1

I started getting this warning :

This application is modifying the autolayout engine from a background thread, which can lead to engine corruption and weird crashes. This will cause an exception in a future release.

Here is the backtrace with the warning message :

Stack:(
0   CoreFoundation                      0x25542303 <redacted> + 150
1   libobjc.A.dylib                     0x24d0edff objc_exception_throw + 38
2   CoreFoundation                      0x25542231 <redacted> + 0
3   Foundation                          0x25e25bbb <redacted> + 170
4   Foundation                          0x25ccb637 <redacted> + 38
5   UIKit                               0x297e0431 <redacted> + 52
6   UIKit                               0x297e0e1f <redacted> + 222
7   UIKit                               0x297fd52d <redacted> + 96
8   UIKit                               0x29efe579 <redacted> + 320
9   UIKit                               0x299dc8e9 <redacted> + 148
10  UIKit                               0x299cb44f <redacted> + 42
11  UIKit                               0x296d5a83 <redacted> + 714
12  QuartzCore                          0x277b1ad5 <redacted> + 128
13  QuartzCore                          0x277ad1d1 <redacted> + 352
14  QuartzCore                          0x277ad061 <redacted> + 16
15  QuartzCore                          0x277ac581 <redacted> + 368
16  QuartzCore                          0x277ac233 <redacted> + 614
17  QuartzCore                          0x277d9b63 <redacted> + 310
18  libsystem_pthread.dylib             0x25279905 <redacted> + 508
19  libsystem_pthread.dylib             0x25279507 <redacted> + 86
20  libsystem_pthread.dylib             0x2527a485 pthread_exit + 28
21  Foundation                          0x25ca31d7 <redacted> + 10
22  Foundation                          0x25d5e34f <redacted> + 1178
23  libsystem_pthread.dylib             0x2527ac7f <redacted> + 138
24  libsystem_pthread.dylib             0x2527abf3 _pthread_start + 110
25  libsystem_pthread.dylib             0x25278a08 thread_start + 8

As far as i know i don't use Autolayout (as i want the app to be iOS 5.1.1 compatible). and also i don't seem to be within the reported backtrace.

I also have the PSPDFUIKitMainThreadGuard class enabled, which should be checking the main thread accesses but nothing trigered out of this thing.

Is there any way how to find out what is doing such a thing?

Question This application is modifying the autolayout engine from a background thread, which can lead to engine corruption and weird crashes doesn't explain how to debug such thing.

Community
  • 1
  • 1
LetynSOFT
  • 124
  • 1
  • 8
  • Any update to any UI component from other than the main queue will generate this message - so look to see where you are updating UI from completion handlers and so on – Paulw11 Jan 21 '16 at 14:27
  • 1
    Add an exception breakpoint. Show us the code causing the crash, not the error. :D – Fogmeister Jan 21 '16 at 14:29
  • The app doesn't crash, it just produces this warning into the debug log and i don't really know which part of the code does this... The debugging worked fine with the PSPDFUIKitMainThreadGuard class, but it does nothing in regards to this issue – LetynSOFT Jan 21 '16 at 14:31
  • Find all your background job (thread, dispatch...), and look if there is any UI changes in it. – Michaël Azevedo Jan 21 '16 at 14:40
  • Possible duplicate of [This application is modifying the autolayout engine from a background thread, which can lead to engine corruption and weird crashes](http://stackoverflow.com/questions/31951704/this-application-is-modifying-the-autolayout-engine-from-a-background-thread-wh) – SwiftArchitect Jan 21 '16 at 14:53
  • Your answer is here: http://stackoverflow.com/a/31952060/218152 – SwiftArchitect Jan 21 '16 at 14:54
  • Ok, the issue was an iToast were beiing invoked on a background thread, but only occasionaly thronwing this error. The correct answer would be to add a breakpont to all exceptions and debug it that way..., Can you make an answer from your comment Fogmeister? – LetynSOFT Jan 21 '16 at 15:08
  • Assumed you already had a breakpoint for exceptions. Good catch regardless. – SwiftArchitect Jan 21 '16 at 15:12
  • How did you solve your issue? – SwiftArchitect Jan 31 '16 at 01:37

1 Answers1

0

Whether or not you are using Autolayout directly is not the issue at hand. The OS is converting legacy autoresizingMask to modern NSLayoutConstraint under the hood.

The issue has to do with modifying the UI from anywhere but the main tread. This typically happens when:

  • responding to a NSNotification
  • returning from an async method
  • executing a completion block on a thread you do not control
  • explicitly scheduling a task in the background

Note about The app doesn't crash...
The app will crash. All you need is time and a few thousand users...

SwiftArchitect
  • 43,382
  • 25
  • 129
  • 168