Puzzling crash at application launch - ios

Many of my users get the crash describes in the below stack trace.
As you can read it seems to happen at the application launch and it does not involved any of our methods if we did not take into account the standard main call at line 28.
I do not know how to fix this bug as I do not manage to reproduce it and the below stack trace is not helpful for me.
The bug appears only on iOS9 (93% iOS9.2, 4% iOS 9.1.0, etc..)
Maybe someone know what to do in this case?
Thread : Crashed: com.apple.main-thread
0 libobjc.A.dylib 0x180911bd0 objc_msgSend + 16
1 Foundation 0x181b7b5f4 -[NSObject(NSKeyValueObservingPrivate) _changeValueForKey:key:key:usingBlock:] + 372
2 Foundation 0x181c2430c _NSSetPointValueAndNotify + 284
3 UIKit 0x18608e798 -[UIView(Geometry) _applyISEngineLayoutValues] + 656
4 UIKit 0x185f9b458 -[UIView(Geometry) _resizeWithOldSuperviewSize:] + 136
5 CoreFoundation 0x181188370 __53-[__NSArrayM enumerateObjectsWithOptions:usingBlock:]_block_invoke + 132
6 CoreFoundation 0x181188268 -[__NSArrayM enumerateObjectsWithOptions:usingBlock:] + 308
7 UIKit 0x185f89f8c -[UIView(Geometry) resizeSubviewsWithOldSize:] + 148
8 UIKit 0x18608e8e0 -[UIView(AdditionalLayoutSupport) _is_layout] + 128
9 UIKit 0x1862931f0 -[UIView(Hierarchy) _updateConstraintsAsNecessaryAndApplyLayoutFromEngine] + 756
10 UIKit 0x185f7f778 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 656
11 QuartzCore 0x18398eb2c -[CALayer layoutSublayers] + 148
12 QuartzCore 0x183989738 CA::Layer::layout_if_needed(CA::Transaction*) + 292
13 QuartzCore 0x1839895f8 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 32
14 QuartzCore 0x183988c94 CA::Context::commit_transaction(CA::Transaction*) + 252
15 QuartzCore 0x1839889dc CA::Transaction::commit() + 512
16 QuartzCore 0x1839820cc CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 80
17 CoreFoundation 0x181248588 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
18 CoreFoundation 0x18124632c __CFRunLoopDoObservers + 372
19 CoreFoundation 0x18124675c __CFRunLoopRun + 928
20 CoreFoundation 0x181175680 CFRunLoopRunSpecific + 384
21 GraphicsServices 0x182684088 GSEventRunModal + 180
22 UIKit 0x185fecd90 UIApplicationMain + 204
23 once 0x1000f0f00 main (main.m:14)
24 libdispatch.dylib 0x180d168b8 (Missing)
As an additional information I'm using AFNetworking. Here is the AFNetworking thread stack trace that does not crash:
Thread : AFNetworking
0 libsystem_kernel.dylib 0x180e194bc mach_msg_trap + 8
1 libsystem_kernel.dylib 0x180e19338 mach_msg + 72
2 CoreFoundation 0x181248ac0 __CFRunLoopServiceMachPort + 196
3 CoreFoundation 0x1812467c4 __CFRunLoopRun + 1032
4 CoreFoundation 0x181175680 CFRunLoopRunSpecific + 384
5 Foundation 0x181b6d21c -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 308
6 Foundation 0x181bc2874 -[NSRunLoop(NSRunLoop) run] + 88
7 once 0x1001ddf9c +[AFURLConnectionOperation networkRequestThreadEntryPoint:] (AFURLConnectionOperation.m:169)
8 Foundation 0x181c53c40 __NSThread__start__ + 1000
9 libsystem_pthread.dylib 0x180efbb28 _pthread_body + 156
Maybe it could help.
Thank you for your help!

I found another entry in SO with a stack that's eerily similar to yours. There was a resolution involving the removal of a setTranslatesAutoresizingMaskIntoConstraints:NO in a subview.
issue with reentering of view with [UIView(Geometry) _applyISEngineLayoutValues] in iOS8 but not iOS7
At application startup, this could only be your main view controller or the launchScreen if you have a xib/storyboard for it.

Related

SwiftUI - Fatal Exception: NSInternalInconsistencyException

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.
I am getting these occasional crashes in Firebase Crashlytics which I can't fathom out or reproduce (I'm new to debugging). Here is some of the info logged in Crashlytics but I can't see anything that looks familiar or that points to where its happening.
I'm guessing that something has happened in the background thread that shouldn't have but I have no idea where this is occurring in the app, hence I have not included any code.
Is there anything hidden in this list that I am missing that may give more of a clue? There are more threads listed in Crashlytics if needed but not much is in them.
Thanks in advance.
Fatal Exception: NSInternalInconsistencyException
0 CoreFoundation 0xa248 __exceptionPreprocess
1 libobjc.A.dylib 0x17a68 objc_exception_throw
2 CoreAutoLayout 0xde84 NSISLinExpReplaceVarWithVarPlusDelta
3 CoreAutoLayout 0x4e60 -[NSISEngine withBehaviors:performModifications:]
4 UIKitCore 0xac03c __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke
5 UIKitCore 0xd4544 -[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]
6 UIKitCore 0xd4154 __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke
7 UIKitCore 0x1022750 -[UIView _postMovedFromSuperview:]
8 UIKitCore 0x1ed38 -[UIView(Internal) _addSubview:positioned:relativeTo:]
9 UIKitCore 0x508b88 -[_UITextLayoutCanvasView textViewportLayoutController:configureRenderingSurfaceForTextLayoutFragment:]
10 UIFoundation 0xb299c __48-[NSTextViewportLayoutController layoutViewport]_block_invoke_4
11 UIFoundation 0x5f720 __80-[NSTextLayoutManager enumerateViewportElementsFromLocation:options:usingBlock:]_block_invoke
12 UIFoundation 0x36ea8 __83-[NSTextLayoutManager enumerateTextLayoutFragmentsFromLocation:options:usingBlock:]_block_invoke_2
13 CoreFoundation 0xa760 __NSARRAY_IS_CALLING_OUT_TO_A_BLOCK__
14 CoreFoundation 0x378ec -[__NSSingleObjectArrayI enumerateObjectsWithOptions:usingBlock:]
15 UIFoundation 0x36b78 __83-[NSTextLayoutManager enumerateTextLayoutFragmentsFromLocation:options:usingBlock:]_block_invoke
16 UIFoundation 0x20210 -[NSTextLayoutManager enumerateTextLayoutFragmentsFromLocation:options:usingBlock:]
17 UIFoundation 0x1ff70 -[NSTextLayoutManager enumerateViewportElementsFromLocation:options:usingBlock:]
18 UIFoundation 0x1fa88 -[NSTextViewportLayoutController layoutViewport]
19 UIKitCore 0x316d0 +[UIView(Animation) performWithoutAnimation:]
20 UIKitCore 0x8af4 -[_UITextLayoutCanvasView layoutSubviews]
21 UIKitCore 0x4cec -[UIView(CALayerDelegate) layoutSublayersOfLayer:]
22 QuartzCore 0xa4e8 CA::Layer::layout_if_needed(CA::Transaction*)
23 QuartzCore 0x1db9c CA::Layer::layout_and_display_if_needed(CA::Transaction*)
24 QuartzCore 0x2f098 CA::Context::commit_transaction(CA::Transaction*, double, double*)
25 QuartzCore 0x663c4 CA::Transaction::commit()
26 QuartzCore 0xb6658 CA::Transaction::release_thread(void*)
27 libsystem_pthread.dylib 0x1bd8 _pthread_tsd_cleanup
28 libsystem_pthread.dylib 0x4674 _pthread_exit
29 libsystem_pthread.dylib 0x10e0 pthread_main_np
30 libsystem_pthread.dylib 0xe80 _pthread_wqthread
31 libsystem_pthread.dylib 0xb98 start_wqthread
com.apple.main-thread
0 libsystem_kernel.dylib 0xb48 mach_msg2_trap + 8
1 libsystem_kernel.dylib 0x13008 mach_msg2_internal + 80
2 libsystem_kernel.dylib 0x13248 mach_msg_overwrite + 388
3 libsystem_kernel.dylib 0x108c mach_msg + 24
4 CoreFoundation 0x7ae00 __CFRunLoopServiceMachPort + 160
5 CoreFoundation 0x7c044 __CFRunLoopRun + 1232
6 CoreFoundation 0x811e4 CFRunLoopRunSpecific + 612
7 GraphicsServices 0x1368 GSEventRunModal + 164
8 UIKitCore 0x3a2d88 -[UIApplication _run] + 888
9 UIKitCore 0x3a29ec UIApplicationMain + 340
10 SwiftUI 0x1dace8 OUTLINED_FUNCTION_895 + 2424
11 SwiftUI 0x137c24 block_copy_helper.1 + 388
12 SwiftUI 0x120b44 OUTLINED_FUNCTION_901 + 2804
13 MyApp 0x496c main + 4372253036 (<compiler-generated>:4372253036)
14 ??? 0x1d3e95948 (Missing)

EXC_BAD_ACCESS KERN_INVALID_ADDRESS iOS crash

I am getting below crash logs across all iOS versions. However, I am not able to figure out the exact cause of this. Is it something to do with accessing a de-allocated object? If yes, is there a way to replicate the scenario since I am not able to.
Crashed: com.apple.main-thread
0 libobjc.A.dylib 0x180771b90 objc_msgSend + 16
1 CoreGraphics 0x182574568 CGColorRetain + 28
2 CoreGraphics 0x182609088 CGGStateSetStrokeColor + 64
3 UIKit 0x186893698 -[UIKBHandwritingStrokeView drawRect:] + 692
4 UIKit 0x1862e2678 -[UIView(CALayerDelegate) drawLayer:inContext:] + 368
5 QuartzCore 0x183c16228 -[CALayer drawInContext:] + 260
6 QuartzCore 0x183c008ac CABackingStoreUpdate_ + 2432
7 QuartzCore 0x183d18360 ___ZN2CA5Layer8display_Ev_block_invoke + 52
8 QuartzCore 0x183bffa88 CA::Layer::display_() + 1368
9 QuartzCore 0x183be17a8 CA::Layer::display_if_needed(CA::Transaction*) + 228
10 QuartzCore 0x183be1494 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 44
11 QuartzCore 0x183be0ab8 CA::Context::commit_transaction(CA::Transaction*) + 252
12 QuartzCore 0x183be0818 CA::Transaction::commit() + 500
13 UIKit 0x186256ff4 _UIApplicationHandleEventQueue + 4980
14 CoreFoundation 0x1810b109c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
15 CoreFoundation 0x1810b0b30 __CFRunLoopDoSources0 + 540
16 CoreFoundation 0x1810ae830 __CFRunLoopRun + 724
17 CoreFoundation 0x180fd8c50 CFRunLoopRunSpecific + 384
18 GraphicsServices 0x1828c0088 GSEventRunModal + 180
19 UIKit 0x1862c2088 UIApplicationMain + 204
20 Smartphone 0x1000e0b78 main (main.m:13)
21 libdispatch.dylib 0x180b768b8 (Missing)
Also I am not able to figure out where exactly the crash is happening. Since I am getting these as part of release build.

SIGABRT ABORT in QuartzCore

I'm seeing crashlogs being generated containing the following call stack
Thread : Crashed: com.apple.main-thread
0 libsystem_kernel.dylib 0x38a0a1f0 __pthread_kill + 8
1 libsystem_pthread.dylib 0x38a74797 pthread_kill + 58
2 libsystem_c.dylib 0x389bafdd abort + 76
3 libsystem_malloc.dylib 0x38a32d67 free + 382
4 libobjc.A.dylib 0x3844e3ad object_dispose + 20
5 UIKit 0x305511ef -[UIViewAnimationState dealloc] + 174
6 libobjc.A.dylib 0x38456b6b objc_object::sidetable_release(bool) + 174
7 CoreFoundation 0x2dc2d93d CFRelease + 556
8 QuartzCore 0x30195635 CA::release_objects(X::List<void const*>*) + 16
9 QuartzCore 0x3019aad7 -[CAAnimation dealloc] + 54
10 libobjc.A.dylib 0x38456b6b objc_object::sidetable_release(bool) + 174
11 CoreFoundation 0x2dc2d93d CFRelease + 556
12 QuartzCore 0x3019d117 CA::Layer::run_animation_callbacks(void*) + 238
13 libdispatch.dylib 0x3892f81f _dispatch_client_callout + 22
14 libdispatch.dylib 0x3893649f _dispatch_main_queue_callback_4CF$VARIANT$mp + 278
15 CoreFoundation 0x2dcc78f1 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 8
16 CoreFoundation 0x2dcc61c5 __CFRunLoopRun + 1300
17 CoreFoundation 0x2dc30f0f CFRunLoopRunSpecific + 522
18 CoreFoundation 0x2dc30cf3 CFRunLoopRunInMode + 106
19 GraphicsServices 0x32b52663 GSEventRunModal + 138
20 UIKit 0x3057c16d UIApplicationMain + 1136
21 Domino M 0x000c125f main (main.m:14)
Other threads only show the AFNetworking library doing something.
How can I find and fix issues like this (the ones that don't seem to have anything to do with self written code)?

iOS app odd crashes [UINavigationController _startCustomTransition:]

I have my app in alpha test, and using fabric to capture the crash logs. I had encountered a crash, and I have the below trace but have no idea what is going on. I tried to reproduce it with Xcode, but hardly can reproduce.
Could any one help on this? or share some ideas?
Thread : Crashed: com.apple.main-thread
0 libsystem_platform.dylib 0x0000000197c7d8d4 OSAtomicCompareAndSwap32Barrier + 12
1 libobjc.A.dylib 0x0000000197468120 realizeClass(objc_class*) + 100
2 libobjc.A.dylib 0x000000019746c930 lookUpImpOrForward + 224
3 libobjc.A.dylib 0x0000000197477db8 _objc_msgSend_uncached_impcache + 56
4 UIKit 0x000000018b66bef4 -[UINavigationController _startCustomTransition:] + 972
5 UIKit 0x000000018b57d630 -[UINavigationController _startDeferredTransitionIfNeeded:] + 468
6 UIKit 0x000000018b57d3fc -[UINavigationController __viewWillLayoutSubviews] + 56
7 UIKit 0x000000018b57d37c -[UILayoutContainerView layoutSubviews] + 200
8 UIKit 0x000000018b4c5d2c -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 572
9 QuartzCore 0x000000018ae1d994 -[CALayer layoutSublayers] + 168
10 QuartzCore 0x000000018ae18564 CA::Layer::layout_if_needed(CA::Transaction*) + 320
11 QuartzCore 0x000000018ae18408 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 32
12 QuartzCore 0x000000018ae17c08 CA::Context::commit_transaction(CA::Transaction*) + 276
13 QuartzCore 0x000000018ae1798c CA::Transaction::commit() + 436
14 UIKit 0x000000018b4c7c48 _UIApplicationHandleEventQueue + 1700
15 CoreFoundation 0x0000000186cd29ec __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
16 CoreFoundation 0x0000000186cd1c90 __CFRunLoopDoSources0 + 264
17 CoreFoundation 0x0000000186ccfd40 __CFRunLoopRun + 712
18 CoreFoundation 0x0000000186bfd0a4 CFRunLoopRunSpecific + 396
19 GraphicsServices 0x000000018fd975a4 GSEventRunModal + 168
20 UIKit 0x000000018b52eaa4 UIApplicationMain + 1488
21 MCompass 0x00000001001631c8 main (main.m:16)
22 libdyld.dylib 0x0000000197ad2a08 start + 4
It is hard to tell without seeing some more details, but maybe this can help: http://aplus.rs/2013/beware-a-crashing-bug-lurks-with-uinavigationcontroller-transitions/

iOS - Determining the cause of a crash (from a crash report) in _WebTryThreadLock

I have been trying to figure out what is causing one of the top crashes in my iOS application. It looks like there is some layout happening on a background thread which is causing it to crash. Is there any way to determine what I might be doing that is triggering this relayout? I assume from the stack that it is related to a UIWebView when my app is being brought back into the foreground.
Other stackoverflow threads on the topic seem to mention things like triggering a table reload on a background thread. As far as I can see all the webView delegate methods get called on the main thread. Is there some case where this is not true or are there some other methods which get called on a background thread and I'm just not aware?
Web Thread - Crashed.
0 WebCore _WebTryThreadLock(bool) + 297
1 WebCore _WebTryThreadLock(bool) + 288
2 WebCore WebThreadLock + 66
3 UIKit -[UIWebDocumentView(UIWebDocumentViewTextSelecting) selectionBaseWritingDirection] + 10
4 UIKit -[UITextField _currentTextAlignment] + 86
5 UIKit -[UITextField _showsClearButtonWhenNonEmpty:] + 58
6 UIKit -[UITextField _textRectForBounds:forEditing:] + 678
7 UIKit -[UITextField editingRectForBounds:] + 52
8 UIKit -[UITextField editRect] + 70
9 UIKit -[UITextField layoutSubviews] + 1320
10 UIKit -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 258
11 QuartzCore -[CALayer layoutSublayers] + 214
12 QuartzCore CA::Layer::layout_if_needed(CA::Transaction*) + 460
13 QuartzCore CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 16
14 QuartzCore CA::Context::commit_transaction(CA::Transaction*) + 238
15 QuartzCore CA::Transaction::commit() + 316
16 QuartzCore CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 60
17 CoreFoundation __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 20
18 CoreFoundation __CFRunLoopDoObservers + 276
19 CoreFoundation CFRunLoopRunSpecific + 394
20 CoreFoundation CFRunLoopRunInMode + 104
21 WebCore RunWebThread(void*) + 444
22 libsystem_c.dylib pthread_start + 308
Main - Thread
0 libsystem_kernel.dylib __psynch_mutexwait + 24
1 libsystem_c.dylib pthread_mutex_lock + 392
2 WebCore _WebTryThreadLock(bool) + 336
3 WebCore WebThreadLock + 66
4 WebKit -[WebDatabasePauser applicationWillEnterForeground] + 16
5 CoreFoundation _CFXNotificationPost + 1426
6 Foundation -[NSNotificationCenter postNotificationName:object:userInfo:] + 72
7 UIKit -[UIApplication _sendWillEnterForegroundCallbacks] + 154
8 UIKit -[UIApplication _handleApplicationResumeEvent:] + 1094
9 UIKit -[UIApplication handleEvent:withNewEvent:] + 1292
10 UIKit -[UIApplication sendEvent:] + 72
11 UIKit _UIApplicationHandleEvent + 6154
12 GraphicsServices _PurpleEventCallback + 590
13 CoreFoundation __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 14
14 CoreFoundation __CFRunLoopDoSources0 + 212
15 CoreFoundation __CFRunLoopRun + 646
16 CoreFoundation CFRunLoopRunSpecific + 356
17 CoreFoundation CFRunLoopRunInMode + 104
18 GraphicsServices GSEventRunModal + 74
19 UIKit UIApplicationMain + 1120
20 AppName main.m line 23
It seems you are updating UI on the background thread, in your code add this line wherever you are updating your UI and you are fetching data on the background thread:
dispatch_async(dispatch_get_main_queue(), ^{
// Update data here
});
As soon as you, rather code feels that data is there on device and it's time to update the UI corresponding to new data then try and bring back main thread in action.
Hope it helps.

Resources