Skip to content

iOS Adomb crash -Multiple locks on web thread not allowed #53

Closed

Description

@zettyfactory

OS target (Android/iOS):
iOS

Godot version:
3.0.6

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.

Activity

  1. changed the title [-]iOs Adomb crash[/-] [+]iOS Adomb crash[/+] on Nov 12, 2018
  2. changed the title [-]iOS Adomb crash[/-] [+]iOS Adomb crash -Multiple locks on web thread not allowed[/+] on Nov 12, 2018
  3. Shin-NiL commented on Nov 13, 2018

    @Shin-NiL
    Collaborator

    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.

  4. zettyfactory commented on Nov 14, 2018

    @zettyfactory
    Author

    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

    0x1215f1e37 <+215>: leaq   0x1738026(%rip), %rdi     ; webLock + 12
    0x1215f1e3e <+222>: callq  0x1229abad2               ; symbol stub for: WTF::Lock::lockSlow()
    0x1215f1e43 <+227>: jmp    0x1215f1dd2               ; <+114>
    0x1215f1e45 <+229>: callq  0x1215f30e0               ; CurrentThreadContext()
    0x1215f1e4a <+234>: movq   %rax, %rcx
    0x1215f1e4d <+237>: leaq   0x170d85c(%rip), %rdi     ; @"%s, %p: Tried to obtain the web lock from a thread other than the main thread or the web thread. This may be a result of calling to UIKit from a secondary thread. Crashing now..."
    0x1215f1e54 <+244>: leaq   0x13fb86f(%rip), %rsi     ; "void _WebThreadLock()"
    0x1215f1e5b <+251>: xorl   %eax, %eax
    0x1215f1e5d <+253>: movq   %rcx, %rdx
    0x1215f1e60 <+256>: callq  0x1229aae2a               ; symbol stub for: NSLog
    0x1215f1e65 <+261>: int3   
    0x1215f1e66 <+262>: ud2    
    0x1215f1e68 <+264>: callq  0x1215f30e0               ; CurrentThreadContext()
    0x1215f1e6d <+269>: movq   %rax, %rcx
    0x1215f1e70 <+272>: leaq   0x170d859(%rip), %rdi     ; @"%s, %p: Multiple locks on web thread not allowed! Please file a bug. Crashing now..."
    0x1215f1e77 <+279>: leaq   0x13fb84c(%rip), %rsi     ; "void _WebThreadLock()"
    0x1215f1e7e <+286>: xorl   %eax, %eax
    0x1215f1e80 <+288>: movq   %rcx, %rdx
    0x1215f1e83 <+291>: callq  0x1229aae2a               ; symbol stub for: NSLog
    0x1215f1e88 <+296>: int3   
    

    -> 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)

  5. lukasmican commented on Nov 29, 2018

    @lukasmican

    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)

  6. Shin-NiL commented on Nov 29, 2018

    @Shin-NiL
    Collaborator

    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".

  7. opencma commented on Dec 5, 2018

    @opencma

    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_async or dispatch_sync_f, using dispatch_get_main_queue as the queue.

  8. gvdb commented on Dec 8, 2018

    @gvdb

    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 Dispatch dispatch_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_deferred method. 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?).

  9. Shin-NiL commented on Dec 8, 2018

    @Shin-NiL
    Collaborator

    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.

  10. gvdb commented on Dec 8, 2018

    @gvdb

    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.

    Will investigate more.

  11. gvdb commented on Dec 9, 2018

    @gvdb

    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 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.

  12. opencma commented on Dec 9, 2018

    @opencma

    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.

  13. gvdb commented on Dec 9, 2018

    @gvdb

    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.

  14. 32 remaining items

  15. yamshing commented on Aug 14, 2019

    @yamshing

    @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 ?)

  16. Dridia1 commented on Aug 15, 2019

    @Dridia1

    @yamshing I were using the interstitial ad, so I changed the following line instead:

    [self performSelector:@selector(bannerEnable) withObject:nil afterDelay:0];

    This works perfect, and I'm running iOS 12.4 on an iPhone X

  17. yamshing commented on Aug 15, 2019

    @yamshing

    @Dridia1 thanks for your test. I will change the delay and commit the change

  18. canvasbushi commented on Aug 20, 2019

    @canvasbushi

    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.

  19. yamshing commented on Aug 24, 2019

    @yamshing

    @canvasbushi thank you for your suggestion I will test this

  20. alfredocova commented on Oct 30, 2019

    @alfredocova

    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

  21. pinned this issue on May 4, 2020
  22. gumaciel commented on May 4, 2020

    @gumaciel

    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

  23. unpinned this issue on May 6, 2020
  24. gumaciel commented on May 6, 2020

    @gumaciel

    This issue is fixed on 3.1.2, if someone is still facing this issue, please comment here

  25. pchasco commented on May 27, 2020

    @pchasco

    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.

  26. pchasco commented on Jun 26, 2020

    @pchasco

    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.

  27. gumaciel commented on Jun 27, 2020

    @gumaciel

    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?

  28. pchasco commented on Jun 27, 2020

    @pchasco
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions