After upgrading my build environment to Xcode 12 and iOS 14 my application has begun crashing with the following error:
Normally this kind of thing can be tracked down by enabling the Main Thread Checker, but it does not appear to be working in this one case. I've enabled it and verified that the breakpoint it creates is active, but when the background thread does its thing the breakpoint is not called - the app simply crashes with the ever so useless:
I'm frankly not sure what is creating this background thread - it does not appear to be associated with a queue. I'm not using any low-level APIs that would create a thread on my own, so I assume it's being executed by one of the libraries I'm using (or by one of the core iOS libs).
I'm going to start doing the usual things: disconnecting various bits of the app to see if I can get the crash to stop. If anyone knows how to get the Main Thread Checker to catch this, or might know what's going on here, please let me know. The app has been working fine for months when build on Xcode 11 and run on iOS 13.
Code Block 2020-09-22 13:49:14.896138-0500 FlightBox PFD[3347:2884020] This application is modifying the autolayout engine from a background thread after the engine was accessed from the main thread. This can lead to engine corruption and weird crashes. Stack:( 0 CoreAutoLayout 0x00007fff58010c53 _AssertAutoLayoutOnAllowedThreadsOnly + 190 1 CoreAutoLayout 0x00007fff58010fcd -[NSISEngine withBehaviors:performModifications:] + 25 2 UIKitCore 0x00007fff24ab9bdc -[UIView(UIConstraintBasedLayout) _resetLayoutEngineHostConstraints] + 70 3 UIKitCore 0x00007fff24bbd92f -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2715 4 QuartzCore 0x00007fff27a3dd87 -[CALayer layoutSublayers] + 258 5 QuartzCore 0x00007fff27a44239 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 575 6 QuartzCore 0x00007fff27a4ff91 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 65 7 QuartzCore 0x00007fff27990078 _ZN2CA7Context18commit_transactionEPNS_11TransactionEdPd + 496 8 QuartzCore 0x00007fff279c6e13 _ZN2CA11Transaction6commitEv + 783 9 QuartzCore 0x00007fff279c7616 _ZN2CA11Transaction14release_threadEPv + 210 10 libsystem_pthread.dylib 0x00007fff5dcda054 _pthread_tsd_cleanup + 551 11 libsystem_pthread.dylib 0x00007fff5dcdc512 _pthread_exit + 70 12 libsystem_pthread.dylib 0x00007fff5dcd9ddd _pthread_wqthread_exit + 77 13 libsystem_pthread.dylib 0x00007fff5dcd8afc _pthread_wqthread + 481 14 libsystem_pthread.dylib 0x00007fff5dcd7b77 start_wqthread + 15 ) 2020-09-22 13:49:14.898322-0500 FlightBox PFD[3347:2884020] * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Modifications to the layout engine must not be performed from a background thread after it has been accessed from the main thread.' * First throw call stack: ( 0 CoreFoundation 0x00007fff2043a126 __exceptionPreprocess + 242 1 libobjc.A.dylib 0x00007fff20177f78 objc_exception_throw + 48 2 CoreAutoLayout 0x00007fff58010d41 -[NSISEngine tryToOptimizeReturningMutuallyExclusiveConstraints] + 0 3 CoreAutoLayout 0x00007fff58010fcd -[NSISEngine withBehaviors:performModifications:] + 25 4 UIKitCore 0x00007fff24ab9bdc -[UIView(UIConstraintBasedLayout) _resetLayoutEngineHostConstraints] + 70 5 UIKitCore 0x00007fff24bbd92f -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2715 6 QuartzCore 0x00007fff27a3dd87 -[CALayer layoutSublayers] + 258 7 QuartzCore 0x00007fff27a44239 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 575 8 QuartzCore 0x00007fff27a4ff91 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 65 9 QuartzCore 0x00007fff27990078 _ZN2CA7Context18commit_transactionEPNS_11TransactionEdPd + 496 10 QuartzCore 0x00007fff279c6e13 _ZN2CA11Transaction6commitEv + 783 11 QuartzCore 0x00007fff279c7616 _ZN2CA11Transaction14release_threadEPv + 210 12 libsystem_pthread.dylib 0x00007fff5dcda054 _pthread_tsd_cleanup + 551 13 libsystem_pthread.dylib 0x00007fff5dcdc512 _pthread_exit + 70 14 libsystem_pthread.dylib 0x00007fff5dcd9ddd _pthread_wqthread_exit + 77 15 libsystem_pthread.dylib 0x00007fff5dcd8afc _pthread_wqthread + 481 16 libsystem_pthread.dylib 0x00007fff5dcd7b77 start_wqthread + 15 )
Normally this kind of thing can be tracked down by enabling the Main Thread Checker, but it does not appear to be working in this one case. I've enabled it and verified that the breakpoint it creates is active, but when the background thread does its thing the breakpoint is not called - the app simply crashes with the ever so useless:
Code Block libc++abi.dylib: terminating with uncaught exception of type NSException
I'm frankly not sure what is creating this background thread - it does not appear to be associated with a queue. I'm not using any low-level APIs that would create a thread on my own, so I assume it's being executed by one of the libraries I'm using (or by one of the core iOS libs).
I'm going to start doing the usual things: disconnecting various bits of the app to see if I can get the crash to stop. If anyone knows how to get the Main Thread Checker to catch this, or might know what's going on here, please let me know. The app has been working fine for months when build on Xcode 11 and run on iOS 13.