I've been getting occasional crash reports that look similar to this:
Fatal Exception: NSInternalInconsistencyException
Modifications to the layout engine must not be performed from a background thread after it has been accessed from the main thread.
Fatal Exception: NSInternalInconsistencyException
0 CoreFoundation 0x19dcd0a48 __exceptionPreprocess
1 libobjc.A.dylib 0x19d9f7fa4 objc_exception_throw
2 Foundation 0x19e1a6f08 -[NSISEngine tryToOptimizeReturningMutuallyExclusiveConstraints]
3 Foundation 0x19dfa803c -[NSISEngine withBehaviors:performModifications:]
4 UIKitCore 0x1a20ff8e8 -[UIView(UIConstraintBasedLayout) _resetLayoutEngineHostConstraints]
5 UIKitCore 0x1a21d9314 -[UIView(CALayerDelegate) layoutSublayersOfLayer:]
6 QuartzCore 0x1a473c7dc -[CALayer layoutSublayers]
7 QuartzCore 0x1a4742958 CA::Layer::layout_if_needed(CA::Transaction*)
8 QuartzCore 0x1a474d578 CA::Layer::layout_and_display_if_needed(CA::Transaction*)
9 QuartzCore 0x1a4695f1c CA::Context::commit_transaction(CA::Transaction*, double)
10 QuartzCore 0x1a46bfc08 CA::Transaction::commit()
11 QuartzCore 0x1a46c0b8c CA::Transaction::release_thread(void*)
12 libsystem_pthread.dylib 0x19d9eefb0 _pthread_tsd_cleanup
13 libsystem_pthread.dylib 0x19d9ebde8 _pthread_exit
14 libsystem_pthread.dylib 0x19d9ece7c _pthread_wqthread_legacy_worker_wrap
15 libsystem_pthread.dylib 0x19d9ecc18 _pthread_wqthread
16 libsystem_pthread.dylib 0x19d9ef760 start_wqthread
This is not being invoked by my code (at least directly). I've been running the app in the debugger with the Main Thread Checker enabled and have yet to catch whatever is causing this.
I've found multiple reports from others who have been experiencing similar issues, most commonly on iOS 13. (My app only supports 13 and later.) I have yet to see any solid explanation. @Eskimo - is it possible that iOS is invoking something that results in a UI state change which is called from a background thread?
Thanks,
-S