Web Thread Crashed / NSInternalInconsistencyException threading violation: expected the main thread

Long-time lurker, first time poster. I've got a crash that I cannot, for the life of me, make heads or tails of or even attempt to reproduce. According to Firebase, the culprit seems to be a threading violation, which seems simple enough. I've tried using the Main Thread Checker with no luck. I don't know the specific conditions at the time of the crash.

Code Block
Fatal Exception: NSInternalInconsistencyException
0 CoreFoundation 0x1a3931654 exceptionPreprocess
1 libobjc.A.dylib 0x1a3653bcc objc_exception_throw
2 CoreFoundation 0x1a38346ec +[_CFXNotificationTokenRegistration keyCallbacks]
3 Foundation 0x1a3c7a16c -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:]
4 FrontBoardServices 0x1a8b00e84 -[FBSSerialQueue assertOnQueue]
5 FrontBoardServices 0x1a8ab6d88 -[FBSSceneImpl updateClientSettings:withTransitionContext:]
6 FrontBoardServices 0x1a8ab6fe8 -[FBSSceneImpl updateClientSettingsWithTransitionBlock:]
7 FrontBoardServices 0x1a8ab6ef8 -[FBSSceneImpl updateClientSettingsWithBlock:]
8 UIKitCore 0x1a755c6c0 -[FBSScene(UIApp) updateUIClientSettingsWithBlock:]
9 UIKitCore 0x1a79d9194 -[UIApplication _setAmbiguousControlCenterActivationMargin:]
10 UIKitCore 0x1a783bd24 -[UIPeripheralHost(UIKitInternal) setAmbiguousControlCenterActivationMargin:]
11 UIKitCore 0x1a77cb35c -[UIInputWindowController viewDidLayoutSubviews]
12 UIKitCore 0x1a7e999dc -[UIView(CALayerDelegate) layoutSublayersOfLayer:]
13 QuartzCore 0x1aa436494 -[CALayer layoutSublayers]
14 QuartzCore 0x1aa43c5ec CA::Layer::layout_if_needed(CA::Transaction*)
15 QuartzCore 0x1aa447128 CA::Layer::layout_and_display_if_needed(CA::Transaction*)
16 QuartzCore 0x1aa38fb44 CA::Context::commit_transaction(CA::Transaction*, double)
17 QuartzCore 0x1aa3b94e4 CA::Transaction::commit()
18 QuartzCore 0x1aa3b9ef8 CA::Transaction::observer_callback(CFRunLoopObserver*, unsigned long, void*)
19 CoreFoundation 0x1a38aef2c CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION
20 CoreFoundation 0x1a38a9e20 CFRunLoopDoObservers
21 CoreFoundation 0x1a38aa29c CFRunLoopRun
22 CoreFoundation 0x1a38a9ba8 CFRunLoopRunSpecific
23 WebCore 0x1abe43ee8 RunWebThread(void*)
24 libsystem_pthread.dylib 0x1a3647d98 _pthread_start
25 libsystem_pthread.dylib 0x1a364b74c thread_start


Interestingly enough, it's a web thread that crashed.

Code Block
Crashed: WebThread
0 SwipeKit 0x104a354c4 FIRCLSProcessRecordAllThreads + 392 (FIRCLSProcess.c:392)
1 SwipeKit 0x104a358a8 FIRCLSProcessRecordAllThreads + 423 (FIRCLSProcess.c:423)
2 SwipeKit 0x104a2bdb0 FIRCLSHandler + 34 (FIRCLSHandler.m:34)
3 SwipeKit 0x104a27878 FIRCLSExceptionRecord_block_invoke + 218 (FIRCLSException.mm:218)
4 libdispatch.dylib 0x1a35f7524 _dispatch_client_callout + 16
5 libdispatch.dylib 0x1a35db1fc _dispatch_lane_barrier_sync_invoke_and_complete + 56
6 SwipeKit 0x104a27010 FIRCLSExceptionRecord + 225 (FIRCLSException.mm:225)
7 SwipeKit 0x104a27308 FIRCLSExceptionRecordNSException + 111 (FIRCLSException.mm:111)
8 SwipeKit 0x104a26bf0 FIRCLSTerminateHandler() + 279 (FIRCLSException.mm:279)
9 libcabi.dylib 0x1a36fa14c std::terminate(void (*)()) + 16
10 libcabi.dylib 0x1a36fce58 __cxa_rethrow + 144
11 libobjc.A.dylib 0x1a3653d80 objc_exception_rethrow + 40
12 CoreFoundation 0x1a38a9c14 CFRunLoopRunSpecific + 532
13 WebCore 0x1abe43ee8 RunWebThread(void*) + 612
14 libsystem_pthread.dylib 0x1a3647d98 _pthread_start + 156
15 libsystem_pthread.dylib 0x1a364b74c thread_start + 8


I'm hoping that someone can help me make sense of the crash reports and give me some more insight into how i might reproduce and address this issue.

Crash reports attached.





We met the same crash, but cannot reproduce it.
It turned out to be an issue with the Google Mobile Ads SDK. The version of the SDK we were using was still leveraging UIWebView. From the Firebase Console, we were able to determine that there seemed to be a correlation between when we started compiling our project with Xcode 11 (iOS 13 SDK) and how it affects the behavior of UIWebView. I found a StackOverflow thread that referenced a similar issue:

https://stackoverflow.com/questions/58393257/crashlytics-thread-crashed-only-on-ios13-built-with-xcode11

UIWebview was officially deprecated in the Google Mobile Ads SDK as of version 7.55.0. If you're currently using that SDK, just update to the latest version. You won't need to add the plist entry as referenced in the SO thread. We noticed that the issue went away in Firebase after updating.

Hope this helps!



Web Thread Crashed / NSInternalInconsistencyException threading violation: expected the main thread
 
 
Q