iOS9 'modifying the autolayout engine from a background thread' without using autolayout - ios

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.

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...

Related

ios exception analyse NSInternalInconsistencyException

My app crash with a NSInternalInconsistencyException like this
Exception reason:NSInternalInconsistencyException
Exception name:Can't cancel on a touch that isn't already active!
Exception stack:(
0 CoreFoundation 0x0000000191a4d1d0 <redacted> + 148
1 libobjc.A.dylib 0x000000019048455c objc_exception_throw + 56
2 CoreFoundation 0x0000000191a4d08c <redacted> + 0
3 Foundation 0x000000019250502c <redacted> + 112
4 UIKit 0x0000000197fd1960 <redacted> + 404
5 UIKit 0x0000000197fcf970 <redacted> + 1648
6 libdispatch.dylib 0x00000001908d61fc <redacted> + 24
7 libdispatch.dylib 0x00000001908d61bc <redacted> + 16
8 libdispatch.dylib 0x00000001908e43dc <redacted> + 928
9 libdispatch.dylib 0x00000001908d99a4 <redacted> + 652
10 libdispatch.dylib 0x00000001908e634c <redacted> + 572
11 libdispatch.dylib 0x00000001908e60ac <redacted> + 124
12 libsystem_pthread.dylib 0x0000000190adf2a0 _pthread_wqthread + 1288
13 libsystem_pthread.dylib 0x0000000190aded8c start_wqthread + 4
)
How do i analyse the log? Like What do those number tags mean,"+ 148" "+ 56"...? How to detect the code that have invoked this exception.
Is this a crash from a release build of the app, or do you have it in Xcode? If in Xcode please provide the code causing the crash?
Looking at your report, the line
Can't cancel on a touch that isn't already active!
seems very telling. I would look through your code for anywhere you are interacting with a UITouch object, or perhaps a UIGestureRecognizer. My guess would be that somewhere you are manually calling to cancel an interaction that you should not be, and there is a race condition where that can sometimes happen after the system has already cancelled the touch (or vice versa, I guess).

When i run my app on simulator it doesn't show my app under both simulator settings and location services

It is the error shown in the Xcode when i switch back to settings in simulator .if somebody knows please kindly notify me. Thanks in advance
GeoNet[2325:41287] 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.
Stack:(
0 CoreFoundation 0x00c5ba14 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x0071ce02 objc_exception_throw + 50
2 CoreFoundation 0x00c5b93d +[NSException raise:format:] + 141
3 Foundation 0x004ee74b _AssertAutolayoutOnMainThreadOnly + 96
4 Foundation 0x003164c1 -[NSISEngine optimize] + 67
5 Foundation 0x00316f84 -[NSISEngine withBehaviors:performModifications:] + 245
6 Foundation 0x0031a404 -[NSISEngine withAutomaticOptimizationDisabled:] + 48
7 UIKit 0x01dd9b08 -[UIView(AdditionalLayoutSupport) _withAutomaticEngineOptimizationDisabledIfEngineExists:] + 75
8 UIKit 0x01dda781 -[UIView(AdditionalLayoutSupport) updateConstraintsIfNeeded] + 278
9 UIKit 0x01aa48b8 -[UITableViewCellContentView updateConstraintsIfNeeded] + 185
10 UIKit 0x01ddb66c -[UIView(AdditionalLayoutSupport) _updateConstraintsAtEngineLevelIfNeeded] + 372
11 UIKit 0x014a919a -[UIView(Hierarchy) _updateConstraintsAsNecessaryAndApplyLayoutFromEngine] + 173
12 UIKit 0x014a9929 -[UIView(Hierarchy) layoutSubviews] + 184
13 UIKit 0x014bb008 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 810
14 libobjc.A.dylib 0x00731059 -[NSObject performSelector:withObject:] + 70
15 QuartzCore 0x0603480a -[CALayer layoutSublayers] + 144
16 QuartzCore 0x060284ee _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 388
17 QuartzCore 0x06028352 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
18 QuartzCore 0x0601ae8b _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 317
19 QuartzCore 0x0604ee03 _ZN2CA11Transaction6commitEv + 561
20 QuartzCore 0x0604f1ab _ZN2CA11Transaction14release_threadEPv + 289
21 libsystem_pthread.dylib 0x0308d2f7 _pthread_tsd_cleanup + 93
22 libsystem_pthread.dylib 0x0308d051 _pthread_exit + 108
23 libsystem_pthread.dylib 0x0308d734 pthread_get_stackaddr_np + 0
24 libsystem_pthread.dylib 0x0308ae0e start_wqthread + 30
)
This is happening since iOS 9, on earlier version your code could have working fine. This is because, some of your functions must executing on the background thread and after view load trying to change the appearance of view. So, you must have put that function on main thread and load it asynchronously. Please share the code of ViewController, which you are trying to load for more specific answer.
dispatch_async(dispatch_get_main_queue(), ^{
// your code here
})
Been encountering this error a lot in my OS X using swift: "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."
See this link, You can find solution.

iOS Keyboard Extension crash before any of my code runs

I have been getting crash reports like this for a keyboard extension I have developed and am either confused about how to read the stack trace or why it is occurring or both and I was hoping someone could help me clear this up.
Below is the stack trace:
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0xd15db9df
Thread : Crashed: com.apple.main-thread
0 libobjc.A.dylib 0x37949f66 objc_msgSend + 5
1 UIKit 0x2cd57f05 -[_UIViewControllerTransitionContext completeTransition:] + 52
2 UIKit 0x2d10ac1f __95-[_UIWindowAnimationController _performLayoutAnimationWithContext:windowGeometryUpdatingBlock:]_block_invoke88 + 26
3 UIKit 0x2cc7b8e1 -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 308
4 UIKit 0x2cc7b4f9 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 184
5 UIKit 0x2cc7b40f -[UIViewAnimationState animationDidStop:finished:] + 70
6 QuartzCore 0x2c660fe7 CA::Layer::run_animation_callbacks(void*) + 234
7 libdispatch.dylib 0x37ecdc6f _dispatch_client_callout + 22
8 libdispatch.dylib 0x37ed9553 _dispatch_main_queue_callback_4CF$VARIANT$mp + 1322
9 CoreFoundation 0x295ac889 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 8
10 CoreFoundation 0x295aafa9 __CFRunLoopRun + 1512
11 CoreFoundation 0x294f69a1 CFRunLoopRunSpecific + 476
12 CoreFoundation 0x294f67b3 CFRunLoopRunInMode + 106
13 GraphicsServices 0x30e911a9 GSEventRunModal + 136
14 UIKit 0x2cca7635 UIApplicationMain + 1440
15 libxpc.dylib 0x3806f9e3 _xpc_objc_main + 706
16 libxpc.dylib 0x38071009 xpc_main + 168
17 Foundation 0x2a3ec289 service_connection_handler + 162
18 PlugInKit 0x32c5ff75 -[PKService run] + 508
19 PlugInKit 0x32c5fc4b +[PKService main] + 58
20 PlugInKit 0x32c5ffa9 +[PKService _defaultRun:arguments:] + 20
21 libextension.dylib 0x371b60c5 NSExtensionMain + 48
22 libdyld.dylib 0x37f0baaf start + 2
In the left column where it lists the libraries (correct term?) I don't see any reference to my code. In other crash logs there is always some reference to a class in my app or something but I don't see that in this one. What does that mean? Is the crash occurring before my code executes and this is an Apple issue I can ignore?
It's an Apple Bug. The keyboard extension I work on has a nearly identical crash report. Fortunately, this only seems to happen on iOS 8, though I have seen a similar one that affects iOS 9.
I would file a bug report with Apple, and include a copy of the stack trace.

I get some layout constraints error in iOS

I get some error log info,But the position is not the position code, can you help me to point out the cause of the problem
Below is the details of the crash log, I can't find more position the code, what's the problem.
detail crash log:
The layout constraints still need update after sending -updateConstraints to <_UIKeyboardLayoutAlignmentView: 0x13e6ea660; frame = (0 0; 0 0); userInteractionEnabled = NO; layer = <CALayer: 0x17443ffe0>>.
_UIKeyboardLayoutAlignmentView or one of its superclasses may have overridden -updateConstraints without calling super. Or, something may have dirtied layout constraints in the middle of updating them. Both are programming errors.
(null)
(
0 CoreFoundation 0x0000000185d602f4 <redacted> + 160
1 libobjc.A.dylib 0x000000019758c0e4 objc_exception_throw + 60
2 CoreFoundation 0x0000000185d60218 <redacted> + 0
3 UIKit 0x000000018ae64748 <redacted> + 448
4 UIKit 0x000000018ae64880 <redacted> + 136
5 CoreFoundation 0x0000000185c40cdc CFArrayApplyFunction + 68
6 UIKit 0x000000018ae64620 <redacted> + 152
7 UIKit 0x000000018ae64880 <redacted> + 136
8 CoreFoundation 0x0000000185c40cdc CFArrayApplyFunction + 68
9 UIKit 0x000000018ae64620 <redacted> + 152
10 UIKit 0x000000018ae64880 <redacted> + 136
11 UIKit 0x000000018a89b7b4 <redacted> + 104
12 Foundation 0x0000000186bc1308 <redacted> + 176
13 UIKit 0x000000018a89b4d0 <redacted> + 212
14 UIKit 0x000000018a8b7e04 <redacted> + 104
15 UIKit 0x000000018ae64be4 <redacted> + 180
16 UIKit 0x000000018a7b2140 <redacted> + 588
17 UIKit 0x000000018ac71bd0 <redacted> + 792
18 UIKit 0x000000018aaa8fb0 <redacted> + 1860
19 UIKit 0x000000018a824240 <redacted> + 356
20 UIKit 0x000000018a7946ec <redacted> + 536
21 CoreFoundation 0x0000000185d182a4 <redacted> + 32
22 CoreFoundation 0x0000000185d15230 <redacted> + 360
23 CoreFoundation 0x0000000185d15610 <redacted> + 836
24 CoreFoundation 0x0000000185c412d4 CFRunLoopRunSpecific + 396
25 GraphicsServices 0x000000018f4576fc GSEventRunModal + 168
26 UIKit 0x000000018a806fac UIApplicationMain + 1488
27 Myapp 0x1001803b0 Myapp + 1573808
28 libdyld.dylib 0x0000000197c0aa08 <redacted> + 4
)
dSYM UUID: B1FB72DD-A4D0-3ABA-BF95-9FCD83749770
CPU Type: arm64
Slide Address: 0x0000000100000000
Binary Image: Myapp
Base Address: 0x00000001000f0000
If you implemented updateConstraints you need to call [super updateConstraints]; within your implementation.
See https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIView_Class/index.html#//apple_ref/occ/instm/UIView/updateConstraints
UPDATE:
_UIKeyboardLayoutAlignmentView is an Apple internal keyboard view. Most likely something is crashing while it is presented.
See this Radar (Apple bug report) and these answers for a potential solution.
The bug seems to be iOS 8.3 specific.
https://openradar.appspot.com/20615507
NSInteralInconsistencyException - UIKeyboardLayoutAlignmentView
iOS 8.3 UIAlertController crashes when trying to add a textfield

UIButton _setTitleFrozen crash

I have weird crash related to UIButton class. I have not found anything similar on SO yet. The log I get comes from Crashlytics so I also don't know which part of code is causing the issue. I put crash log below, may be some of you have already found out what is creating the problem.
EXC_BAD_ACCESS KERN_INVALID_ADDRESS at 0xd1712d18
0 libobjc.A.dylib objc_msgSend + 5 _setTitleFrozen:
1 UIKit 32-[UIButton _beginTitleAnimation]_block_invoke853 + 28
2 UIKit -[UIViewAnimationBlockDelegate_didEndBlockAnimation:finished:context:] + 308
3 UIKit -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 184
4 UIKit -[UIViewAnimationState animationDidStop:finished:] + 70
5 QuartzCore CA::Layer::run_animation_callbacks(void*) + 234
6 libdispatch.dylib _dispatch_client_callout + 22
7 libdispatch.dylib _dispatch_main_queue_callback_4CF$VARIANT$mp + 712
8 CoreFoundation __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE_ + 8
9 CoreFoundation __CFRunLoopRun + 1512
10 CoreFoundation CFRunLoopRunSpecific + 476
11 CoreFoundation CFRunLoopRunInMode + 106
12 GraphicsServices GSEventRunModal + 136
13 UIKit UIApplicationMain + 1440
Changing the button type from System to Custom resolved this crash for me.
In my case this crash occurred because I was changing the button title right before removing it from the view hierarchy (by dismissing its parent view's VC) while the title change animation was still running.

Resources