firebase / quickstart-unity

Firebase Quickstart Samples for Unity
https://firebase.google.com/games
Apache License 2.0
825 stars 428 forks source link

iOS crashes for 25% of users. (Android is fine) #610

Closed unnanego closed 4 years ago

unnanego commented 4 years ago

Approximately 25% of all my apps users (both this one and I'm guessing I had the same problem with my previous app from last summer, but crashlytics doesn't go that far) experience crashes on iOS only (this is a unity project, Android has no crashes at all). Crashlytics gives me the following stack trace and some of the crashes have this key: CoreUI: deallocating _CUIInternalLinkRendition 205 /System/Library/CoreServices/CoreGlyphs.bundle/Assets.car

Here's the stacktrace from Crashlytics: 0 UnityFramework UnityAdsEngineSetDidFinishCallback + 27372 1 UnityFramework Firebase_App_FutureVoid_SWIGUpcast + 14940256

full: https://pastebin.com/f5vYT5WB

Unity 2019.3.3 Latest xcode and iOS versions. Unity Firebase SDK 6.11.0

I can't reproduce the error on any of my devices.

google-oss-bot commented 4 years ago

I found a few problems with this issue:

unnanego commented 4 years ago

There's a topic on stackoverflow https://stackoverflow.com/questions/59717173/crash-info-entry-0-coreui-deallocating-cuiinternallinkrendition-assets-ca but it has no answer

google-oss-bot commented 4 years ago

This issue does not seem to follow the issue template. Make sure you provide all the required information.

a-maurice commented 4 years ago

Hi @unnanego,

Without a reproducible case, unfortunately not sure what this issue might be, as we haven't seen anything similar. My best guess would be that maybe your FirebaseApp is being garbage collected, if you aren't holding a reference to it. If you can, please try to track down a case that can reproduce this.

google-oss-bot commented 4 years ago

Hey @unnanego. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot commented 4 years ago

Hey @unnanego. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot commented 4 years ago

Since there haven't been any recent updates here, I am going to close this issue.

@unnanego if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.

VGMFR commented 4 years ago

We have exactly the same issue. iOS only, Unity 2019.3, last Firebase SDK. Did you solve the issue @unnanego? Right now it still is quite a mystery to us...

patm1987 commented 4 years ago

Hi VGMFR/unnanego,

I'm re-opening since there has been some additional follow up. We really really need repro steps if we're going to help solve this issue. I know that not being able to repro on your own devices is going to make this more challenging too.

Some things to help, make sure all of these fields from the template are filled in (I know this came over from another github repo, so I apologize for asking this after the fact)

Unity editor version: 2019.3.3 Firebase Unity SDK version: 6.11.0 Source you installed the SDK (.unitypackage or Unity Package Manager): Firebase plugins in use (Auth, Database, etc.): Additional SDKs you are using (Facebook, AdMob, etc.): Platform you are using the Unity editor on (Mac, Windows, or Linux): Platform you are targeting (iOS, Android, and/or desktop): Scripting Runtime (Mono, and/or IL2CPP):

I can also say that one of the first debugging steps will be to have you upgrade to the latest SDK version - which is currently 6.13.0.

For reproduction, we prefer if at all possible you can reproduce on the quickstart (here's the Crashlytics one, since that's the SDK you mention currently).

Without seeing your code and without solid repro steps, it's hard to say exactly what's happening (and therefore to get any sort of fix in). I do notice that there are some Unity Ads callbacks in the callstack. It might be worth auditing scripts where you call Show with a finishCallback and see if there's any way that that may be triggered after that script or the game has been torn down. I don't know the best practices around that API, but it might be as simple as checking if this is not null in your callback methods (given Unity's object model).

I hope that helps!

--Patrick

VGMFR commented 4 years ago

Hi Patrick,

Thanks for reopening this. We still can't reproduce this issue on our side, even if I am struggling with it since last Thursday. Here is the information that I can give you:

Unity editor version: 2019.3.6f1 Firebase Unity SDK version: 6.13.0 Source you installed the SDK: Unity Package Manager Firebase plugins in use: Crashlytics & Analytics Additional SDKs you are using: Facebook, Ogury, Appsflyer for the biggest ones Platform you are using the Unity editor on: Mac Platform you are targeting: iOS and Android. As said, Android works flawlessly, this problem only occurs on iOS. Scripting Runtime : IL2CPP, .Net 4.x

Hope it helps! I'll come back if I get more info.

0x61726b commented 4 years ago

Hello, this is the first search result on google when you search UnityAdsEngineSetDidFinishCallback and I'm not sure if the crash is somehow related to Firebase but I'm writing my findings about this issue. Firstly:

Unity editor version: 2019.3.7 2019.3.8 2019.3.9 (happens on all of them) AND 2018.4.5 Firebase Unity SDK version: 6.13.0 Source you installed the SDK: .unitypackage Firebase plugins in use: Crashlytics, Analytics, RemoteConfig, CloudMessaging Additional SDKs you are using: MoPub (latest, 5.12), Facebook, AdMob and a lot of ad network SDKs Platform you are using the Unity editor on: Mac Platform you are targeting: iOS Scripting Runtime: il2cpp, .net 4.x

So we have about 110k crashes on Crashlytics and 100% are background and iOS 13. There are several crashes that all have similar call stacks. They all have [UIApplication _terminateWithStatus:] or UnityAdsEngineSetDidFinishCallback. So it somehow crashes when you force-kill the app by swiping the home button/bar then swiping the app up to kill. Then a crash popup appears saying the app crashed.

At first we thought that this is a 2019.3 crash but then we got the same behaviour crash (force-kill) on Unity 2018.4.5, that led me to think that this isnt a Unity version thing and some SDKs are at fault. Weird thing is that we have another game with Unity 2019.2.14 and with same version SDKs and these crashes dont happen there.

When we force-kill the app as described above while watching an ad, it crashes like %80 of the time. Note that which ad network is showing the ad does not matter, I've had the crash happen on Facebook, AdMob, Unity etc so this makes me think that it could be MoPub related.

Currently I have no reason to believe that this crash is related to Firebase. I'll post updates if I find anything else.

Here are some stack traces from 2 different apps on iOS:

Crashed: com.apple.main-thread
0  UnityFramework                 0x105822954 MetalHeap::AliasResources() + 76544
1  UnityFramework                 0x1046d2478 UnityAdsEngineSetDidFinishCallback + 29352
2  UnityFramework                 0x1046c76cc (Missing)
3  UIKitCore                      0x18f1a4140 -[UIApplication _supportedInterfaceOrientationsForWindow:] + 108
4  UIKitCore                      0x18eb9fa64 -[UIViewController __supportedInterfaceOrientations] + 256
5  UIKitCore                      0x18eb91028 -[UIViewController _preferredInterfaceOrientationGivenStatusBarAndDeviceAndOrientation:] + 104
6  UIKitCore                      0x18eb9f680 -[UIViewController _preferredInterfaceOrientationForPresentationInWindow:fromInterfaceOrientation:] + 544
7  UIKitCore                      0x18eab01c8 -[_UIFullscreenPresentationController _adjustOrientationIfNecessaryInWindow:forViewController:preservingViewController:] + 576
8  UIKitCore                      0x18eaa5eb8 -[UIPresentationController _dismissWithAnimationController:interactionController:target:didEndSelector:] + 684
9  UIKitCore                      0x18eb9a01c __99-[UIViewController _dismissViewControllerWithAnimationController:interactionController:completion:]_block_invoke_2 + 72
10 UIKitCore                      0x18f628c14 +[UIView(Animation) performWithoutAnimation:] + 96
11 UIKitCore                      0x18eb99e98 -[UIViewController _dismissViewControllerWithAnimationController:interactionController:completion:] + 580
12 UIKitCore                      0x18f628c14 +[UIView(Animation) performWithoutAnimation:] + 96
13 UIKitCore                      0x18eb99b4c -[UIViewController _dismissViewControllerWithTransition:from:completion:] + 816
14 UIKitCore                      0x18eb99228 -[UIViewController dismissViewControllerWithTransition:completion:] + 1200
15 UIKitCore                      0x18eb98c90 -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 508
16 UIKitCore                      0x18eb9b3a0 -[UIViewController dismissViewControllerAnimated:completion:] + 132
17 UIKitCore                      0x18f1d828c __68-[UIWindow _removeAllViewControllersFromWindowHierarchyFromDealloc:]_block_invoke + 60
18 UIKitCore                      0x18eb93154 +[UIViewController _performWithoutDeferringTransitionsAllowingAnimation:actions:] + 168
19 UIKitCore                      0x18f1d7f1c -[UIWindow _removeAllViewControllersFromWindowHierarchyFromDealloc:] + 288
20 UIKitCore                      0x18f1d8438 -[UIWindow setRootViewController:] + 284
21 UnityFramework                 0x1046c75b0 (Missing)
22 UnityFramework                 0x1046c8364 (Missing)
23 UIKitCore                      0x18f1a5ae0 -[UIApplication _terminateWithStatus:] + 244
24 UIKitCore                      0x18e96b8b8 -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:] + 124
25 UIKitCore                      0x18e96b538 -[_UISceneLifecycleMultiplexer forceExitWithTransitionContext:scene:] + 216
26 UIKitCore                      0x18f19be80 -[UIApplication workspaceShouldExit:withTransitionContext:] + 212
27 FrontBoardServices             0x19024690c -[FBSUIApplicationWorkspaceShim workspaceShouldExit:withTransitionContext:] + 84
28 FrontBoardServices             0x19027205c __83-[FBSWorkspaceScenesClient willTerminateWithTransitionContext:withAcknowledgement:]_block_invoke_2 + 76
29 FrontBoardServices             0x190257f04 -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 232
30 FrontBoardServices             0x190271fec __83-[FBSWorkspaceScenesClient willTerminateWithTransitionContext:withAcknowledgement:]_block_invoke + 124
31 libdispatch.dylib              0x18ade7184 _dispatch_client_callout + 16
32 libdispatch.dylib              0x18adc1420 _dispatch_block_invoke_direct$VARIANT$armv81 + 216
33 FrontBoardServices             0x190297418 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 40
34 FrontBoardServices             0x1902970e4 -[FBSSerialQueue _queue_performNextIfPossible] + 404
35 FrontBoardServices             0x19029760c -[FBSSerialQueue _performNextFromRunLoopSource] + 28
36 CoreFoundation                 0x18b098a00 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
37 CoreFoundation                 0x18b098958 __CFRunLoopDoSource0 + 80
38 CoreFoundation                 0x18b098140 __CFRunLoopDoSources0 + 260
39 CoreFoundation                 0x18b09323c __CFRunLoopRun + 1080
40 CoreFoundation                 0x18b092adc CFRunLoopRunSpecific + 464
41 GraphicsServices               0x195033328 GSEventRunModal + 104
42 UIKitCore                      0x18f1a063c UIApplicationMain + 1936
43 UnityFramework                 0x1046cc910 UnityAdsEngineSetDidFinishCallback + 5952
44 appNameHere                       0x104297e1c main + 28 (main.mm:28)
45 libdyld.dylib                  0x18af1c360 start + 4

another app:

Crashed: com.apple.main-thread
0  UnityFramework                 0x103c79888 operator delete[](void*, std::nothrow_t const&) + 79792
1  UnityFramework                 0x103c7431c operator delete[](void*, std::nothrow_t const&) + 57924
2  UnityFramework                 0x103c742a4 operator delete[](void*, std::nothrow_t const&) + 57804
3  UnityFramework                 0x103dc1134 operator delete[](void*, std::nothrow_t const&) + 1421404
4  UnityFramework                 0x104085e5c MetalHeap::AliasResources() + 75372
5  UnityFramework                 0x1031e5878 _moPubPreviouslyConsentedVendorListVersion + 10160
6  UnityFramework                 0x10327c7a4 MPInterstitialOrientationTypeToUIInterfaceOrientationMask + 24060
7  UnityFramework                 0x10327e8c4 MPInterstitialOrientationTypeToUIInterfaceOrientationMask + 32540
8  UnityFramework                 0x10327fa58 MPInterstitialOrientationTypeToUIInterfaceOrientationMask + 37040
9  UnityFramework                 0x1031c655c GetGULSwizzlingQueue + 49776
10 UnityFramework                 0x10339b260 pb_encode_string + 783500
11 UnityFramework                 0x10339b180 pb_encode_string + 783276
12 UnityFramework                 0x1032de924 pb_encode_string + 11088
13 UnityFramework                 0x1032ed094 pb_encode_string + 70336
14 UIKitCore                      0x1b4127720 -[UIViewController _setViewAppearState:isAnimating:] + 928
15 UIKitCore                      0x1b4127ef8 -[UIViewController __viewWillDisappear:] + 96
16 UIKitCore                      0x1b4044d10 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke.465 + 1032
17 UIKitCore                      0x1b404aa2c +[UIPresentationController _scheduleTransition:] + 96
18 UIKitCore                      0x1b4044680 -[UIPresentationController runTransitionForCurrentState] + 1688
19 UIKitCore                      0x1b4041ef0 -[UIPresentationController _dismissWithAnimationController:interactionController:target:didEndSelector:] + 740
20 UIKitCore                      0x1b413601c __99-[UIViewController _dismissViewControllerWithAnimationController:interactionController:completion:]_block_invoke_2 + 72
21 UIKitCore                      0x1b4bc4c14 +[UIView(Animation) performWithoutAnimation:] + 96
22 UIKitCore                      0x1b4135e98 -[UIViewController _dismissViewControllerWithAnimationController:interactionController:completion:] + 580
23 UIKitCore                      0x1b4bc4c14 +[UIView(Animation) performWithoutAnimation:] + 96
24 UIKitCore                      0x1b4135b4c -[UIViewController _dismissViewControllerWithTransition:from:completion:] + 816
25 UIKitCore                      0x1b4135228 -[UIViewController dismissViewControllerWithTransition:completion:] + 1200
26 UIKitCore                      0x1b4134c90 -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 508
27 UIKitCore                      0x1b41373a0 -[UIViewController dismissViewControllerAnimated:completion:] + 132
28 UIKitCore                      0x1b477428c __68-[UIWindow _removeAllViewControllersFromWindowHierarchyFromDealloc:]_block_invoke + 60
29 UIKitCore                      0x1b412f154 +[UIViewController _performWithoutDeferringTransitionsAllowingAnimation:actions:] + 168
30 UIKitCore                      0x1b4773f1c -[UIWindow _removeAllViewControllersFromWindowHierarchyFromDealloc:] + 288
31 UIKitCore                      0x1b4774438 -[UIWindow setRootViewController:] + 284
32 UnityFramework                 0x102f84f08 (Missing)
33 UnityFramework                 0x102f85cb8 (Missing)
34 UIKitCore                      0x1b4741ae0 -[UIApplication _terminateWithStatus:] + 244
35 UIKitCore                      0x1b3f078b8 -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:] + 124
36 UIKitCore                      0x1b3f07538 -[_UISceneLifecycleMultiplexer forceExitWithTransitionContext:scene:] + 216
37 UIKitCore                      0x1b4737e80 -[UIApplication workspaceShouldExit:withTransitionContext:] + 212
38 FrontBoardServices             0x1b57e290c -[FBSUIApplicationWorkspaceShim workspaceShouldExit:withTransitionContext:] + 84
39 FrontBoardServices             0x1b580e05c __83-[FBSWorkspaceScenesClient willTerminateWithTransitionContext:withAcknowledgement:]_block_invoke_2 + 76
40 FrontBoardServices             0x1b57f3f04 -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 232
41 FrontBoardServices             0x1b580dfec __83-[FBSWorkspaceScenesClient willTerminateWithTransitionContext:withAcknowledgement:]_block_invoke + 124
42 libdispatch.dylib              0x1b0383184 _dispatch_client_callout + 16
43 libdispatch.dylib              0x1b035d420 _dispatch_block_invoke_direct$VARIANT$armv81 + 216
44 FrontBoardServices             0x1b5833418 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 40
45 FrontBoardServices             0x1b58330e4 -[FBSSerialQueue _queue_performNextIfPossible] + 404
46 FrontBoardServices             0x1b583360c -[FBSSerialQueue _performNextFromRunLoopSource] + 28
47 CoreFoundation                 0x1b0634a00 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
48 CoreFoundation                 0x1b0634958 __CFRunLoopDoSource0 + 80
49 CoreFoundation                 0x1b06340f0 __CFRunLoopDoSources0 + 180
50 CoreFoundation                 0x1b062f23c __CFRunLoopRun + 1080
51 CoreFoundation                 0x1b062eadc CFRunLoopRunSpecific + 464
52 GraphicsServices               0x1ba5cf328 GSEventRunModal + 104
53 UIKitCore                      0x1b473c63c UIApplicationMain + 1936
54 UnityFramework                 0x102f8a268 UnityAdsEngineSetDidFinishCallback + 5948
55 otherAppnameHere                        0x102d5fe1c main + 28 (main.mm:28)
56 libdyld.dylib                  0x1b04b8360 start + 4
Crashed: com.apple.main-thread
0  UnityFramework                 0x1051ccf58 TypeManager::FindAllRTTIDerivedTypes(RTTI const*, dynamic_array<RTTI const*, 0ul>&, bool) const + 68 (TypeManager.cpp:68)
1  UnityFramework                 0x1051c79ec FindInstanceIDsOfTypeImplementation(core::hash_set<Object*, core::hash<Object*>, std::__1::equal_to<Object*> >*, Unity::Type const*, dynamic_array<int, 0ul>&) + 566 (dynamic_array.h:566)
2  UnityFramework                 0x1051c7974 Object::FindInstanceIDsOfType(Unity::Type const*, dynamic_array<int, 0ul>&, bool) + 719 (BaseObject.cpp:719)
3  UnityFramework                 0x105314d30 SendMessageToEveryone(MessageIdentifier const&, MessageData) + 566 (dynamic_array.h:566)
4  UnityFramework                 0x1055f3910 UnityPause + 348 (LibEntryPoint.mm:348)
5  UnityFramework                 0x104737428 -[MoPubManager interstitialWillDisappear:] + 491 (MoPubManager.mm:491)
6  UnityFramework                 0x1047cee14 -[MPInterstitialAdController managerWillDismissInterstitial:] + 155 (MPInterstitialAdController.m:155)
7  UnityFramework                 0x1047d0f4c -[MPInterstitialAdManager interstitialWillDisappearForAdapter:] + 264 (MPInterstitialAdManager.m:264)
8  UnityFramework                 0x1047d20f4 -[MPInterstitialCustomEventAdapter interstitialCustomEventWillDisappear:] + 137 (MPInterstitialCustomEventAdapter.m:137)
9  UnityFramework                 0x104717da8 -[AppLovinInterstitialCustomEvent ad:wasHiddenIn:] + 218 (AppLovinInterstitialCustomEvent.m:218)
10 UnityFramework                 0x1048ee4b8 __68+[ALDelegateCallbackInvoker invokeAdDisplayDelegate:ad:wasHiddenIn:]_block_invoke + 62 (ALDelegateCallbackInvoker.m:62)
11 UnityFramework                 0x1048ee3d8 +[ALDelegateCallbackInvoker invokeAdDisplayDelegate:ad:wasHiddenIn:] + 154 (ALCommonMacros.h:154)
12 UnityFramework                 0x104831b7c -[ALDelegateCallbackUnrepeatableInvoker handleAd:wasHiddenIn:] + 64 (ALDelegateCallbackUnrepeatableInvoker.m:64)
13 UnityFramework                 0x1048402ec -[ALBaseVideoViewController viewWillDisappear:] + 303 (ALBaseVideoViewController.m:303)
14 UIKitCore                      0x1b9eb271c -[UIViewController _setViewAppearState:isAnimating:] + 972
15 UIKitCore                      0x1b9eb2f18 -[UIViewController __viewWillDisappear:] + 100
16 UIKitCore                      0x1b9dca440 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke.478 + 1012
17 UIKitCore                      0x1b9dd032c +[UIPresentationController _scheduleTransition:] + 104
18 UIKitCore                      0x1b9dc9dd0 -[UIPresentationController runTransitionForCurrentState] + 1712
19 UIKitCore                      0x1b9dc75e4 -[UIPresentationController _dismissWithAnimationController:interactionController:target:didEndSelector:] + 708
20 UIKitCore                      0x1b9ec16a4 __99-[UIViewController _dismissViewControllerWithAnimationController:interactionController:completion:]_block_invoke_2 + 76
21 UIKitCore                      0x1ba996d54 +[UIView(Animation) performWithoutAnimation:] + 104
22 UIKitCore                      0x1b9ec14f8 -[UIViewController _dismissViewControllerWithAnimationController:interactionController:completion:] + 608
23 UIKitCore                      0x1ba996d54 +[UIView(Animation) performWithoutAnimation:] + 104
24 UIKitCore                      0x1b9ec118c -[UIViewController _dismissViewControllerWithTransition:from:completion:] + 832
25 UIKitCore                      0x1b9ec084c -[UIViewController dismissViewControllerWithTransition:completion:] + 1236
26 UIKitCore                      0x1b9ec0270 -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 528
27 UIKitCore                      0x1b9ec2af0 -[UIViewController dismissViewControllerAnimated:completion:] + 148
28 UIKitCore                      0x1ba52a9f8 __68-[UIWindow _removeAllViewControllersFromWindowHierarchyFromDealloc:]_block_invoke + 64
29 UIKitCore                      0x1b9eba500 +[UIViewController _performWithoutDeferringTransitionsAllowingAnimation:actions:] + 176
30 UIKitCore                      0x1ba52a678 -[UIWindow _removeAllViewControllersFromWindowHierarchyFromDealloc:] + 304
31 UIKitCore                      0x1ba52abb4 -[UIWindow setRootViewController:] + 288
32 UnityFramework                 0x1044d2070 UnityCleanupTrampoline + 168 (UnityAppController.mm:168)
33 UnityFramework                 0x1044d2e24 -[UnityAppController applicationWillTerminate:] + 468 (UnityAppController.mm:468)
34 UIKitCore                      0x1ba4f6bc0 -[UIApplication _terminateWithStatus:] + 248
35 UIKitCore                      0x1b9c882d0 -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:] + 128
36 UIKitCore                      0x1b9c87f2c -[_UISceneLifecycleMultiplexer forceExitWithTransitionContext:scene:] + 220
37 UIKitCore                      0x1ba4ecdd4 -[UIApplication workspaceShouldExit:withTransitionContext:] + 216
38 FrontBoardServices             0x1bb5de98c -[FBSUIApplicationWorkspaceShim workspaceShouldExit:withTransitionContext:] + 88
39 FrontBoardServices             0x1bb60c264 __83-[FBSWorkspaceScenesClient willTerminateWithTransitionContext:withAcknowledgement:]_block_invoke_2 + 80
40 FrontBoardServices             0x1bb5f0ef4 -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 240
41 FrontBoardServices             0x1bb60c1f0 __83-[FBSWorkspaceScenesClient willTerminateWithTransitionContext:withAcknowledgement:]_block_invoke + 140
42 libdispatch.dylib              0x1b6095fd8 _dispatch_client_callout + 20
43 libdispatch.dylib              0x1b6098d1c _dispatch_block_invoke_direct + 264
44 FrontBoardServices             0x1bb633254 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 48
45 FrontBoardServices             0x1bb632f00 -[FBSSerialQueue _queue_performNextIfPossible] + 432
46 FrontBoardServices             0x1bb63346c -[FBSSerialQueue _performNextFromRunLoopSource] + 32
47 CoreFoundation                 0x1b636c108 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28
48 CoreFoundation                 0x1b636c05c __CFRunLoopDoSource0 + 84
49 CoreFoundation                 0x1b636b7c8 __CFRunLoopDoSources0 + 184
50 CoreFoundation                 0x1b6366694 __CFRunLoopRun + 1068
51 CoreFoundation                 0x1b6365f40 CFRunLoopRunSpecific + 480
52 GraphicsServices               0x1c05f6534 GSEventRunModal + 108
53 UIKitCore                      0x1ba4f1580 UIApplicationMain + 1940
54 UnityFramework                 0x1044d74b0 -[UnityFramework runUIApplicationMainWithArgc:argv:] + 96 (main.mm:96)
55 anotherAnotherApp                        0x1042c3e1c main + 28 (main.mm:28)
56 libdyld.dylib                  0x1b61e4e18 start + 4
VGMFR commented 4 years ago

@arkenthera Thanks for investigation this issue too. Turns out that we have the same issue (with 100% background) that you have. But I also have a crash that seems to be on launch with a different stacktrace and that seems to be related somehow:

Fatal Exception: NSInvalidArgumentException
0  CoreFoundation                 0x1b05c6a48 __exceptionPreprocess
1  libobjc.A.dylib                0x1b02edfa4 objc_exception_throw
2  CoreFoundation                 0x1b061c360 -[__NSCFString characterAtIndex:].cold.1
3  CoreFoundation                 0x1b06256b4 -[__NSPlaceholderDictionary initWithObjects:forKeys:count:].cold.5
4  CoreFoundation                 0x1b04b373c -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]
5  CoreFoundation                 0x1b04a55d0 +[NSDictionary dictionaryWithObjects:forKeys:count:]
6  UnityFramework                 0x104998e54 (Manquant)
7  UnityFramework                 0x104989f20 (Manquant)
8  UnityFramework                 0x104988f80 (Manquant)
9  UnityFramework                 0x10498a0a4 (Manquant)
10 UnityFramework                 0x1067b9514 (Manquant)
11 UnityFramework                 0x1067cdd74 (Manquant)
12 UnityFramework                 0x1067ce6f0 (Manquant)
13 UnityFramework                 0x1067ce4c4 (Manquant)
14 UnityFramework                 0x1048e557c (Manquant)
15 UnityFramework                 0x105696810 (Manquant)
16 UnityFramework                 0x105030f78 (Manquant)
17 UnityFramework                 0x10503bcb8 (Manquant)
18 UnityFramework                 0x105048b70 (Manquant)
19 UnityFramework                 0x105048df0 (Manquant)
20 UnityFramework                 0x105047774 (Manquant)
21 UnityFramework                 0x104e9a3a0 (Manquant)
22 UnityFramework                 0x104f70f1c (Manquant)
23 UnityFramework                 0x104f70f50 (Manquant)
24 UnityFramework                 0x104f711a8 (Manquant)
25 UnityFramework                 0x10525ad70 (Manquant)
26 UnityFramework                 0x10481a350 (Manquant)
27 UnityFramework                 0x10481a22c (Manquant)
28 QuartzCore                     0x1b6f0b130 CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long)
29 QuartzCore                     0x1b6fd5000 display_timer_callback(__CFMachPort*, void*, long, void*)
30 CoreFoundation                 0x1b051b8ac __CFMachPortPerform
31 CoreFoundation                 0x1b054507c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__
32 CoreFoundation                 0x1b05447a8 __CFRunLoopDoSource1
33 CoreFoundation                 0x1b053f67c __CFRunLoopRun
34 CoreFoundation                 0x1b053eadc CFRunLoopRunSpecific
35 GraphicsServices               0x1ba4df328 GSEventRunModal
36 UIKitCore                      0x1b464c63c UIApplicationMain
37 UnityFramework                 0x104818ce8 (Manquant)
38 AirlinesManager2               0x102d6be1c main + 28 (main.mm:28)
39 libdyld.dylib                  0x1b03c8360 start
Crashed: com.twitter.crashlytics.ios.exception
0  UnityFramework                 0x104a9df38 CLSProcessRecordAllThreads + 180
1  UnityFramework                 0x104a9df38 CLSProcessRecordAllThreads + 180
2  UnityFramework                 0x104a9e320 CLSProcessRecordAllThreads + 1180
3  UnityFramework                 0x104a8d31c CLSHandler + 48
4  UnityFramework                 0x104a9c340 CLSExceptionWrite(CLSFile*, CLSExceptionType, char const*, char const*, NSArray*) + 1200
5  libdispatch.dylib              0x1b0293184 _dispatch_client_callout + 16
6  libdispatch.dylib              0x1b0276dc8 _dispatch_lane_barrier_sync_invoke_and_complete + 56
7  UnityFramework                 0x104a9bdac CLSExceptionRecord + 216
8  UnityFramework                 0x104a9bbd8 CLSExceptionRecordNSException + 572
9  UnityFramework                 0x104a9b7cc CLSExceptionInitialize + 528
10 libc++abi.dylib                0x1b0393304 std::__terminate(void (*)()) + 16
11 libc++abi.dylib                0x1b0392ed8 __cxa_rethrow + 144
12 libobjc.A.dylib                0x1b02ee158 objc_exception_rethrow + 40
13 CoreFoundation                 0x1b053eb4c CFRunLoopRunSpecific + 576
14 GraphicsServices               0x1ba4df328 GSEventRunModal + 104
15 UIKitCore                      0x1b464c63c UIApplicationMain + 1936
16 UnityFramework                 0x104818ce8 UnityAdsEngineSetDidFinishCallback + 5952
17 AirlinesManager2               0x102d6be1c main + 28 (main.mm:28)
18 libdyld.dylib                  0x1b03c8360 start + 4
L4fter commented 4 years ago

@unnanego @arkenthera @VGMFR I've been struggling to find the cause of the similar crash for couple of days now. This thread is almost everything you can find at all. So maybe my findings would be helpful to you guys.

The crash stack trace symbolycation is "corrupted" because firebase lacks symbols to process the addresses. If you look closely at symbolicated output you'll notice the offsets from base function addresses are huge (MetalHeap::AliasResources() + 76544 or _operator delete[](void*, std::nothrowt const&) + 1421404) which makes no sense at all: no function is that large. Probably firebase tries its best to symbolicate the addresses with not much luck. I checked on crashlytics page and yes, some symbols are missing for the build (marked as Optional for some reason).

The reason for that is Unity changed the way xcode projects are structured starting from 19.3. It now separates the application from unityframework, and when built they produce separate dSYM files. Firebase only upload one of them: I believe this is a bug in Unity Firebase Crashlytics implementation. So when I uploaded symbols manually, new strack traces of the same bug started to look more to the point, from the

1  UnityFramework                 0x102a97f58 MetalHeap::AliasResources() + 93488
2  UnityFramework                 0x101820620 UnityAdsEngineSetDidFinishCallback + 30760
3  UIKitCore                      0x1ac587ba0 -[UIViewController __supportedInterfaceOrientations] + 572
4  UIKitCore                      0x1ac579028 -[UIViewController _preferredInterfaceOrientationGivenStatusBarAndDeviceAndOrientation:] + 104
5  UIKitCore                      0x1ac587680 -[UIViewController _preferredInterfaceOrientationForPresentationInWindow:fromInterfaceOrientation:] + 544
6  UIKitCore                      0x1ac4981c8 -[_UIFullscreenPresentationController _adjustOrientationIfNecessaryInWindow:forViewController:preservingViewController:] + 576
7  UIKitCore                      0x1ac48deb8 -[UIPresentationController _dismissWithAnimationController:interactionController:target:didEndSelector:] + 684
8  UIKitCore                      0x1ac58201c __99-[UIViewController _dismissViewControllerWithAnimationController:interactionController:completion:]_block_invoke_2 + 72
9  UIKitCore                      0x1ad010c14 +[UIView(Animation) performWithoutAnimation:] + 96
10 UIKitCore                      0x1ac581e98 -[UIViewController _dismissViewControllerWithAnimationController:interactionController:completion:] + 580
11 UIKitCore                      0x1ad010c14 +[UIView(Animation) performWithoutAnimation:] + 96
12 UIKitCore                      0x1ac581b4c -[UIViewController _dismissViewControllerWithTransition:from:completion:] + 816
13 UIKitCore                      0x1ac581228 -[UIViewController dismissViewControllerWithTransition:completion:] + 1200
14 UIKitCore                      0x1ac580c90 -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 508
15 UIKitCore                      0x1ac5833a0 -[UIViewController dismissViewControllerAnimated:completion:] + 132
16 UIKitCore                      0x1acbc028c __68-[UIWindow _removeAllViewControllersFromWindowHierarchyFromDealloc:]_block_invoke + 60
17 UIKitCore                      0x1ac57b154 +[UIViewController _performWithoutDeferringTransitionsAllowingAnimation:actions:] + 168
18 UIKitCore                      0x1acbbff1c -[UIWindow _removeAllViewControllersFromWindowHierarchyFromDealloc:] + 288
19 UIKitCore                      0x1acbc0438 -[UIWindow setRootViewController:] + 284
20 UnityFramework                 0x101814afc (Missing)
21 UnityFramework                 0x101815ad0 (Missing)

to

1  UnityFramework                 0x102af3e38 UnityIsOrientationEnabled + 250 (ScreenManager.h:250)
2  UnityFramework                 0x10187c52c EnabledAutorotationInterfaceOrientations() + 178 (UnityViewControllerBase+iOS.mm:178)
3  UnityFramework                 0x101870b6c -[UnityAppController application:supportedInterfaceOrientationsForWindow:] + 201 (UnityAppController.mm:201)
4  UIKitCore                      0x1acb8c140 -[UIApplication _supportedInterfaceOrientationsForWindow:] + 108
5  UIKitCore                      0x1ac587a64 -[UIViewController __supportedInterfaceOrientations] + 256
6  UIKitCore                      0x1ac579028 -[UIViewController _preferredInterfaceOrientationGivenStatusBarAndDeviceAndOrientation:] + 104
7  UIKitCore                      0x1ac587680 -[UIViewController _preferredInterfaceOrientationForPresentationInWindow:fromInterfaceOrientation:] + 544
8  UIKitCore                      0x1ac4981c8 -[_UIFullscreenPresentationController _adjustOrientationIfNecessaryInWindow:forViewController:preservingViewController:] + 576
9  UIKitCore                      0x1ac48deb8 -[UIPresentationController _dismissWithAnimationController:interactionController:target:didEndSelector:] + 684
10 UIKitCore                      0x1ac58201c __99-[UIViewController _dismissViewControllerWithAnimationController:interactionController:completion:]_block_invoke_2 + 72
11 UIKitCore                      0x1ad010c14 +[UIView(Animation) performWithoutAnimation:] + 96
12 UIKitCore                      0x1ac581e98 -[UIViewController _dismissViewControllerWithAnimationController:interactionController:completion:] + 580
13 UIKitCore                      0x1ad010c14 +[UIView(Animation) performWithoutAnimation:] + 96
14 UIKitCore                      0x1ac581b4c -[UIViewController _dismissViewControllerWithTransition:from:completion:] + 816
15 UIKitCore                      0x1ac581228 -[UIViewController dismissViewControllerWithTransition:completion:] + 1200
16 UIKitCore                      0x1ac580c90 -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 508
17 UIKitCore                      0x1ac5833a0 -[UIViewController dismissViewControllerAnimated:completion:] + 132
18 UIKitCore                      0x1acbc028c __68-[UIWindow _removeAllViewControllersFromWindowHierarchyFromDealloc:]_block_invoke + 60
19 UIKitCore                      0x1ac57b154 +[UIViewController _performWithoutDeferringTransitionsAllowingAnimation:actions:] + 168
20 UIKitCore                      0x1acbbff1c -[UIWindow _removeAllViewControllersFromWindowHierarchyFromDealloc:] + 288
21 UIKitCore                      0x1acbc0438 -[UIWindow setRootViewController:] + 284
22 UnityFramework                 0x101870a50 UnityCleanupTrampoline + 168 (UnityAppController.mm:168)
23 UnityFramework                 0x101871a14 -[UnityAppController applicationWillTerminate:] + 468 (UnityAppController.mm:468)

The addresses are different merely because it's another build with changes.

The crash is actually 100% reproducible, unity app just crashes when user closes it while some ad is running. When UnityAppController.UnityCleanupTrampoline() gets called it then sets root ViewController to nil, but this lead to iOS 13 asking the app for application:supportedInterfaceOrientationsForWindow, which then asks ViewController for orientations. This leads to crash in backgound, because app is "closed" already. You can check out "Data\PlaybackEngines\iOSSupport\Trampoline\Classes" folder at Unity install location to have a look at sources yourself. This is clearly a Unity bug. I've tried to quickfix it by changing the UnityCleanupTrampoline, with no luck. The crash still reproduces, but not shown in crashlytics at all for some weird reason.

Please let me know if you find any solution to this. Thanks.

0x61726b commented 4 years ago

Hey, @L4fter thanks for sharing your findings. We opted to downgrade to Unity 2019.2.x in one game and the crashes went away. But we cant downgrade some other game because it depends on some 2019.3 features. I'm discarding what I said about Unity 2018 in my previous post because that must be something else. We didnt experience this crash when we downgraded 1 game to 2019.2.x , and with your findings it's certain that this is a bug in 2019.3.x.

I also tested this in Unity 2020 beta and it's happening there too.

VGMFR commented 4 years ago

@L4fter Thanks a lot for sharing this. You should report this bug to Unity using Unity Bug Report!

L4fter commented 4 years ago

@VGMFR I did. Will get in touch if I receive any news. Another question is: should the bug in crashlytics regarding unity 19.3 be opened separatly from this thread? @patm1987 ?

0x61726b commented 4 years ago

How destructive would removing UnityCleanupTrampoline() from applicationWillTerminate be? I'm comparing Unity 2019.2.x and 2019.3.x applicationWillTerminate callbacks in UnityAppController.mm, obviously a lot are different but if I change the code to be same as 2019.2.x implementation, crash does not happen.

This means:

2019.2.x:

- (void)applicationWillTerminate:(UIApplication*)application
{
    ::printf("-> applicationWillTerminate()\n");

    Profiler_UninitProfiler();

    if (_unityAppReady)
    {
        UnityCleanup();
    }

    extern void SensorsCleanup();
    SensorsCleanup();
}

2019.3.x vanilla:

- (void)applicationWillTerminate:(UIApplication*)application
{
    ::printf("-> applicationWillTerminate()\n");

    // Only clean up if Unity has finished initializing, else the clean up process will crash,
    // this happens if the app is force closed immediately after opening it.
    if (_unityAppReady)
    {
        UnityCleanup();
        UnityCleanupTrampoline();
    }
}

2019.3.x edited:

- (void)applicationWillTerminate:(UIApplication*)application
{
    ::printf("-> applicationWillTerminate()\n");

    Profiler_UninitProfiler();

    // Only clean up if Unity has finished initializing, else the clean up process will crash,
    // this happens if the app is force closed immediately after opening it.
    if (_unityAppReady)
    {
        UnityCleanup();
        SensorsCleanup();
    }
}

If I run the app like this, the crash does not occur. But I dont know the extents of what could happen by removing the trampoline cleanup code. We can test this in production but if anyone has any ideas of what could happen by changing the code like this I'd appreciate it.

L4fter commented 4 years ago

My bet was to create flag like "shutdownStarted", set it first in UnityCleanupTrampoline(), and then check if it is set inside supportedInterfaceOrientationsForWindow. The latter already have a similar check in both unity versions:

if ([window rootViewController] == nil)
        return UIInterfaceOrientationMaskAll;

This failed, dunno why, probably a simple if-else in obj-c is just to much for me.

But you there have a great solution to use before official fix. The application is already closing, so who cares if anything breaks as long as no crash is happening.

0x61726b commented 4 years ago

We released a build with the edited applicationWillTerminate code and all the crashes went away and currently sitting at %99 crash free.

zoranigic commented 4 years ago

Cause of error is [_UnityAppController window].rootViewController = nil; Commenting it prevent error from happening.

`extern "C" void UnityCleanupTrampoline() { // Unity view and viewController will not necessary be destroyed right after this function execution. // We need to ensure that these objects will not receive any callbacks from system during that time. //[_UnityAppController window].rootViewController = nil; [[_UnityAppController unityView] removeFromSuperview];

// Prevent multiple cleanups
if (_UnityAppController == nil)
    return;

[KeyboardDelegate Destroy];

SensorsCleanup();

Profiler_UninitProfiler();

[DisplayManager Destroy];

UnityDestroyDisplayLink();

_UnityAppController = nil;

}`

odysoftware commented 4 years ago

At least I can confirm that with Unity 2019.3.1f6 you should not have those issues, but when moving up to at least 2019.3.1f9 then having several native crashes in analytics starts! - So for now downgrading to 2019.31f6 should work.

So the error must be in one of the versions after f6

VGMFR commented 4 years ago

@L4fter Hi, did you get some news from Unity? I also reported this issue, and even with the complete reproduction description, they ask for a project where they can just reproduce it without any effort. I'll try to do this, but I don't have the time at the moment. What is your status on the subject? Thanks!

0x61726b commented 4 years ago

@VGMFR I submitted a report with a project attached and repro steps last week. Havent heard back

L4fter commented 4 years ago

@VGMFR not a single word from them image

L4fter commented 4 years ago

@arkenthera @VGMFR I created thread at Unity forum to bring more attention to the bug from Unity team https://forum.unity.com/threads/unity-2019-3-crashes-on-ios-13.880030/ I assume they will notice the issue faster this way. I hope you guys can put a comment there describing the issue and linking your own bug reports. Hopefully that will give this thing a little momentum.

google-oss-bot commented 4 years ago

Hey @unnanego. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

odysoftware commented 4 years ago

Its still present -> crashes in UnityIsOrientationEnabled - is not related to unity ads! I have it in my app and its always crashing on closing the app - now also tested on 2019.3.13f1

cgviver commented 4 years ago

i faced the same issue in Unity 2018.4.21f1 plugins used : Admod, FB audience network etc .

How i resolved :

Previously :

changed to :

}

its working fine now without any crash while close and reopen while i build it directly to my iPad but after uploading to test flight i am facing the same issue.

cgviver commented 4 years ago

We released a build with the edited applicationWillTerminate code and all the crashes went away and currently sitting at %99 crash free.

i facing the same issue in unity 2018.4.21f1 . (17D50)","incident_id":"B6887DAC-0A40-41F4-A610-FD0545D5A28F","name":"ounger"} Incident Identifier: B6887DAC-0A40-41F4-A610-FD0545D5A28F CrashReporter Key: 2650223b012475d4cf45a6ff875aead981773466 Hardware Model: iPad5,3 Process: ounger [1935] Path: /private/var/containers/Bundle/Application/3707E949-2069-49C0-8346-24B2D6ED87BA/ounger.app/ounger Identifier: games.sponto.ounger Version: 16 (1.0) Code Type: ARM-64 (Native) Role: Non UI Parent Process: launchd [1] Coalition: games.sponto.ounger [1385]

Date/Time: 2020-05-11 17:49:43.0476 +0530 Launch Time: 2020-05-11 17:49:32.2554 +0530 OS Version: iPhone OS 13.3.1 (17D50) Release Type: User Baseband Version: n/a Report Version: 104

Exception Type: EXC_CRASH (SIGKILL) Exception Codes: 0x0000000000000000, 0x0000000000000000 Exception Note: EXC_CORPSE_NOTIFY Termination Reason: Namespace SPRINGBOARD, Code 0x8badf00d Termination Description: SPRINGBOARD, process-exit watchdog transgression: application:1935 exhausted real (wall clock) time allowance of 5.00 seconds | ProcessVisibility: Unknown | ProcessState: Running | WatchdogEvent: process-exit | WatchdogVisibility: Foreground | WatchdogCPUStatistics: ( | "Elapsed total CPU time (seconds): 4.080 (user 4.080, system 0.000), 27% CPU", | "Elapsed application CPU time (seconds): 0.196, 1% CPU" | ) Triggered by Thread: 0

What i did :

add this method to UnityAppController.mm (not exist in unity 2018.4. extern "C" void UnityCleanupTrampoline() { // Unity view and viewController will not necessary be destroyed right after this function execution. // We need to ensure that these objects will not receive any callbacks from system during that time. //[_UnityAppController window].rootViewController = nil; [[_UnityAppController unityView] removeFromSuperview];

// Prevent multiple cleanups
if (_UnityAppController == nil)
    return;

[KeyboardDelegate dealloc];

// SensorsCleanup();

Profiler_UninitProfiler();

[DisplayManager dealloc];

UnityDestroyDisplayLink();

_UnityAppController = nil;

}

and edited :

}

but still facing the same crash issue. Any help will be appreciated.

VGMFR commented 4 years ago

@arkenthera @L4fter Thank you for your answers. No need to send them a project then, si you already did it. In the meantime we applied @arkenthera fix and it worked: no more crashes reported on the subject!

apautrot commented 4 years ago

On my side, until a fix is found on Unity side, I SOLVED THIS ISSUE by applying the fix proposal made by @zoranigic and my build is live since 2 days, with more than 2K users acquired, ans so far, not a single crash (while my previous version had 5% users crashing on this issue).

google-oss-bot commented 4 years ago

Hey @unnanego. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot commented 4 years ago

Hey @unnanego. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot commented 4 years ago

Since there haven't been any recent updates here, I am going to close this issue.

@unnanego if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.

0x61726b commented 4 years ago

Unity QA team finally answered my bug report saying they reproduced the crash and will resolve it in the future releases

nicolasgramlich commented 4 years ago

Just experienced the same issue. Thanks for being persistent @arkenthera :)

trymoto commented 4 years ago

@arkenthera also thanks! Ran into the crash problem today while building on 2019.3f14, rolled back to 3f9. Hoping to see it fixed in the upcoming changelogs.

Alej-P commented 4 years ago

@arkenthera do you have a link to the Unity issue tracker page?

renattou commented 4 years ago

I talked with Unity support and it seems the fix was shipped with Unity 2019.4.0f1. We still didn't try updating though.