Search Unity

Bug Crash - AdMob

Discussion in 'Unity Mediation' started by bearhugmo, May 11, 2022.

  1. bearhugmo

    bearhugmo

    Joined:
    Mar 20, 2019
    Posts:
    19
    Crash when showing an AdMob ad. I realise this is probably a Google Ads issue but thought I'd provide insight since we are showing them via UnityMediation now.

    Code (CSharp):
    1. CrashReporter Key:  aad8faa2cf7f5af1494e218ca01d937a12a64b7e
    2. Hardware Model:     iPhone9,4
    3. Process:            AliceLegends
    4. Identifier:         com.bhe.alicelegends
    5. Version:            3.3.0
    6. Role:               Background
    7. OS Version:         iOS 15.4.1
    8. Exception Type:     EXC_BAD_ACCESS
    9.  
    10.  
    11. EXC_BAD_ACCESS: Attempted to dereference garbage pointer 0x58.
    12.  
    13. 0  AliceLegends       GC_is_marked (mark.c:242:17)
    14. 1  AliceLegends       GC_finish_collection (alloc.c:1084:7)
    15. 2  AliceLegends       GC_try_to_collect_inner (alloc.c:592:5)
    16. 3  AliceLegends       GC_init (misc.c:1323:9)
    17. 4  AliceLegends       GC_generic_malloc_inner (malloc.c:174:15)
    18. 5  gcj_mlc.c          GC_gcj_malloc
    19. 6  AliceLegends       il2cpp::vm::Object::NewAllocSpecific(Il2CppClass*) (Object.cpp:78:9)
    20. 7  AliceLegends       il2cpp::vm::Thread::Attach(Il2CppDomain*) (Thread.cpp:121:40)
    21. 8  AliceLegends       il2cpp::vm::ScopedThreadAttacher::ScopedThreadAttacher() (ScopedThreadAttacher.cpp:10:28)
    22. 9  AliceLegends       ReversePInvokeWrapper_IosRewardedShowListener_Closed_m1E7E7EA93868CF08856059BE30E458569D7B4DAB (Unity.Mediation.cpp:7644:35)
    23. 10 AliceLegends       -[UMSPRewardedAdShowDelegate onRewardedClosed:] (UMSPRewardedAdShowDelegate.mm:27:9)
    24. 11 UnityFramework     -[UMSRewardedAd triggerOnRewardedClosed]
    25. 12 UnityFramework     -[UMSRewardedAd onRewardedAdapterClosed]
    26. 13 UnityFramework     __36-[UMSAdmobRewardedAd show:delegate:]_block_invoke_2
    27. 14 UnityFramework     -[UMSAdmobFullScreenContentDelegate adDidDismissFullScreenContent:]
    28. 15 UnityFramework     GAD_GADRewardedAd_arm64_8_13_0
    29. 16 UnityFramework     __copy_helper_block_e8_32s40s48s56b64s
    30. 17 UnityFramework     __copy_helper_block_e8_32s40s48s56b64s
    31. 18 UnityFramework     GADPostNotification
    32. 19 Foundation         -[__NSObserver _doit:]
    33. 20 CoreFoundation     ___CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__
    34. 21 CoreFoundation     ____CFXRegistrationPost_block_invoke
    35. 22 CoreFoundation     __CFXRegistrationPost
    36. 23 CoreFoundation     __CFXNotificationPost
    37. 24 Foundation         -[NSNotificationCenter postNotificationName:object:userInfo:]
    38. 25 UnityFramework     GADPostNotification
    39. 26 UnityFramework     GADPostNotification
    40. 27 UnityFramework     GAD_GADIntermission_arm64_8_13_0
    41. 28 UnityFramework     GAD_GADIntermission_arm64_8_13_0
    42. 29 UnityFramework     GAD_GADIntermission_arm64_8_13_0
    43. 30 UnityFramework     GADPostNotification
    44. 31 Foundation         -[__NSObserver _doit:]
    45. 32 CoreFoundation     ___CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__
    46. 33 CoreFoundation     ____CFXRegistrationPost_block_invoke
    47. 34 CoreFoundation     __CFXRegistrationPost
    48. 35 CoreFoundation     __CFXNotificationPost
    49. 36 Foundation         -[NSNotificationCenter postNotificationName:object:userInfo:]
    50. 37 UnityFramework     GADPostNotification
    51. 38 UnityFramework     GADPostNotification
    52. 39 UnityFramework     GAD_GADFullScreenAdViewController_arm64_8_13_0
    53. 40 UIKitCore          -[UIViewController _setViewAppearState:isAnimating:]
    54. 41 UIKitCore          -[UIViewController __viewDidDisappear:]
    55. 42 UIKitCore          -[UIViewController _endAppearanceTransition:]
    56. 43 UIKitCore          ___48-[UIPresentationController transitionDidFinish:]_block_invoke
    57. 44 UIKitCore          -[UIPresentationController transitionDidFinish:]
    58. 45 UIKitCore          -[_UICurrentContextPresentationController transitionDidFinish:]
    59. 46 UIKitCore          ___56-[UIPresentationController runTransitionForCurrentState]_block_invoke.437
    60. 47 UIKitCore          -[_UIViewControllerTransitionContext completeTransition:]
    61. 48 UIKitCore          -[UIViewControllerBuiltinTransitionViewAnimator animateTransition:]
    62. 49 UIKitCore          ____UIViewControllerTransitioningRunCustomTransition_block_invoke_2
    63. 50 UIKitCore          +[UIKeyboardSceneDelegate _pinInputViewsForKeyboardSceneDelegate:onBehalfOfResponder:duringBlock:]
    64. 51 UIKitCore          ____UIViewControllerTransitioningRunCustomTransition_block_invoke.641
    65. 52 UIKitCore          +[UIView(Animation) _setAlongsideAnimations:toRunByEndOfBlock:]
    66. 53 UIKitCore          __UIViewControllerTransitioningRunCustomTransition
    67. 54 UIKitCore          ___56-[UIPresentationController runTransitionForCurrentState]_block_invoke.401
    68. 55 UIKitCore          +[UIPresentationController _scheduleTransition:]
    69. 56 UIKitCore          -[UIPresentationController runTransitionForCurrentState]
    70. 57 UIKitCore          -[UIPresentationController _dismissWithAnimationController:interactionController:target:didEndSelector:]
    71. 58 UIKitCore          ___99-[UIViewController _dismissViewControllerWithAnimationController:interactionController:completion:]_block_invoke_2
    72. 59 UIKitCore          +[UIView(Animation) performWithoutAnimation:]
    73. 60 UIKitCore          -[UIViewController _dismissViewControllerWithAnimationController:interactionController:completion:]
    74. 61 UIKitCore          +[UIView(Animation) performWithoutAnimation:]
    75. 62 UIKitCore          -[UIViewController _dismissViewControllerWithTransition:from:completion:]
    76. 63 UIKitCore          -[UIViewController dismissViewControllerWithTransition:completion:]
    77. 64 UIKitCore          -[UIViewController _performCoordinatedPresentOrDismiss:animated:]
    78. 65 UIKitCore          -[UIViewController dismissViewControllerAnimated:completion:]
    79. 66 UIKitCore          ___68-[UIWindow _removeAllViewControllersFromWindowHierarchyFromDealloc:]_block_invoke
    80. 67 UIKitCore          +[UIViewController _performWithoutDeferringTransitionsAllowingAnimation:actions:]
    81. 68 UIKitCore          -[UIWindow _removeAllViewControllersFromWindowHierarchyFromDealloc:]
    82. 69 UIKitCore          -[UIWindow setRootViewController:]
    83. 70 AliceLegends       UnityCleanupTrampoline (UnityAppController.mm:178:34)
    84. 71 AliceLegends       -[UnityAppController applicationWillTerminate:] (UnityAppController.mm:518:9)
    85. 72 UIKitCore          -[UIApplication _terminateWithStatus:]
    86. 73 UIKitCore          -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]
    87. 74 UIKitCore          -[_UISceneLifecycleMultiplexer forceExitWithTransitionContext:scene:]
    88. 75 UIKitCore          -[UIApplication workspaceShouldExit:withTransitionContext:]
    89. 76 FrontBoardServices ___63-[FBSWorkspaceScenesClient willTerminateWithTransitionContext:]_block_invoke_2
    90. 77 FrontBoardServices -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:]
    91. 78 FrontBoardServices ___63-[FBSWorkspaceScenesClient willTerminateWithTransitionContext:]_block_invoke
    92. 79 libdispatch.dylib  __dispatch_client_callout
    93. 80 libdispatch.dylib  __dispatch_block_invoke_direct$VARIANT$mp
    94. 81 FrontBoardServices __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__
    95. 82 FrontBoardServices -[FBSSerialQueue _targetQueue_performNextIfPossible]
    96. 83 FrontBoardServices -[FBSSerialQueue _performNextFromRunLoopSource]
    97. 84 CoreFoundation     ___CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
    98. 85 CoreFoundation     ___CFRunLoopDoSource0
    99. 86 CoreFoundation     ___CFRunLoopDoSources0
    100. 87 CoreFoundation     ___CFRunLoopRun
    101. 88 CoreFoundation     _CFRunLoopRunSpecific
    102. 89 GraphicsServices   _GSEventRunModal
    103. 90 UIKitCore          -[UIApplication _run]
    104. 91 UIKitCore          _UIApplicationMain
    105. 92 AliceLegends       -[UnityFramework runUIApplicationMainWithArgc:argv:] (main.mm:96:5)
    106. 93 AliceLegends       main (main.mm:26:9)
     
  2. DeclanMcPartlin

    DeclanMcPartlin

    Unity Technologies

    Joined:
    Nov 19, 2020
    Posts:
    146
    Hey @mobearhug,

    Thanks for sharing this. One question, do you have an OnClosed event subscribed to your RewardedAd instance? Would you mind sharing the contents of that if it exists?

    Are there any other steps you're doing to trigger this behaviour? Is it 100% reproducible for you? So far I haven't been able to reproduce this.

    Thanks!
     
  3. bearhugmo

    bearhugmo

    Joined:
    Mar 20, 2019
    Posts:
    19
    I've only observed this on one occurrence so far and it occurred after the app was suspended.
    upload_2022-5-12_10-3-35.png

    Here are the contents of our callback and the delayed method which handles the behaviour.

    Code (CSharp):
    1. private void OnAdClosed(object sender, EventArgs e)
    2.         {
    3.             Logger.Debug(nameof(OnAdClosed));
    4.          
    5.             // Delay by a frame because it is possible for OnAdClosed to be called before OnUserEarnedReward
    6.             void OnAction()
    7.             {
    8.                 _scheduler.ScheduleFrames(1, OnDelayAdClosed);
    9.             }
    10.          
    11.             OnAction();
    12.         }
    13.  
    14.         private void OnDelayAdClosed()
    15.         {
    16.             if (!_watched)
    17.             {
    18.                 Assert.IsNotNull(LoadedAd);
    19.                 Skipped?.Invoke(LoadedAd);
    20.             }
    21.             else
    22.             {
    23.                 Watched?.Invoke(LoadedAd);
    24.             }
    25.        
    26.             IsWatching.Value = false;
    27.             ReloadInternal(LoadedAd);
    28.         }
     
  4. DeclanMcPartlin

    DeclanMcPartlin

    Unity Technologies

    Joined:
    Nov 19, 2020
    Posts:
    146
    Hi @mobearhug,

    Thank you for sharing this insight. So OnAdClosed is called after the app goes into the background. That is strange. Generally, this event is triggered by a user invoked event, where the close button is clicked. I've tested to see if Admob's rewarded ad triggers this event in the background, but so far I haven't been able to reproduce. I'll let you know if I am able to reproduce.

    Thanks
     
    bearhugmo likes this.
  5. bearhugmo

    bearhugmo

    Joined:
    Mar 20, 2019
    Posts:
    19
    Could it be impacted by runInBackground flag being set on the device?

    upload_2022-5-12_15-43-10.png
     
  6. bearhugmo

    bearhugmo

    Joined:
    Mar 20, 2019
    Posts:
    19
    Also we had rolled back to
    <iosPod name="UnityAds" version="4.1.0"/> when we saw this.
     
  7. DeclanMcPartlin

    DeclanMcPartlin

    Unity Technologies

    Joined:
    Nov 19, 2020
    Posts:
    146
    Hey @mobearhug, I'll see if I can reproduce that and if I can, I'll let you know.

    As for the UnityAds rollback, if you remove that XML file, do you still see this issue? You should see UnityAds 4.2.1 installed at that point.

    Thank you for sharing this issue!

    Best regards,