iOS Native Crash on UnityUseAnimatedAutorotation (TrampolineGlue)

Hi, we’re encountering a bunch of native crashes on iOS related to UnityUseAnimatedAutorotation when using 2019.4.9f1.

From what I can gather (based on the stacktrace below), the Trempoline is being cleaned-up on stack frame 31, and being accessed again on stack frame 0, which would probably lead to exceptions since I’d mostly a bad idea to access an object after it’s cleaned-up.

Is anyone else having this issue, or is there a known solution/work-around for this?

Stacktrace (taken from the Unity Crashes & Exceptions page):

Thread 0 (crashed)
0   UnityFramework                     0x0000000106a52f34 UnityUseAnimatedAutorotation (TrampolineGlue.mm:46)
1   UnityFramework                     0x000000010601e834 -[UnityViewControllerBase(iOS) viewWillTransitionToSize:withTransitionCoordinator:] (UnityViewControllerBase+iOS.mm:90)
2   UIKitCore                          0x00000001ac84f22c <system symbols missing>
3   UIKitCore                          0x00000001ac864f7c <system symbols missing>
4   UIKitCore                          0x00000001acec4ac0 <system symbols missing>
5   UIKitCore                          0x00000001acec4814 <system symbols missing>
6   UIKitCore                          0x00000001aced0b5c <system symbols missing>
7   UIKitCore                          0x00000001acec69c8 <system symbols missing>
8   UIKitCore                          0x00000001ac880f6c <system symbols missing>
9   UIKitCore                          0x00000001ad3316f4 <system symbols missing>
10  UIKitCore                          0x00000001ac880d60 <system symbols missing>
11  UIKitCore                          0x00000001ac880c38 <system symbols missing>
12  UIKitCore                          0x00000001acec4118 <system symbols missing>
13  UIKitCore                          0x00000001acec66f4 <system symbols missing>
14  UIKitCore                          0x00000001acec6c08 <system symbols missing>
15  UIKitCore                          0x00000001acec5fdc <system symbols missing>
16  UIKitCore                          0x00000001ac76d0b4 <system symbols missing>
17  UIKitCore                          0x00000001ac76cdf8 <system symbols missing>
18  UIKitCore                          0x00000001ac762ab0 <system symbols missing>
19  UIKitCore                          0x00000001ac856100 <system symbols missing>
20  UIKitCore                          0x00000001ad32c16c <system symbols missing>
21  UIKitCore                          0x00000001ac855f7c <system symbols missing>
22  UIKitCore                          0x00000001ad32c16c <system symbols missing>
23  UIKitCore                          0x00000001ac855c30 <system symbols missing>
24  UIKitCore                          0x00000001ac855308 <system symbols missing>
25  UIKitCore                          0x00000001ac854d70 <system symbols missing>
26  UIKitCore                          0x00000001ac857478 <system symbols missing>
27  UIKitCore                          0x00000001acebdb50 <system symbols missing>
28  UIKitCore                          0x00000001ac84f22c <system symbols missing>
29  UIKitCore                          0x00000001acebd7f0 <system symbols missing>
30  UIKitCore                          0x00000001acebdcfc <system symbols missing>
31  UnityFramework                     0x00000001060133b8 UnityCleanupTrampoline (UnityAppController.mm:174)
32  UnityFramework                     0x00000001060144d8 -[UnityAppController applicationWillTerminate:] (UnityAppController.mm:498)
33  UIKitCore                          0x00000001ace8a9a4 <system symbols missing>
34  UIKitCore                          0x00000001ac6280d4 <system symbols missing>
35  UIKitCore                          0x00000001ac627d5c <system symbols missing>
36  UIKitCore                          0x00000001ace80b44 <system symbols missing>
37  FrontBoardServices                 0x00000001adf518a0 <system symbols missing>
38  FrontBoardServices                 0x00000001adf7c9bc <system symbols missing>
39  FrontBoardServices                 0x00000001adf62bfc <system symbols missing>
40  FrontBoardServices                 0x00000001adf7c94c <system symbols missing>
41  libdispatch.dylib                  0x00000001a8a97524 <system symbols missing>
42  libdispatch.dylib                  0x00000001a8a40434 <system symbols missing>
43  FrontBoardServices                 0x00000001adfa1850 <system symbols missing>
44  FrontBoardServices                 0x00000001adfa151c <system symbols missing>
45  FrontBoardServices                 0x00000001adfa1a44 <system symbols missing>
46  CoreFoundation                     0x00000001a8d4fad8 <system symbols missing>
47  CoreFoundation                     0x00000001a8d4fa30 <system symbols missing>
48  CoreFoundation                     0x00000001a8d4f1b8 <system symbols missing>
49  CoreFoundation                     0x00000001a8d4a1e8 <system symbols missing>
50  CoreFoundation                     0x00000001a8d49ba8 <system symbols missing>
51  GraphicsServices                   0x00000001b2eb9344 <system symbols missing>
52  UIKitCore                          0x00000001ace853e4 <system symbols missing>
53  UnityFramework                     0x0000000106018a28 -[UnityFramework runUIApplicationMainWithArgc:argv:] (main.mm:96)
54  [APPNAME]                    0x00000001049fbe1c main (main.mm:28)
55  libdyld.dylib                      0x00000001a8bd18f0 <system symbols missing>

same issue here with 2019.4.9f1 and 2019.4.10f1

We temporarily “fixed” this by not calling UnityUseAnimatedAutorotation while terminating:

if (!isTerminating)
[UIView setAnimationsEnabled: UnityUseAnimatedAutorotation() ? YES : NO];

sigh not this again: apple started to do more and more things with views on app shutdown.

We temporarily “fixed” this by not calling UnityUseAnimatedAutorotation while terminating:
this is a perfectly fine fix

can you report a bug (no need to attach project, sure) with all this information so it can be tracked?

Bug reported (although we actually stopped reporting bugs years ago because we always were asked to provide a project for really easy to reproduce bugs or reports were suddenly closed without notice). Lets see this time :wink:

https://fogbugz.unity3d.com/default.asp?1278124_7r5hldelt9nanr35

well this time 1) it is impossible to just reproduce 2) we have all the information 3) you can always say in the bug “alexey told me to do just this” :wink:

anyway: 1198042 is about “Crash on Android plugin CallStatic”, so i assume you meant 1278124 :wink:

Now that sounds good :wink: submitting impossible bugs to reproduce in future only :wink:

Thanks, edited!

In Unity release 2019.4.13f1 the case number 1278124 was mentioned as being fixed.

After updating our project to this unity version, we still receive the same crash (although far less than before):

Native StackTrace:

Thread 0 (crashed)
0   UnityFramework                     0x0000000104dfc808 UnityUseAnimatedAutorotation (TrampolineGlue.mm:46)
1   UnityFramework                     0x000000010401dc94 -[UnityViewControllerBase(iOS) viewWillTransitionToSize:withTransitionCoordinator:] (UnityViewControllerBase+iOS.mm:90)
2   UIKitCore                          0x000000019e122228 <system symbols missing>
3   UIKitCore                          0x000000019e137f78 <system symbols missing>
4   UIKitCore                          0x000000019e797ac0 <system symbols missing>
5   UIKitCore                          0x000000019e797814 <system symbols missing>
6   UIKitCore                          0x000000019e7a3b5c <system symbols missing>
7   UIKitCore                          0x000000019e7999c8 <system symbols missing>
8   UIKitCore                          0x000000019e153f68 <system symbols missing>
9   UIKitCore                          0x000000019ec046f4 <system symbols missing>
10  UIKitCore                          0x000000019e153d5c <system symbols missing>
11  UIKitCore                          0x000000019e153c34 <system symbols missing>
12  UIKitCore                          0x000000019e797118 <system symbols missing>
13  UIKitCore                          0x000000019e7996f4 <system symbols missing>
14  UIKitCore                          0x000000019e799c08 <system symbols missing>
15  UIKitCore                          0x000000019e798fdc <system symbols missing>
16  UIKitCore                          0x000000019e0400b0 <system symbols missing>
17  UIKitCore                          0x000000019e03fdf4 <system symbols missing>
18  UIKitCore                          0x000000019e035aac <system symbols missing>
19  UIKitCore                          0x000000019e1290fc <system symbols missing>
20  UIKitCore                          0x000000019ebff16c <system symbols missing>
21  UIKitCore                          0x000000019e128f78 <system symbols missing>
22  UIKitCore                          0x000000019ebff16c <system symbols missing>
23  UIKitCore                          0x000000019e128c2c <system symbols missing>
24  UIKitCore                          0x000000019e128304 <system symbols missing>
25  UIKitCore                          0x000000019e127d6c <system symbols missing>
26  UIKitCore                          0x000000019e12a474 <system symbols missing>
27  UIKitCore                          0x000000019e790b50 <system symbols missing>
28  UIKitCore                          0x000000019e122228 <system symbols missing>
29  UIKitCore                          0x000000019e7907f0 <system symbols missing>
30  UIKitCore                          0x000000019e790cfc <system symbols missing>
31  UnityFramework                     0x0000000104012818 UnityCleanupTrampoline (UnityAppController.mm:174)
32  UnityFramework                     0x0000000104013938 -[UnityAppController applicationWillTerminate:] (UnityAppController.mm:498)
33  UIKitCore                          0x000000019e75d9a4 <system symbols missing>
34  UIKitCore                          0x000000019defb0d0 <system symbols missing>
35  UIKitCore                          0x000000019defad58 <system symbols missing>
36  UIKitCore                          0x000000019e753b44 <system symbols missing>
37  FrontBoardServices                 0x000000019f8248a0 <system symbols missing>
38  FrontBoardServices                 0x000000019f84f9bc <system symbols missing>
39  FrontBoardServices                 0x000000019f835bfc <system symbols missing>
40  FrontBoardServices                 0x000000019f84f94c <system symbols missing>
41  libdispatch.dylib                  0x000000019a36a524 <system symbols missing>
42  libdispatch.dylib                  0x000000019a313434 <system symbols missing>
43  FrontBoardServices                 0x000000019f874850 <system symbols missing>
44  FrontBoardServices                 0x000000019f87451c <system symbols missing>
45  FrontBoardServices                 0x000000019f874a44 <system symbols missing>
46  CoreFoundation                     0x000000019a622ad8 <system symbols missing>
47  CoreFoundation                     0x000000019a622a30 <system symbols missing>
48  CoreFoundation                     0x000000019a6221b8 <system symbols missing>
49  CoreFoundation                     0x000000019a61d1e8 <system symbols missing>
50  CoreFoundation                     0x000000019a61cba8 <system symbols missing>
51  GraphicsServices                   0x00000001a4793344 <system symbols missing>
52  UIKitCore                          0x000000019e7583e4 <system symbols missing>
53  UnityFramework                     0x0000000104017e88 -[UnityFramework runUIApplicationMainWithArgc:argv:] (main.mm:96)
54  [APPNAME]                    0x0000000102aabe1c main (main.mm:28)
55  libdyld.dylib                      0x000000019a4a48f0 <system symbols missing>

that sounds very weird - it should be in a different place (different line)
and i can confirm the fix should be in 2019.4.13f1

I’m not sure if the fix was applied directly to the affected file, but I’ve compared the UnityViewControllerBase+iOS.mm files of both 2019.4.13f1 and 2019.4.9f1 and there’s no difference in their content…

but I’ve compared the UnityViewControllerBase+iOS.mm files
nono, the fix was in unity library itself

Ended up hitting a very similar issue, in 2019.4.19f1, so far causing 1003 crashes and effecting 817 users.
in my case the app is landscape only but looking at ours logs it happens before or after a ad is viewed by the user. so my assumption is that ad is portrait and causing it to animate into a new orientation.

got my stack trace for it here

Crashed: com.apple.main-thread
0  UnityFramework                 0x1060bf060 UnityMetalFramebufferOnly + 423 (PlayerSettings.h:423)
1  UnityFramework                 0x1060bf060 UnityMetalFramebufferOnly + 423 (PlayerSettings.h:423)
2  UnityFramework                 0x104e3f1e0 -[UnityView recreateRenderingSurface] + 125 (UnityView.mm:125)
3  UnityFramework                 0x104e2e3e4 -[UnityView(iOS) didRotate] + 39 (UnityView+iOS.mm:39)
4  UnityFramework                 0x104e458b4 __83-[UnityViewControllerBase(iOS) viewWillTransitionToSize:withTransitionCoordinator:]_block_invoke + 110 (UnityViewControllerBase+iOS.mm:110)
5  UIKitCore                      0x19916c410 -[_UIViewControllerTransitionCoordinator _applyBlocks:releaseBlocks:] + 264
6  UIKitCore                      0x199168cb4 -[_UIViewControllerTransitionContext _runAlongsideCompletions] + 132
7  UIKitCore                      0x1991689e0 -[_UIViewControllerTransitionContext completeTransition:] + 116
8  UIKitCore                      0x1991848dc -[_UIWindowAnimationController animateTransition:] + 348
9  UIKitCore                      0x199847338 -[UIWindow _adjustSizeClassesAndResizeWindowToFrame:] + 764
10 UIKitCore                      0x199853438 -[UIWindow _resizeWindowFrameToSceneBoundsIfNecessary] + 280
11 UIKitCore                      0x199849760 __78-[UIWindow _rotateWindowToOrientation:updateStatusBar:duration:skipCallbacks:]_block_invoke + 388
12 UIKitCore                      0x199184f30 __58-[_UIWindowRotationAnimationController animateTransition:]_block_invoke_2 + 172
13 UIKitCore                      0x199d03a58 +[UIView _performBlockDelayingTriggeringResponderEvents:forScene:] + 244
14 UIKitCore                      0x199184d24 __58-[_UIWindowRotationAnimationController animateTransition:]_block_invoke + 156
15 UIKitCore                      0x199184c04 -[_UIWindowRotationAnimationController animateTransition:] + 492
16 UIKitCore                      0x199846c84 -[UIWindow _rotateToBounds:withAnimator:transitionContext:] + 580
17 UIKitCore                      0x19984948c -[UIWindow _rotateWindowToOrientation:updateStatusBar:duration:skipCallbacks:] + 1416
18 UIKitCore                      0x199849988 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:isRotating:] + 384
19 UIKitCore                      0x199848db0 -[UIWindow _setRotatableViewOrientation:updateStatusBar:duration:force:] + 108
20 UIKitCore                      0x19903a6c4 -[_UIFullscreenPresentationController _placeCounterRotationViewWithView:inWindow:fromOrientation:toOrientation:force:] + 504
21 UIKitCore                      0x19903a408 -[_UIFullscreenPresentationController _adjustOrientationIfNecessaryInWindow:forViewController:preservingViewController:] + 832
22 UIKitCore                      0x199030010 -[UIPresentationController _dismissWithAnimationController:interactionController:target:didEndSelector:] + 564
23 UIKitCore                      0x199155880 __99-[UIViewController _dismissViewControllerWithAnimationController:interactionController:completion:]_block_invoke_2 + 72
24 UIKitCore                      0x199cfe704 +[UIView(Animation) performWithoutAnimation:] + 96
25 UIKitCore                      0x1991556b8 -[UIViewController _dismissViewControllerWithAnimationController:interactionController:completion:] + 596
26 UIKitCore                      0x199cfe704 +[UIView(Animation) performWithoutAnimation:] + 96
27 UIKitCore                      0x199154b08 -[UIViewController _dismissViewControllerWithTransition:from:completion:] + 1644
28 UIKitCore                      0x19915447c __67-[UIViewController dismissViewControllerWithTransition:completion:]_block_invoke.1808 + 84
29 UIKitCore                      0x19914d6b8 +[UIViewController _performWithoutDeferringTransitionsAllowingAnimation:actions:] + 156
30 UIKitCore                      0x199153e40 -[UIViewController dismissViewControllerWithTransition:completion:] + 1744
31 UIKitCore                      0x199153550 -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 504
32 UIKitCore                      0x199156140 -[UIViewController dismissViewControllerAnimated:completion:] + 124
33 UIKitCore                      0x1998403a8 __68-[UIWindow _removeAllViewControllersFromWindowHierarchyFromDealloc:]_block_invoke + 60
34 UIKitCore                      0x19914d6b8 +[UIViewController _performWithoutDeferringTransitionsAllowingAnimation:actions:] + 156
35 UIKitCore                      0x19984004c -[UIWindow _removeAllViewControllersFromWindowHierarchyFromDealloc:] + 276
36 UIKitCore                      0x199840554 -[UIWindow setRootViewController:] + 284
37 UnityFramework                 0x104e3a58c UnityCleanupTrampoline + 174 (UnityAppController.mm:174)
38 UnityFramework                 0x104e3b664 -[UnityAppController applicationWillTerminate:] + 498 (UnityAppController.mm:498)
39 UIKitCore                      0x19980c7fc -[UIApplication _terminateWithStatus:] + 240
40 UIKitCore                      0x198eda810 -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:] + 124
41 UIKitCore                      0x198eda494 -[_UISceneLifecycleMultiplexer forceExitWithTransitionContext:scene:] + 216
42 UIKitCore                      0x1998027f8 -[UIApplication workspaceShouldExit:withTransitionContext:] + 208
43 FrontBoardServices             0x1a62bcf04 -[FBSUIApplicationWorkspaceShim workspaceShouldExit:withTransitionContext:] + 84
44 FrontBoardServices             0x1a62e7874 __63-[FBSWorkspaceScenesClient willTerminateWithTransitionContext:]_block_invoke_2 + 76
45 FrontBoardServices             0x1a62cde60 -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 232
46 FrontBoardServices             0x1a62e7810 __63-[FBSWorkspaceScenesClient willTerminateWithTransitionContext:]_block_invoke + 104
47 libdispatch.dylib              0x196bcf280 _dispatch_client_callout + 16
48 libdispatch.dylib              0x196ba8190 _dispatch_block_invoke_direct$VARIANT$armv81 + 216
49 FrontBoardServices             0x1a630ce60 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 40
50 FrontBoardServices             0x1a630cb28 -[FBSSerialQueue _targetQueue_performNextIfPossible] + 404
51 FrontBoardServices             0x1a630cffc -[FBSSerialQueue _performNextFromRunLoopSource] + 28
52 CoreFoundation                 0x196f16bf0 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
53 CoreFoundation                 0x196f16af0 __CFRunLoopDoSource0 + 204
54 CoreFoundation                 0x196f15e38 __CFRunLoopDoSources0 + 256
55 CoreFoundation                 0x196f103e0 __CFRunLoopRun + 776
56 CoreFoundation                 0x196f0fba0 CFRunLoopRunSpecific + 572
57 GraphicsServices               0x1adc78598 GSEventRunModal + 160
58 UIKitCore                      0x1998012f4 -[UIApplication _run] + 1052
59 UIKitCore                      0x199806874 UIApplicationMain + 164
60 UnityFramework                 0x104e3fa78 -[UnityFramework runUIApplicationMainWithArgc:argv:] + 96 (main.mm:96)
61 vf3                            0x102867d54 main + 28 (main.mm:28)
6