Frequent NSInternalInconsistencyException Crashes After Displaying Full-Screen Ads
[REQUIRED] Step 1: Describe your environment
- Unity version: 2022.3.22f1
- Google Mobile Ads Unity plugin version: v9.5.0
- Plugin installation method: unitypackage import
- Platform: iOS
- Platform OS version: iOS 18
- Any specific devices issue occurs on: iPhone13, 15, 16, 16 pro
- Mediation ad networks used, and their versions: Liftoff Monetize 5.2.3, Pangle 4.5.4
[REQUIRED] Step 2: Describe the problem
Steps to reproduce:
We do not have a reliable step-by-step reproduction procedure. However, Crashlytics frequently reports the following crash after users have viewed a full-screen ad. It appears to occur around the time the ad is dismissed.
The crash does not happen for every ad impression, and we haven’t been able to reproduce it reliably in our own testing. We do not call Application.Quit() or exit(0) anywhere in our code.
Below is a snippet of the crash log:
Fatal Exception: NSInternalInconsistencyException
Attempting to attach window to an invalidated scene: <UIWindowScene: 0x1028a3380; role: UIWindowSceneSessionRoleApplication; persistentIdentifier: 805D79E0-CA08-4454-9964-375E03A9C791; activationState: UISceneActivationStateUnattached>; window: <ASOOverlayWindow: 0x138ae8000; baseClass = UIApplicationRotationFollowingWindow; frame = (0 0; 390 844); hidden = YES; layer = <UIWindowLayer: 0x3034f4c30>>
Fatal Exception: NSInternalInconsistencyException
0 CoreFoundation 0x827cc __exceptionPreprocess
1 libobjc.A.dylib 0x172e4 objc_exception_throw
2 Foundation 0x80f8d8 _userInfoForFileAndLine
3 UIKitCore 0x362958 -[UIWindowScene _attachWindow:]
4 UIKitCore 0x3625b4 -[UIWindow _commonInitDebugName:uiScene:]
5 UIKitCore 0x3624a0 -[UIWindow _initWithFrame:debugName:windowScene:]
6 UIKitCore 0x2ccaf0 -[UIApplicationRotationFollowingWindow _initWithFrame:debugName:windowScene:]
7 UIKitCore 0x2cc8e4 -[UIWindow initWithWindowScene:]
8 UIKitCore 0xd1a34c -[UIApplicationRotationFollowingWindow initWithWindowScene:]
9 AppStoreOverlays 0x5778 -[ASOOverlayWindow initWithWindowScene:]
10 AppStoreOverlays 0x302c -[ASOOverlayManager initWithWindowScene:]
11 AppStoreOverlays 0x37e0 -[UIWindowScene(AppOverlayManager) _aso_appOverlayManager]
12 StoreKit 0x45fd8 +[SKOverlay dismissOverlayInScene:]
13 UnityFramework 0x247c22c GAD_GADInAppStoreMonitor_arm64_11_7_0
14 UnityFramework 0x24c0ba0 GADPostNotificationFromMainQueue
15 CoreFoundation 0x512e0 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__
16 CoreFoundation 0x51210 ___CFXRegistrationPost_block_invoke
17 CoreFoundation 0x51158 _CFXRegistrationPost
18 CoreFoundation 0x4f70c _CFXNotificationPost
19 Foundation 0x2fea4 -[NSNotificationCenter postNotificationName:object:userInfo:]
20 UnityFramework 0x24c06c0 GADPostNotificationFromMainQueue
21 UnityFramework 0x24bfba8 GADPostNotification
22 UnityFramework 0x246cfb8 GAD_GADIntermission_arm64_11_7_0
23 UnityFramework 0x246cdf4 GAD_GADIntermission_arm64_11_7_0
24 UnityFramework 0x246ce58 GAD_GADIntermission_arm64_11_7_0
25 UnityFramework 0x246c5bc GAD_GADIntermission_arm64_11_7_0
26 UnityFramework 0x24c0ba0 GADPostNotificationFromMainQueue
27 CoreFoundation 0x512e0 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__
28 CoreFoundation 0x51210 ___CFXRegistrationPost_block_invoke
29 CoreFoundation 0x51158 _CFXRegistrationPost
30 CoreFoundation 0x4f70c _CFXNotificationPost
31 Foundation 0x2fea4 -[NSNotificationCenter postNotificationName:object:userInfo:]
32 UnityFramework 0x24c06c0 GADPostNotificationFromMainQueue
33 UnityFramework 0x24bfba8 GADPostNotification
34 UnityFramework 0x244d488 GAD_GADFullScreenAdViewController_arm64_11_7_0
35 UIKitCore 0xe4290 -[UIViewController _setViewAppearState:isAnimating:]
36 UIKitCore 0x2faa2c -[UIViewController __viewDidDisappear:]
37 UIKitCore 0x2fa6e0 -[UIViewController _endAppearanceTransition:]
38 UIKitCore 0x2e47b4 __48-[UIPresentationController transitionDidFinish:]_block_invoke
39 UIKitCore 0x28ccb0 -[UIPresentationController transitionDidFinish:]
40 UIKitCore 0xa6a3b4 -[_UICurrentContextPresentationController transitionDidFinish:]
41 UIKitCore 0xa67c20 __77-[UIPresentationController runTransitionForCurrentStateAnimated:handoffData:]_block_invoke.112
42 UIKitCore 0x2e3194 -[_UIViewControllerTransitionContext completeTransition:]
43 UIKitCore 0x2e54c8 -[UIViewControllerBuiltinTransitionViewAnimator animateTransition:]
44 UIKitCore 0xb1cd50 ___UIViewControllerTransitioningRunCustomTransitionWithRequest_block_invoke_3
45 UIKitCore 0x43343c +[UIKeyboardSceneDelegate _pinInputViewsForKeyboardSceneDelegate:onBehalfOfResponder:duringBlock:]
46 UIKitCore 0xb1cc6c ___UIViewControllerTransitioningRunCustomTransitionWithRequest_block_invoke_2
47 UIKitCore 0x156e694 +[UIView(Animation) _setAlongsideAnimations:toRunByEndOfBlock:animated:]
48 UIKitCore 0xb1cac0 _UIViewControllerTransitioningRunCustomTransitionWithRequest
49 UIKitCore 0xa676c8 __77-[UIPresentationController runTransitionForCurrentStateAnimated:handoffData:]_block_invoke_3
50 UIKitCore 0x28f74c +[UIPresentationController _scheduleTransition:]
51 UIKitCore 0xa66d18 -[UIPresentationController runTransitionForCurrentStateAnimated:handoffData:]
52 UIKitCore 0xa65248 -[UIPresentationController _dismissWithAnimationController:interactionController:animated:handoffData:]
53 UIKitCore 0x7ff30 +[UIView(Animation) performWithoutAnimation:]
54 UIKitCore 0xb0e81c __73-[UIViewController _dismissViewControllerWithTransition:from:completion:]_block_invoke
55 UIKitCore 0x7ff30 +[UIView(Animation) performWithoutAnimation:]
56 UIKitCore 0xb0dd74 -[UIViewController _dismissViewControllerWithTransition:from:completion:]
57 UIKitCore 0x525b84 -[UIViewController dismissViewControllerWithTransition:completion:]
58 UIKitCore 0x525248 -[UIViewController _performCoordinatedPresentOrDismiss:animated:]
59 UIKitCore 0x525008 -[UIViewController dismissViewControllerAnimated:completion:]
60 UIKitCore 0x38c144 __68-[UIWindow _removeAllViewControllersFromWindowHierarchyFromDealloc:]_block_invoke
61 UIKitCore 0x38c0ac +[UIViewController _performWithoutDeferringTransitionsAllowingAnimation:actions:]
62 UIKitCore 0x38bdc4 -[UIWindow _removeAllViewControllersFromWindowHierarchyFromDealloc:]
63 UIKitCore 0x2150d0 -[UIWindow setRootViewController:]
64 UnityFramework 0x217d0b8 UnityCleanupTrampoline + 172 (UnityAppController.mm:172)
65 UIKitCore 0x113fdcc -[UIApplication _terminateWithStatus:]
66 UIKitCore 0x17ef88 -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]
67 UIKitCore 0x95f8f4 -[_UISceneLifecycleMultiplexer forceExitWithTransitionContext:scene:]
68 UIKitCore 0x113b54c -[UIApplication workspaceShouldExit:withTransitionContext:]
69 FrontBoardServices 0x54f68 __63-[FBSWorkspaceScenesClient willTerminateWithTransitionContext:]_block_invoke_2
70 FrontBoardServices 0x14c44 -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:]
71 FrontBoardServices 0x54f08 __63-[FBSWorkspaceScenesClient willTerminateWithTransitionContext:]_block_invoke
72 libdispatch.dylib 0x40d0 _dispatch_client_callout
73 libdispatch.dylib 0x7b14 _dispatch_block_invoke_direct
74 FrontBoardServices 0x16300 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__
75 FrontBoardServices 0x16280 -[FBSMainRunLoopSerialQueue _targetQueue_performNextIfPossible]
76 FrontBoardServices 0x16158 -[FBSMainRunLoopSerialQueue _performNextFromRunLoopSource]
77 CoreFoundation 0x56328 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
78 CoreFoundation 0x562bc __CFRunLoopDoSource0
79 CoreFoundation 0x53e24 __CFRunLoopDoSources0
80 CoreFoundation 0x52fbc __CFRunLoopRun
81 CoreFoundation 0x52830 CFRunLoopRunSpecific
82 GraphicsServices 0x11c4 GSEventRunModal
83 UIKitCore 0x3d2eb0 -[UIApplication _run]
84 UIKitCore 0x4815b4 UIApplicationMain
85 UnityFramework 0x2181a48 -[UnityFramework runUIApplicationMainWithArgc:argv:] + 96 (main.mm:96)
86 MyDog 0x412c main + 28 (main.mm:28)
87 ??? 0x1bf152ec8 (シンボルが不足しています)
If there is any known issue or recommended workaround regarding this crash, we would appreciate any guidance. Thank you!
We have the exact same issue! (AdMob 9.5.0 with LiftOff 5.2.2) It started 6 days ago (when we basically updated AdMob + Mediators).
We could identify that it seems to be related to Vungle (Liftoff) Interstitial ads, as when we disabled them, the crashes went down. Not sure if also rewarded ads are problematic, but atleast interstitials of them are defintively breaking. Also Vungle seems sometimes on iOS to play sound even so the phone is muted :)
Just checked: Funny thing we only updated AdMob...as our vungle adapter was manually imported into the project and not via the UPM). Therefore our liftoff adapter is still at 5.2.2
Thanks for the report, I will let the IOS team know about this.
So to confirm, the replication steps seem to be:
- Admob 9.5.0 with the above mediation adapters.
- "Disable" the interstitial ads (what do you mean by this?)
- Open the ad?
Corect?
@NVentimiglia
Thanks for following up! I’d like to clarify my own situation.
-
AdMob version & mediation: I’m currently using AdMob 9.5.0 with Liftoff, Pangle mediation.
-
Crash details: Crashlytics reports NSInternalInconsistencyException involving [SKOverlay dismissOverlayInScene:]. It usually occurs when a full-screen ad is dismissed or when the app terminates. We’re not calling Application.Quit() or exit(0), and so far we haven’t found a reliable way to reproduce it ourselves. You can see the full crash log snippet in my original post.
-
Regarding “disable the interstitial ads”: Another user mentioned that turning off LiftOff interstitials helped in their case. However, my crashes occur under normal usage, with all interstitial and rewarded ads still enabled.
If there’s a known workaround or any suggestions you can provide, I’d really appreciate it. Thank you for looking into this and for passing the info along to the iOS team!
Thanks for the report, I will let the IOS team know about this.
So to confirm, the replication steps seem to be:
- Admob 9.5.0 with the above mediation adapters.
- "Disable" the interstitial ads (what do you mean by this?)
- Open the ad?
Corect?
No :)
To replicate the issue you need Admob 9.5.0 + Liftoff mediation adapter.
Disabling liftoff ads (on the admob platform) for interstitials helped us to REDUCE the errors (basically confirming for us, that liftoff ads are the problem). So if you want to see crashes, you need to have liftoff ads of course enabled.
Thanks for the update, I will let the team know.
This is the most common crash in my game. Please fix it as soon as possible.
I am seeing alot of these crashes in my game as well. Mostly on iOS 18.3.1 but I have also seen as low as 18.1.1.
I am not using any of the adapters mentioned in the original post. I am using AdMob, AppLovin, Meta, and Unity.
The crash is always after presenting a full screen ad, when the game has gone to the background and lost focus.
I am seeing alot of these crashes in my game as well. Mostly on iOS 18.3.1 but I have also seen as low as 18.1.1.
I am not using any of the adapters mentioned in the original post. I am using AdMob, AppLovin, Meta, and Unity.
The crash is always after presenting a full screen ad, when the game has gone to the background and lost focus.
I’m experiencing the same issue, and it is affecting all iOS 18.x devices. The problem appears to have emerged after building the project with Xcode 16.x. Our app uses AdMob mediation, but the issue persists even after disabling all mediation ads.
I updated my app to log the adapter response info:
ad.GetResponseInfo().GetLoadedAdapterResponseInfo().ToString()
right before the ad is shown to see if I can figure out which adapter is causing the issue. I also changed my mediation bidding strategy at the same time, so perhaps coincidentally I am receiving a lot less of these crashes since the update, but so far, 3 out of 3 crashes are from the AdMob Network:
Network: GADMAdapterGoogleAdMobAds Ad Source Name:AdMob Network
I am using Unity AdMob SDK 9.3.0 which is using iOS Google Mobile Ads SDK 11.11.0.
any update?
Any update?
Experiencing the same issue after upgrading ad unity packages: GoogleMobileAds v9.6.0 UnityAdsUnityAdapter v3.13 LiftoffUnityAdapter v5.2.4
This bug should be the top priority. We had to downgrade the AdMob SDK just to prevent crashes—they were happening way too often :(
This bug should be the top priority. We had to downgrade the AdMob SDK just to prevent crashes—they were happening way too often :(
What version is stable, that you downgraded to?
Has the latest v10.0.0 fixed this?
Hello, while we were unable to reproduce this exact behavior, we have included some code that might be able to mitigate the crashes in the latest 10.0.0 build. Is it possible for folks to upgrade to the latest and see if they notice a drop in crash rates.
Hello, while we were unable to reproduce this exact behavior, we have included some code that might be able to mitigate the crashes in the latest 10.0.0 build. Is it possible for folks to upgrade to the latest and see if they notice a drop in crash rates.
I am sure if you try it enough, you can reproduce the issue.
In the video below, you can see that the ad messes up the screen resolution. Watch it carefully and you'll notice that as soon as the playable ad starts, the screen shifts down a little bit. After the video finishes, the game UI is also affected.
I believe this issue is likely related to the crashes mentioned above.
(It's better to download the video first and then watch it)
https://drive.google.com/file/d/1sH103WrDr1zhiEQqNIkibMR4GfPXB_Sq/view?usp=sharing
Anyone upgraded to v10.0.0 and tested yet?
Test on v10.0.0 and the same issue persists. When is this being addressed?
Were you able to see this happen on your device or in Firebase logs? Any information around the ad viewed might help us. We believe it to be triggered around the app store overlay being shown while the underlying ad is being dismissed. We will investigate further.
We reverted to Admob v9.1.0. The issue is not here.
Just to recap, as reported by others, the issue is present on v9.3, v9.4, v9.5, and v10. Have not tested v9.2, and v9.6 probably has it too.
This bug should be the top priority. We had to downgrade the AdMob SDK just to prevent crashes—they were happening way too often :(
What version is stable, that you downgraded to?
All I have is a Firebase Crashlytics partial-trace:
Fatal Exception: NSInternalInconsistencyException Attempting to attach window to an invalidated scene: <UIWindowScene: role: UIWindowSceneSessionRoleApplication;
I also have some breadcrumb logs showing it is on the Ad Show and not before the Ad Closed.
Occurs on iOS only for me, from what I can see.
First saw this on May 24, 2024.
Any update?
Any update?
We don't believe this is particularly on ad show. Presence of ASOOverlayWindow makes us think its much later in the cycle. Internally we have seen this issue occur only on iPhones running iOS18 using Unity to build apps. For some context, the admob unity plugin uses the admob ios SDK to show ads and we havent seen similar issues on native iOS Apps. We have added some code to mitigate such crashes in the 12.3 iOS release which will be picked up the upcoming GMA Unity Plugin in the next 10.1 release which should be out later this week/early the week after.
We (my colleague and I) think this bug is related to unity202x & ios18.3
64 UnityFramework 0x217d0b8 UnityCleanupTrampoline + 172 (UnityAppController.mm:172)
//[_UnityAppController window].rootViewController = nil;
Commenting this line prevent error from happening.
Inspiration comes from: #https://discussions.unity.com/t/crash-fatal-exception-nsinternalinconsistencyexception/1551190/9 #https://discussions.unity.com/t/crashes-when-you-force-close-an-ios-app-with-another-view-controller-up/787078/3
@bigstupidx the issue predates v18.3 and has been present since August 2024. With your fix, are you commenting that each time you export out to Xcode from Unity?
@bigstupidx the issue predates v18.3 and has been present since August 2024. With your fix, are you commenting that each time you export out to Xcode from Unity?
You can add some code in OnPostProcessBuild scripts so it can be done automatically.
This is just a temporary fix, I think sooner or later this bug will be fixed by upgrading Unity or upgrading GoogleAdsUnityPlugin
@bigstupidx Okay sure. Have you tested this in production and seen crash-free rate increase as well as no other unintended issues?
@bigstupidx Okay sure. Have you tested this in production and seen crash-free rate increase as well as no other unintended issues?
Online 3 days so far, this bug is gone , and no other unintended issues found yet. crash-free rate increase from 98.5% to 99.8%
I updated with @bigstupidx fix and confirm to reduced the crash-rate I had significantly. Thanks!