NSInternalInconsistencyException Call must be made on main thread

Hello, this crash is happening in our app since the IOS-15 but lately in IOS-16 the crash has increase significantly, specifically (IOS16.4.1).

  1. This crash is happening with in one second of user session according to crashlytics.
  2. Our splash page is around 3 second in those seconds all the necessary initialisation happens.

Any help would be appreciated!

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note:  EXC_CORPSE_NOTIFY
Triggered by Thread:  10

Last Exception Backtrace:
0   CoreFoundation                	0x1817f3c80 __exceptionPreprocess + 216 (NSException.m:200)
1   libobjc.A.dylib               	0x199019ee4 objc_exception_throw + 56 (objc-exception.mm:565)
2   Foundation                    	0x182f99c80 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 200 (NSException.m:242)
3   UIKitCore                     	0x183d63370 -[UIApplication _performAfterCATransactionCommitsWithLegacyRunloopObserverBasedTiming:block:] + 448 (UIApplication.m:3140)
4   UIKitCore                     	0x183d1ea34 -[UIWindow _noteOverlayInsetsDidChange] + 208 (UIWindow.m:2479)
5   UIKitCore                     	0x183d241dc -[UIViewController _setContentOverlayInsets:andLeftMargin:rightMargin:] + 604 (UIViewController.m:1012)
6   UIKitCore                     	0x183c84838 __121-[UIViewController __updateContentOverlayInsetsWithOurRect:inBoundsOfAncestorViewController:viaImmediateChildOfAncestor:]_block_invoke + 496 (UIViewController.m:1484)
7   UIKitCore                     	0x183c740f4 -[UIViewController __updateContentOverlayInsetsWithOurRect:inBoundsOfAncestorViewController:viaImmediateChildOfAncestor:] + 3108 (UIViewController.m:1559)
8   UIKitCore                     	0x183c25dac -[UIViewController _updateContentOverlayInsetsFromParentIfNecessary] + 732 (UIViewController.m:1230)
9   UIKitCore                     	0x183cda468 -[UIViewController _updateContentOverlayInsetsForSelfAndChildren] + 84 (UIViewController.m:1056)
10  UIKitCore                     	0x183debe98 -[UIViewController _updateLayoutForStatusBarAndInterfaceOrientation] + 604 (UIViewController.m:4695)
11  UIKitCore                     	0x183c619b4 -[UIViewController viewDidMoveToWindow:shouldAppearOrDisappear:] + 212 (UIViewController.m:6144)
12  UIKitCore                     	0x183d3c084 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 1512 (UIView.m:16014)
13  UIKitCore                     	0x183d3be3c -[UIView(Internal) _didMoveFromWindow:toWindow:] + 928 (UIView.m:15956)
14  UIKitCore                     	0x183c6898c __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 136 (UIView.m:12349)
15  UIKitCore                     	0x183cf46bc -[UIView(Hierarchy) _postMovedFromSuperview:] + 752 (UIView.m:476)
16  UIKitCore                     	0x183c16c98 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 2148 (UIView.m:16778)
17  UIKitCore                     	0x183d81150 -[UINavigationTransitionView transition:fromView:toView:] + 608 (UINavigationTransitionView.m:159)
18  UIKitCore                     	0x183d30730 -[UINavigationController _startTransition:fromViewController:toViewController:] + 2860 (UINavigationController.m:7459)
19  UIKitCore                     	0x183f45720 -[UINavigationController _startDeferredTransitionIfNeeded:] + 864 (UINavigationController.m:7523)
20  UIKitCore                     	0x183e26808 -[UINavigationController __viewWillLayoutSubviews] + 164 (UINavigationController.m:7835)
21  UIKitCore                     	0x183d565c0 -[UILayoutContainerView layoutSubviews] + 224 (UILayoutContainerView.m:88)
22  UIKitCore                     	0x183c191c4 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2556 (UIView.m:18426)
23  QuartzCore                    	0x185299520 CA::Layer::layout_if_needed(CA::Transaction*) + 528 (CALayer.mm:10118)
24  QuartzCore                    	0x18528c294 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 132 (CALayer.mm:2480)
25  QuartzCore                    	0x18529fcc8 CA::Context::commit_transaction(CA::Transaction*, double, double*) + 464 (CAContextInternal.mm:2612)
26  QuartzCore                    	0x1852a879c CA::Transaction::commit() + 708 (CATransactionInternal.mm:449)
27  QuartzCore                    	0x18528b9a8 CA::Transaction::flush_as_runloop_observer(bool) + 84 (CATransactionInternal.mm:956)
28  CoreFoundation                	0x18179f78c __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32 (CFRunLoop.c:1804)
29  CoreFoundation                	0x1817709b4 __CFRunLoopDoObservers + 616 (CFRunLoop.c:1917)
30  CoreFoundation                	0x18177f1e8 CFRunLoopRunSpecific + 656 (CFRunLoop.c:3270)
31  WebCore                       	0x190d32f48 RunWebThread(void*) + 772 (WebCoreThread.mm:679)
32  libsystem_pthread.dylib       	0x1dcb5a338 _pthread_start + 116 (pthread.c:891)
33  libsystem_pthread.dylib       	0x1dcb58938 thread_start + 8

Thread 10 name:
Thread 10 Crashed:
0   libsystem_kernel.dylib        	0x00000001bc0c2bbc __pthread_kill + 8
1   libsystem_pthread.dylib       	0x00000001dcb64844 pthread_kill + 208 (pthread.c:1668)
2   libsystem_c.dylib             	0x000000018bf350b0 __abort + 124 (abort.c:155)
3   libsystem_c.dylib             	0x000000018bee06b8 abort + 136 (abort.c:126)
4   libc++abi.dylib               	0x0000000199111de4 abort_message + 128 (abort_message.cpp:78)
5   libc++abi.dylib               	0x0000000199102684 demangling_terminate_handler() + 300 (cxa_default_handlers.cpp:71)
6   libobjc.A.dylib               	0x000000019901f8f8 _objc_terminate() + 124 (objc-exception.mm:701)
7   FirebaseCrashlytics           	0x0000000104dafa7c FIRCLSTerminateHandler() + 64124 (FIRCLSException.mm:0)
8   libc++abi.dylib               	0x0000000199111280 std::__terminate(void (*)()) + 16 (cxa_handlers.cpp:59)
9   libc++abi.dylib               	0x0000000199113e1c __cxa_rethrow + 144 (cxa_exception.cpp:616)
10  libobjc.A.dylib               	0x000000019901b9c8 objc_exception_rethrow + 40 (objc-exception.mm:604)
11  CoreFoundation                	0x000000018177f280 CFRunLoopRunSpecific + 808 (CFRunLoop.c:3283)
12  WebCore                       	0x0000000190d32f48 RunWebThread(void*) + 772 (WebCoreThread.mm:679)
13  libsystem_pthread.dylib       	0x00000001dcb5a338 _pthread_start + 116 (pthread.c:891)
14  libsystem_pthread.dylib       	0x00000001dcb58938 thread_start + 8

Something caused your navigation controller to be manipulated from a secondary thread. Its hard to tell what that may be from the crash trace, but from what happened my guess would be that you tried to push or pop a view controller onto the navigation controller from a secondary thread, which eventually tried to do work that specifically checked for being on the main thread (it all requires being on the main thread, but as you can imagine a lot of code doesn't explicitly check).

NSInternalInconsistencyException Call must be made on main thread
 
 
Q