Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Crashes when you force close an iOS app with another view controller up?

Discussion in 'iOS and tvOS' started by dean0, Apr 23, 2020.

  1. dean0

    dean0

    Joined:
    Mar 7, 2014
    Posts:
    8
    We have an issue where if you force close the app while an Ad is up, the app crashes.
    Using AdMob and it happens with any of the mediated Ads.

    It generates tens of thousands of crashes for us in our logs (a player wouldn't notice that it's crashing though).
    I can't anyone mentioning this when I google the issue! Is it just me? I am going crazy here.

    AdMob have investigated and said its a unity issue, and happens even if you bring up a blank view controller.

    I have submitted a bug, But it would be great to know if anyone else is experiencing this. Basically just show an Ad and then force quit the game.

    Other details:
    Only happens on iOS 13 devices.
    Only started when we upgraded to 2019.3

    Crashes look like this:

    0 UnityFramework 0x10317fd14 UnityIsOrientationEnabled + 250 (ScreenManager.h:250)
    1 UnityFramework 0x10317fd14 UnityIsOrientationEnabled + 250 (ScreenManager.h:250)
    2 UnityFramework 0x10241859c EnabledAutorotationInterfaceOrientations() + 178 (UnityViewControllerBase+iOS.mm:178)
    3 UnityFramework 0x10240d05c -[UnityAppController application:supportedInterfaceOrientationsForWindow:] + 201 (UnityAppController.mm:201)
    4 UIKitCore 0x1b199c140 -[UIApplication _supportedInterfaceOrientationsForWindow:] + 108
    5 UIKitCore 0x1b1397a64 -[UIViewController __supportedInterfaceOrientations] + 256
    6 UIKitCore 0x1b1389028 -[UIViewController _preferredInterfaceOrientationGivenStatusBarAndDeviceAndOrientation:] + 104
    7 UIKitCore 0x1b1397680 -[UIViewController _preferredInterfaceOrientationForPresentationInWindow:fromInterfaceOrientation:] + 544
    8 UIKitCore 0x1b12a81c8 -[_UIFullscreenPresentationController _adjustOrientationIfNecessaryInWindow:forViewController:preservingViewController:] + 576
    9 UIKitCore 0x1b129deb8 -[UIPresentationController _dismissWithAnimationController:interactionController:target:didEndSelector:] + 684
    10 UIKitCore 0x1b139201c __99-[UIViewController _dismissViewControllerWithAnimationController:interactionController:completion:]_block_invoke_2 + 72
    11 UIKitCore 0x1b1e20c14 +[UIView(Animation) performWithoutAnimation:] + 96
    12 UIKitCore 0x1b1391e98 -[UIViewController _dismissViewControllerWithAnimationController:interactionController:completion:] + 580
    13 UIKitCore 0x1b1e20c14 +[UIView(Animation) performWithoutAnimation:] + 96
    14 UIKitCore 0x1b1391b4c -[UIViewController _dismissViewControllerWithTransition:from:completion:] + 816
    15 UIKitCore 0x1b1391228 -[UIViewController dismissViewControllerWithTransition:completion:] + 1200
    16 UIKitCore 0x1b1390c90 -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 508
    17 UIKitCore 0x1b13933a0 -[UIViewController dismissViewControllerAnimated:completion:] + 132
    18 UIKitCore 0x1b19d028c __68-[UIWindow _removeAllViewControllersFromWindowHierarchyFromDealloc:]_block_invoke + 60
    19 UIKitCore 0x1b138b154 +[UIViewController _performWithoutDeferringTransitionsAllowingAnimation:actions:] + 168
    20 UIKitCore 0x1b19cff1c -[UIWindow _removeAllViewControllersFromWindowHierarchyFromDealloc:] + 288
    21 UIKitCore 0x1b19d0438 -[UIWindow setRootViewController:] + 284
    22 UnityFramework 0x10240cf40 UnityCleanupTrampoline + 168 (UnityAppController.mm:168)
    23 UnityFramework 0x10240df04 -[UnityAppController applicationWillTerminate:] + 468 (UnityAppController.mm:468)
    24 UIKitCore 0x1b199dae0 -[UIApplication _terminateWithStatus:] + 244


    Also like this, looks like the same thing:

    Crashed: com.apple.main-thread
    0 UnityFramework 0x1050a840c MetalHeap::AliasResources() + 89324
    1 UnityFramework 0x1050a840c MetalHeap::AliasResources() + 89324
    2 UnityFramework 0x10433539c UnityAdsEngineSetDidFinishCallback + 30808
    3 UnityFramework 0x104329e5c (Missing)
    4 UIKitCore 0x19c905180 -[UIApplication _supportedInterfaceOrientationsForWindow:] + 112
    5 UIKitCore 0x19c2d739c -[UIViewController __supportedInterfaceOrientations] + 260
    6 UIKitCore 0x19c2c8278 -[UIViewController _preferredInterfaceOrientationGivenStatusBarAndDeviceAndOrientation:] + 108
    7 UIKitCore 0x19c2d6f90 -[UIViewController _preferredInterfaceOrientationForPresentationInWindow:fromInterfaceOrientation:] + 548
    8 UIKitCore 0x19c1e1b78 -[_UIFullscreenPresentationController _adjustOrientationIfNecessaryInWindow:forViewController:preservingViewController:] + 604
    9 UIKitCore 0x19c1d75ac -[UIPresentationController _dismissWithAnimationController:interactionController:target:didEndSelector:] + 652
    10 UIKitCore 0x19c2d16a4 __99-[UIViewController _dismissViewControllerWithAnimationController:interactionController:completion:]_block_invoke_2 + 76
    11 UIKitCore 0x19cda6d54 +[UIView(Animation) performWithoutAnimation:] + 104
    12 UIKitCore 0x19c2d14f8 -[UIViewController _dismissViewControllerWithAnimationController:interactionController:completion:] + 608
    13 UIKitCore 0x19cda6d54 +[UIView(Animation) performWithoutAnimation:] + 104
    14 UIKitCore 0x19c2d118c -[UIViewController _dismissViewControllerWithTransition:from:completion:] + 832
    15 UIKitCore 0x19c2d084c -[UIViewController dismissViewControllerWithTransition:completion:] + 1236
    16 UIKitCore 0x19c2d0270 -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 528
    17 UIKitCore 0x19c2d2af0 -[UIViewController dismissViewControllerAnimated:completion:] + 148
    18 UIKitCore 0x19c93a9f8 __68-[UIWindow _removeAllViewControllersFromWindowHierarchyFromDealloc:]_block_invoke + 64
    19 UIKitCore 0x19c2ca500 +[UIViewController _performWithoutDeferringTransitionsAllowingAnimation:actions:] + 176
    20 UIKitCore 0x19c93a678 -[UIWindow _removeAllViewControllersFromWindowHierarchyFromDealloc:] + 304
    21 UIKitCore 0x19c93abb4 -[UIWindow setRootViewController:] + 288
    22 UnityFramework 0x104329d40 (Missing)
    23 UnityFramework 0x10432ad04 (Missing)
    24 UIKitCore 0x19c906bc0 -[UIApplication _terminateWithStatus:] + 248
     
  2. zoranigic

    zoranigic

    Joined:
    Oct 4, 2019
    Posts:
    12
    I confirm that, we have a exactly same issue, I fixed it in one app by downgrading Unity version to 2019.2. Other proposed fix is in this post but I do not know if that is a good solution
     
    Last edited: Apr 23, 2020
  3. zoranigic

    zoranigic

    Joined:
    Oct 4, 2019
    Posts:
    12
    Cause of error is on line 5. in example code
    [_UnityAppController window].rootViewController = nil;
    (in UnityAppController.mm file).

    Commenting it prevent error from happening.

    Code (CSharp):
    1. extern "C" void UnityCleanupTrampoline()
    2. {
    3.     // Unity view and viewController will not necessary be destroyed right after this function execution.
    4.     // We need to ensure that these objects will not receive any callbacks from system during that time.
    5.     //[_UnityAppController window].rootViewController = nil;
    6.     [[_UnityAppController unityView] removeFromSuperview];
    7.  
    8.     // Prevent multiple cleanups
    9.     if (_UnityAppController == nil)
    10.         return;
    11.  
    12.     [KeyboardDelegate Destroy];
    13.  
    14.     SensorsCleanup();
    15.  
    16.     Profiler_UninitProfiler();
    17.  
    18.     [DisplayManager Destroy];
    19.  
    20.     UnityDestroyDisplayLink();
    21.  
    22.     _UnityAppController = nil;
    23. }
     
    Last edited: Apr 24, 2020
    Neonlyte likes this.
  4. dean0

    dean0

    Joined:
    Mar 7, 2014
    Posts:
    8
    Thanks heaps for the reply, I really appreciate it!
    Was really struggling to find any trace of this issue, so it's good to know it's not just me!

    I will investigate those links, they look like they could be helpful.
     
    zoranigic likes this.
  5. odysoftware

    odysoftware

    Joined:
    Jul 21, 2015
    Posts:
    60
    From my own experience, had the same issues with many native crashes after upgrading to 2019.3.1f9,.. but after downgrading back to 2019.3.1f6 all is fine again.
     
  6. yurykorzun

    yurykorzun

    Joined:
    Oct 29, 2015
    Posts:
    41
    In my case, I had also to comment out this line

    [KeyboardDelegate Destroy];

    It was causing a crash because a keyboard selector was nil
     
  7. kgbv

    kgbv

    Joined:
    Jun 5, 2013
    Posts:
    13
    i facing the issue . i tried all the above possibilities but still facing the same .
     
  8. PandaArcade

    PandaArcade

    Joined:
    Jan 2, 2017
    Posts:
    73
    We're are seeing the same errors in our Crashes and Exceptions but players aren't reporting any issues.

    Did anyone find a solution? It's been a month since the last post here and I don't see anything in the release notes to suggest Unity has fixed it?
     
  9. arnaldoGaroto

    arnaldoGaroto

    Joined:
    Feb 3, 2013
    Posts:
    7
    I had the same, it was caused by a n objectiveC plugin that instantiated a UIViewController at start and stored it in a global variable
     
    PandaArcade likes this.
  10. Alexey

    Alexey

    Unity Technologies

    Joined:
    May 10, 2010
    Posts:
    1,406
    >>Did anyone find a solution? It's been a month since the last post here and I don't see anything in the release notes to suggest Unity has fixed it?

    well there are zero bug cases mentioned

    it was fixed in 2020.1/2020.2
     
  11. PandaArcade

    PandaArcade

    Joined:
    Jan 2, 2017
    Posts:
    73
    @Alexey If it's fixed in 2020.1/2020.2 has it or can it be backported to 2019.4?
     
    szagurskii likes this.
  12. PandaArcade

    PandaArcade

    Joined:
    Jan 2, 2017
    Posts:
    73
    @Alexey bump

    Adding the fix to alpha/beta versions of Unity is not very helpful since this bug is likely not a big concern to developers without published games/apps.
     
    dean0 likes this.
  13. odysoftware

    odysoftware

    Joined:
    Jul 21, 2015
    Posts:
    60
    We have the same issues several reports of crashes - but its always just on closing, so yeah it is not causing issues for customers, but it makes it bad for tracking crashes... and I think it should not crash on closing either...

    I also agree on PAndaArcada - fixing it for alpha/beta version is nice but the main focus for this fix should be the LTS version.
     
    PandaArcade likes this.
  14. PandaArcade

    PandaArcade

    Joined:
    Jan 2, 2017
    Posts:
    73
  15. Alexey

    Alexey

    Unity Technologies

    Joined:
    May 10, 2010
    Posts:
    1,406
    >>If it's fixed in 2020.1/2020.2 has it or can it be backported to 2019.4?
    it should. I'll see what is happening on this front
     
    nicolasgramlich and PandaArcade like this.
  16. PandaArcade

    PandaArcade

    Joined:
    Jan 2, 2017
    Posts:
    73
  17. nicolasgramlich

    nicolasgramlich

    Joined:
    Sep 21, 2017
    Posts:
    182
    It's still happening on 2019.4.6f1 :'(

    Screen Shot 2020-08-03 at 11.01.05 PM.png
     
    PandaArcade likes this.
  18. Tortuap

    Tortuap

    Joined:
    Dec 4, 2013
    Posts:
    78
    Your call-stack has nothing related with the issue & call-stack described here. Please thoroughly verify what you claim.
     
  19. nicolasgramlich

    nicolasgramlich

    Joined:
    Sep 21, 2017
    Posts:
    182
    It's a VERY similar stack trace than in the the opening post:

    Just as the opening post the crash happens through UnityAdsEngineSetDidFinishCallback, when the app is closed/backgrounded while an ad.
     
  20. Shankar-Ganesh

    Shankar-Ganesh

    Joined:
    Sep 23, 2013
    Posts:
    20
    Hi, we have encountered the same issue in Unity LTS Version 2019.4.8f1. We went LIVE the game last week in App Store and get massive number of Crashes. We are using Firebase Crashlytics. Among 3.3K unique users 8.8K crashes have been happened. Our user base is huge and we don't want let our Ratings&Reviews down. Please have a quick look.

    upload_2020-9-14_16-48-26.png

    EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x000000000000024a
    MetalHeap::AliasResources()

    Crashed: com.apple.main-thread
    0 UnityFramework 0x101cf5090 MetalHeap::AliasResources() + 151952
    1 UnityFramework 0x100ae2b00 UnityAdsEngineSetDidFinishCallback + 29816
    2 UIKitCore 0x1afe02228 <redacted> + 168
    3 UIKitCore 0x1afe17f78 <redacted> + 572
    4 UIKitCore 0x1b0477ac0 <redacted> + 360
    5 UIKitCore 0x1b0477814 <redacted> + 852
    6 UIKitCore 0x1b0483b5c <redacted> + 248
    7 UIKitCore 0x1b04799c8 <redacted> + 388
    8 UIKitCore 0x1afe33f68 <redacted> + 172
    9 UIKitCore 0x1b08e46f4 <redacted> + 204
    10 UIKitCore 0x1afe33d5c <redacted> + 164
    11 UIKitCore 0x1afe33c34 <redacted> + 492
    12 UIKitCore 0x1b0477118 <redacted> + 580
    13 UIKitCore 0x1b04796f4 <redacted> + 1420
    14 UIKitCore 0x1b0479c08 <redacted> + 408
    15 UIKitCore 0x1b0478fdc <redacted> + 128
    16 UIKitCore 0x1afd200b0 <redacted> + 504
    17 UIKitCore 0x1afd1fdf4 <redacted> + 880
    18 UIKitCore 0x1afd15aac <redacted> + 684
    19 UIKitCore 0x1afe090fc <redacted> + 72
    20 UIKitCore 0x1b08df16c <redacted> + 96
    21 UIKitCore 0x1afe08f78 <redacted> + 580
    22 UIKitCore 0x1b08df16c <redacted> + 96
    23 UIKitCore 0x1afe08c2c <redacted> + 816
    24 UIKitCore 0x1afe08304 <redacted> + 1200
    25 UIKitCore 0x1afe07d6c <redacted> + 508
    26 UIKitCore 0x1afe0a474 <redacted> + 132
    27 UIKitCore 0x1b0470b50 <redacted> + 60
    28 UIKitCore 0x1afe02228 <redacted> + 168
    29 UIKitCore 0x1b04707f0 <redacted> + 284
    30 UIKitCore 0x1b0470cfc <redacted> + 284
    31 UnityFramework 0x100ad791c (Missing)
    32 UnityFramework 0x100ad89c0 (Missing)
    33 UIKitCore 0x1b043d9a4 <redacted> + 244
    34 UIKitCore 0x1afbdb0d0 <redacted> + 124
    35 UIKitCore 0x1afbdad58 <redacted> + 216
    36 UIKitCore 0x1b0433b44 <redacted> + 212
    37 FrontBoardServices 0x1b15048a0 <redacted> + 84
    38 FrontBoardServices 0x1b152f9bc <redacted> + 76
    39 FrontBoardServices 0x1b1515bfc <redacted> + 232
    40 FrontBoardServices 0x1b152f94c <redacted> + 124
    41 libdispatch.dylib 0x1ac04a524 <redacted> + 16
    42 libdispatch.dylib 0x1abff3434 <redacted> + 224
    43 FrontBoardServices 0x1b1554850 <redacted> + 40
    44 FrontBoardServices 0x1b155451c <redacted> + 404
    45 FrontBoardServices 0x1b1554a44 <redacted> + 28
    46 CoreFoundation 0x1ac302ad8 <redacted> + 24
    47 CoreFoundation 0x1ac302a30 <redacted> + 80
    48 CoreFoundation 0x1ac3021b8 <redacted> + 184
    49 CoreFoundation 0x1ac2fd1e8 <redacted> + 788
    50 CoreFoundation 0x1ac2fcba8 CFRunLoopRunSpecific + 424
    51 GraphicsServices 0x1b6473344 GSEventRunModal + 160
    52 UIKitCore 0x1b04383e4 UIApplicationMain + 1932
    53 UnityFramework 0x100adcd70 UnityAdsEngineSetDidFinishCallback + 5864
    54 wcc3 0x10080fe1c main + 28 (main.mm:28)
    55 libdyld.dylib 0x1ac1848f0 <redacted> + 4
     

    Attached Files:

  21. Shankar-Ganesh

    Shankar-Ganesh

    Joined:
    Sep 23, 2013
    Posts:
    20
    Do anyone have found the solution?
     
  22. Haze-Games

    Haze-Games

    Joined:
    Mar 1, 2015
    Posts:
    83
    Still have crashes after a few seconds of exiting the game as well on iOS. Looking into it...
     
  23. PandaArcade

    PandaArcade

    Joined:
    Jan 2, 2017
    Posts:
    73
    @Alexey ...did you find out what was happening on this front? :D
     
  24. pistoleta

    pistoleta

    Joined:
    Sep 14, 2017
    Posts:
    167
    How did you get that log report ? is some kind of asset?
    Thanks in advance
     
unityunity