You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
iOS Adomb crash -Multiple locks on web thread not allowed #53
Issue description:
Everything works well in android.
However, iOS has problems.
For example, an error occurs after Reward Video is terminated.
2018-11-13 04:30:20.350877+0900 hoonword[4062:184752] [avas] AVAudioSessionPortImpl.mm:56:ValidateRequiredFields: Unknown selected data source for Port Speaker (type: Speaker)
2018-11-13 04:30:20.374741+0900 hoonword[4062:185038] void _WebThreadLock(), 0x10c2ef040: Multiple locks on web thread not allowed! Please file a bug. Crashing now...
(lldb)
I am struggling with this problem for a few days, but I am not an iOS developer, so it is difficult. I would be very grateful if you gave me the answer.
Which versions of Google Mobile Ads SDK, Xcode and iOS are you using?
Unfortunately I don't have any Apple hardware, so I'm afraid I can't help much here. I hope somebody from the community can help us to maintain this module for iOS.
The same thing happens in the iOS simulator.
I saw the source for you, but I am not an iOS developer, so I can not tell you exactly what the problem is.
Compared to the admob sample code, it looks like no problem. But the error still occurs.
I have encountered similar problem, on Android it works fine, but on iOS after terminating Interstitial Ad the application exits. Unfortunately I am not an iOS developer too and I don't own Mac or any iOS device, so debugging iOS apps is pretty hard for me.
UIKit view modifications should be made only on the main thread. NSThread's isMainThread can be used to determine if the current thread is the main. If the current thread is not the main, the modifications can be delegated to it via Dispatchdispatch_async or dispatch_sync_f, using dispatch_get_main_queue as the queue.
I was getting this problem too when returning from a RewardAd. I used the code from the examples provided in this repo and the crash seemed to be occurring on the label text update i.e. get_node("CanvasLayer/LblRewarded").set_text("Reward: " + currency + ", " + str(amount))
UIKit view modifications should be made only on the main thread. NSThread's isMainThread can be used to determine if the current thread is the main. If the current thread is not the main, the modifications can be delegated to it via Dispatchdispatch_async or dispatch_sync_f, using dispatch_get_main_queue as the queue.
I wasn't sure how to do any of that within Godot, but the closest thing I could find that seemed in the right ballpark was the call_deferredmethod. I wrapped the label text update code (above) in a call_deferred method and it seems to have fixed it, though I'm not entirely sure why.
Is there a better way to fix this within Godot? I don't understand how we would modify a Godot app using Apple's libraries (unless there are "hooks" to them within the Godot API?).
I wrapped the label text update code (above) in a call_deferred method and it seems to have fixed it, though I'm not entirely sure why.
Thank you @gvdb, this is interesting information. Can you guys (@zettyfactory , @vinchi9 , @rolandoislas) try this workaround? If it really works, we can try fix the code.
I wrapped the label text update code (above) in a call_deferred method and it seems to have fixed it, though I'm not entirely sure why.
Thank you @gvdb, this is interesting information. Can you guys (@zettyfactory , @vinchi9 , @rolandoislas) try this workaround? If it really works, we can try fix the code.
I tested it a little more this morning, and it still appears to be happening. Seems to be an intermittent issue. By luck I must've had a few instances where it didn't crash last night.
I can't find any way to fix this within the Godot application.
Do the changes suggested by @rolandoislas need to be implemented in the code of this repo itself?
I've attempted to make changes to AdmobRewarded.mm using theselinks as guidance, but my knowledge of the Apple code base is even worse than my knowledge of Godot. I've tried something like this:
But when I try to recompile the Godot engine source, I get errors I'm not sure how to fix, such as the undeclared identifier Thread. Trying to figure out how I instantiate a variable for the "current thread" so I can query whether it's the "main thread".
Will keep trying and update if I make any progress.
edit: By the way @Shin-NiL, I have an iPhone 6 running iOS 12 that I can test this on if needed.
I think the loading of the ad needs to be done on the main thread. For example, this line. I do not have hardware on hand to test at the moment, but I will in a week.
I think the loading of the ad needs to be done on the main thread. For example, this line. I do not have hardware on hand to test at the moment, but I will in a week.
If you can give an example of the code that I would need to add to that line to get it to run on the main thread, I'm happy to test that on my iPhone now.
You have to comment this line, I did this in the AdmobIntersertitial.mm and in AdmobRewarded.mm then you have to recompile again for the iOS
Now you can close the add without getting the banner, I have it running on Xcode 11 and Godot 3.1.1
Perhaps it would be better to remove that line from the module and tell the devs to manually call a banner after an Interstitial instead of calling it automatically
On 2.1 I continue to get this error. In fact, I have stripped everything from the module except the bare minimum of code required by Google to implement a rewarded ad and still receive the error. The issue must be in the engine itself. I have also tried with both Google Ads Frameworks versions 7.41 and 7.60. Same result.
Edit:
I spoke too soon. Updating to the latest SDK, 7.60 seems to correct the issue. You must alter the link flags to link against the new dependencies required by the SDK. The provided frameworks are XCFramework packages, which are not directly supported by the -framework flag as far as I could tell. I had to add the ios-armv7_arm64 directories under each .xcframework to the link path. I don't know of a better way. If this is the best way, then the link flags in config.py will need to be configured per architecture to include the appropriate subdirectory under the .xcframework directories. This is something I can work on. I expect this will solve #135 also.
Godot 3 should now have this issue fixed, as a patch has been merged. The fix has also been picked into the 2.1.7 branch, though at this time it hasn't been officially released. I manually applied the fixes to my own Godot fork.
Activity
[-]iOs Adomb crash[/-][+]iOS Adomb crash[/+][-]iOS Adomb crash[/-][+]iOS Adomb crash -Multiple locks on web thread not allowed[/+]Shin-NiL commentedon Nov 13, 2018
Which versions of Google Mobile Ads SDK, Xcode and iOS are you using?
Unfortunately I don't have any Apple hardware, so I'm afraid I can't help much here. I hope somebody from the community can help us to maintain this module for iOS.
zettyfactory commentedon Nov 14, 2018
The same thing happens in the iOS simulator.
I saw the source for you, but I am not an iOS developer, so I can not tell you exactly what the problem is.
Compared to the admob sample code, it looks like no problem. But the error still occurs.
Version info
XCode : Version 10.1 (10B61)
simulator : iPhone X / iOS 12.1(16B91)
device : IPone6 / iOS 12.1
Admob SDK : 7.29, 7.35
-> 0x1215f1e89 <+297>: ud2
0x1215f1e8b <+299>: nopl (%rax,%rax)
2018-11-14 10:11:06.834799+0900 hoonword[8709:112399] Main -> onReward Button click
Main -> onReward Button click
2018-11-14 10:11:06.835200+0900 hoonword[8709:112399] Calling showInterstitial
2018-11-14 10:11:06.836666+0900 hoonword[8709:112399] interstitialWillPresentScreen
******** screen size 1125, 2436
2018-11-14 10:11:07.288325+0900 hoonword[8709:112399] ERROR: Index p_index=0 out of size (s=0)
2018-11-14 10:11:07.288610+0900 hoonword[8709:112399] At: core/dvector.h:378:remove() - Index p_index=0 out of size (s=0)
ERROR: Index p_index=0 out of size (s=0)
At: core/dvector.h:378:remove() - Index p_index=0 out of size (s=0)
2018-11-14 10:11:09.525277+0900 hoonword[8709:112399] interstitialWillDismissScreen
******** screen size 1125, 2436
2018-11-14 10:11:10.063225+0900 hoonword[8709:113095] void _WebThreadLock(), 0x13e2ef040: Multiple locks on web thread not allowed! Please file a bug. Crashing now...
(lldb)
lukasmican commentedon Nov 29, 2018
I have encountered similar problem, on Android it works fine, but on iOS after terminating Interstitial Ad the application exits. Unfortunately I am not an iOS developer too and I don't own Mac or any iOS device, so debugging iOS apps is pretty hard for me.
Version Info:
Godot 3.0.6
XCode 10.1 (10B61)
Admob SDK 7.36
iPhone 6 (iOS 11.4)
Shin-NiL commentedon Nov 29, 2018
Yeah, we need help from any iOS developer from the community to figure out a solution :(
I'll update the README with this "Known Issue".
opencma commentedon Dec 5, 2018
UIKit view modifications should be made only on the main thread. NSThread's isMainThread can be used to determine if the current thread is the main. If the current thread is not the main, the modifications can be delegated to it via Dispatch
dispatch_asyncordispatch_sync_f, usingdispatch_get_main_queueas the queue.gvdb commentedon Dec 8, 2018
I was getting this problem too when returning from a RewardAd. I used the code from the examples provided in this repo and the crash seemed to be occurring on the label text update i.e.
get_node("CanvasLayer/LblRewarded").set_text("Reward: " + currency + ", " + str(amount))I wasn't sure how to do any of that within Godot, but the closest thing I could find that seemed in the right ballpark was the
call_deferredmethod. I wrapped the label text update code (above) in acall_deferredmethod and it seems to have fixed it, though I'm not entirely sure why.Is there a better way to fix this within Godot? I don't understand how we would modify a Godot app using Apple's libraries (unless there are "hooks" to them within the Godot API?).
Shin-NiL commentedon Dec 8, 2018
Thank you @gvdb, this is interesting information. Can you guys (@zettyfactory , @vinchi9 , @rolandoislas) try this workaround? If it really works, we can try fix the code.
gvdb commentedon Dec 8, 2018
I tested it a little more this morning, and it still appears to be happening. Seems to be an intermittent issue. By luck I must've had a few instances where it didn't crash last night.
Will investigate more.
gvdb commentedon Dec 9, 2018
I can't find any way to fix this within the Godot application.
Do the changes suggested by @rolandoislas need to be implemented in the code of this repo itself?
I've attempted to make changes to
AdmobRewarded.mmusing these links as guidance, but my knowledge of the Apple code base is even worse than my knowledge of Godot. I've tried something like this:if (Thread.isMainThread) { obj->call_deferred("_on_rewarded", [reward.type UTF8String], reward.amount.doubleValue); } else { dispatch_async(dispatch_get_main_queue(), ^{obj->call_deferred("_on_rewarded", [reward.type UTF8String], reward.amount.doubleValue);}); } }But when I try to recompile the Godot engine source, I get errors I'm not sure how to fix, such as the undeclared identifier
Thread. Trying to figure out how I instantiate a variable for the "current thread" so I can query whether it's the "main thread".Will keep trying and update if I make any progress.
edit: By the way @Shin-NiL, I have an iPhone 6 running iOS 12 that I can test this on if needed.
opencma commentedon Dec 9, 2018
I think the loading of the ad needs to be done on the main thread. For example, this line. I do not have hardware on hand to test at the moment, but I will in a week.
gvdb commentedon Dec 9, 2018
If you can give an example of the code that I would need to add to that line to get it to run on the main thread, I'm happy to test that on my iPhone now.
32 remaining items
yamshing commentedon Aug 14, 2019
@Dridia1 Could you test with delay bigger than 0 at
https://github.com/kloder-games/godot-admob/blob/master/admob/ios/src/AdmobRewarded.mm#L83
? If it does nothing tell me more about your environnement ( ios version etc... simulator or real device ?)
Dridia1 commentedon Aug 15, 2019
@yamshing I were using the interstitial ad, so I changed the following line instead:
godot-admob/admob/ios/src/AdmobInterstitial.mm
Line 89 in f1dcaa3
This works perfect, and I'm running iOS 12.4 on an iPhone X
yamshing commentedon Aug 15, 2019
@Dridia1 thanks for your test. I will change the delay and commit the change
canvasbushi commentedon Aug 20, 2019
you should also wrap your bannerEnable method with a
dispatch_async(dispatch_get_main_queue(), ^{
// enable banner
});
so the ui gets updated on the main thread.
yamshing commentedon Aug 24, 2019
@canvasbushi thank you for your suggestion I will test this
alfredocova commentedon Oct 30, 2019
found the answer here
You have to comment this line, I did this in the AdmobIntersertitial.mm and in AdmobRewarded.mm then you have to recompile again for the iOS
Now you can close the add without getting the banner, I have it running on Xcode 11 and Godot 3.1.1
Perhaps it would be better to remove that line from the module and tell the devs to manually call a banner after an Interstitial instead of calling it automatically
gumaciel commentedon May 4, 2020
Someone can test?
I tested on #124 , and its working fine!
Ps: I tested on version 3.1.2, the version 3.2.1 i doesnt test yet
gumaciel commentedon May 6, 2020
This issue is fixed on 3.1.2, if someone is still facing this issue, please comment here
pchasco commentedon May 27, 2020
On 2.1 I continue to get this error. In fact, I have stripped everything from the module except the bare minimum of code required by Google to implement a rewarded ad and still receive the error. The issue must be in the engine itself. I have also tried with both Google Ads Frameworks versions 7.41 and 7.60. Same result.
My clone
Edit:
I spoke too soon. Updating to the latest SDK, 7.60 seems to correct the issue. You must alter the link flags to link against the new dependencies required by the SDK. The provided frameworks are XCFramework packages, which are not directly supported by the -framework flag as far as I could tell. I had to add the ios-armv7_arm64 directories under each .xcframework to the link path. I don't know of a better way. If this is the best way, then the link flags in config.py will need to be configured per architecture to include the appropriate subdirectory under the .xcframework directories. This is something I can work on. I expect this will solve #135 also.
pchasco commentedon Jun 26, 2020
Godot 3 should now have this issue fixed, as a patch has been merged. The fix has also been picked into the 2.1.7 branch, though at this time it hasn't been officially released. I manually applied the fixes to my own Godot fork.
gumaciel commentedon Jun 27, 2020
Hey @pchasco , yes, on Godot 3 this issue is fixed, i dont know if 2.1.X still happens.
2.1.X version is still in working by Godot contributors?
pchasco commentedon Jun 27, 2020