I'm getting the dreaded warning:
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.
I know what it means (it has been asked several times before) and how to fix it, or should I say I would know, if I had a clue which part of my code is causing it: The warning pops up several times in a row, and only after I haven't been touching the app for a while.
Also, there are no asynchronous operations running (that I'm aware of) whose conclusion could trigger it.
So the question is: Is there a symbolic breakpoint I can set up (akin to the famous 'unsatisfiable layout constraints' one) to catch this?
I have tried the solution provided in this answer (symbolic breakpoint on +[NSException raise:format:]
), but it just stops three times for each warning, on some background thread with the following call stacks:
First stop:
Thread 11
> 0 +[NSException raise:format:]
16 start_wqthread
Second stop:
Thread 11
> 0 objc_exception_throw
17 start_wqthread
Third stop:
Thread 11
> 0 __cxa_throw
20 start_wqthread
The stack logged to the console by the warning, is the following:
Stack:(
0 CoreFoundation 0x000000010378834b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00000001031e921e objc_exception_throw + 48
2 CoreFoundation 0x00000001037f1265 +[NSException raise:format:] + 197
3 Foundation 0x0000000102ee4320 _AssertAutolayoutOnAllowedThreadsOnly + 180
4 Foundation 0x0000000102d05be4 -[NSISEngine withBehaviors:performModifications:] + 31
5 UIKit 0x0000000105417a42 -[UIView(UIConstraintBasedLayout) _resetLayoutEngineHostConstraints] + 76
6 UIKit 0x0000000104b11317 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1192
7 QuartzCore 0x00000001047cfcdc -[CALayer layoutSublayers] + 146
8 QuartzCore 0x00000001047c37a0 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
9 QuartzCore 0x00000001047c361e _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
10 QuartzCore 0x000000010475162c _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 280
11 QuartzCore 0x000000010477e713 _ZN2CA11Transaction6commitEv + 475
12 QuartzCore 0x000000010477eb91 _ZN2CA11Transaction14release_threadEPv + 593
13 libsystem_pthread.dylib 0x0000000107f8e50f _pthread_tsd_cleanup + 544
14 libsystem_pthread.dylib 0x0000000107f8e249 _pthread_exit + 152
15 libsystem_pthread.dylib 0x0000000107f8c7cd pthread_attr_getschedpolicy + 0
16 libsystem_pthread.dylib 0x0000000107f8c1ed start_wqthread + 13
)
...neither gives many clues regarding my code.