I am experiencing a strange app crash. I narrowed down the problem to one particular visual component. The app crashes when i navigate back and forth to the screen with this component several time. The strange thing is that same component does not cause crashes on another screen. The problem is that the app does not throw any error when running in debug more. The only thing I see is the crash report in device's log.
I am not sure what code from this component should I provide here. Thus, I will describe what it does in general words. Majority of the layout is coded in xib file which I am loading at runtime. This xib file has number of controls, and UIScrollView is one of the main container. At runtime, I am adding few more UIViews to this scroll view. I am also performing some custom drawing on main CALayer of these added UIViews.
It would be create if somebody can help me narrow down the problem. Also, how can I get more precise report if the issue does not throw any exceptions during debugging?
UPDATE1:
I did further investigations and I think the problem can be narrowed to possibly incorrect disposing. Very similar case is described here (the first comment under the answer). https://stackoverflow.com/a/5359686/3507404
UPDATE2:
It happened that the crash is related to CALayerDelegate. I narrowed down the issue to simple example here. CALayerDelegate disposing issue
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x3b9731f0 __pthread_kill + 8
1 libsystem_pthread.dylib 0x3b9dd792 pthread_kill + 54
2 libsystem_c.dylib 0x3b923fd8 abort + 72
3 MyApp 0x00568df4 mono_handle_native_sigsegv (mini-exceptions.c:2335)
4 MyApp 0x00571dd8 mono_sigsegv_signal_handler (mini.c:6744)
5 libsystem_platform.dylib 0x3b9d7f90 _sigtramp + 40
6 UIKit 0x3302635c -[UIView(Hierarchy) subviews] + 352
7 UIKit 0x331432d4 -[UIView(Hierarchy) _willRemoveSubviewWantingAutolayout:] + 44
8 UIKit 0x332c2056 __UIViewWillBeRemovedFromSuperview + 198
9 UIKit 0x33028af0 -[UIView(Hierarchy) removeFromSuperview] + 56
10 UIKit 0x3302b3b6 -[UIView dealloc] + 374
11 MyApp 0x005fb940 invoke_objc_method_implementation (monotouch-glue.m:1341)
12 MyApp 0x005fb998 monotouch_dealloc_trampoline (monotouch-glue.m:1383)
13 MyApp 0x005fb940 invoke_objc_method_implementation (monotouch-glue.m:1341)
14 MyApp 0x005fb780 monotouch_release_trampoline (monotouch-glue.m:1370)
15 MyApp 0x005fb4bc monotouch_release_managed_ref (monotouch-glue.m:1296)
16 MyApp 0x000f0fa0 (wrapper managed-to-native) MonoTouch.Foundation.NSObject:monotouch_release_managed_ref + 88
17 MyApp 0x000c6228 MonoTouch.Foundation.NSObject:ReleaseManagedRef (.pmcs-compat.NSObject.cs:197)
18 MyApp 0x000c658c MonoTouch.Foundation.NSObject/NSObject_Disposer:Drain (.pmcs-compat.NSObject2.cs:1320)
19 MyApp 0x00234d48 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 196
20 MyApp 0x00573eb4 mono_jit_runtime_invoke (mini.c:6610)
21 MyApp 0x005b00f2 mono_runtime_invoke (object.c:2827)
22 MyApp 0x005379f6 native_to_managed_trampoline_MonoTouch_Foundation_NSObject_NSObject_Disposer_Drain (registrar.m:135)
23 Foundation 0x311f7c6e __NSThreadPerformPerform + 382
24 CoreFoundation 0x307d9208 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 12
25 CoreFoundation 0x307d86d6 __CFRunLoopDoSources0 + 202
26 CoreFoundation 0x307d6eca __CFRunLoopRun + 618
27 CoreFoundation 0x30741eba CFRunLoopRunSpecific + 518
28 CoreFoundation 0x30741c9e CFRunLoopRunInMode + 102
29 GraphicsServices 0x3566865e GSEventRunModal + 134
30 UIKit 0x3308e148 UIApplicationMain + 1132
31 MyApp 0x000f6454 (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain + 268
32 MyApp 0x000d2468 MonoTouch.UIKit.UIApplication:Main (.pmcs-compat.UIApplication.cs:75)
33 MyApp 0x00059144 KarmaMobile.iOS.Application:Main (Main.cs:46)
34 MyApp 0x00234d48 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 196
35 MyApp 0x00573eb4 mono_jit_runtime_invoke (mini.c:6610)
36 MyApp 0x005b00f2 mono_runtime_invoke (object.c:2827)
37 MyApp 0x005b3c78 mono_runtime_exec_main (object.c:4052)
38 MyApp 0x005b3ac8 mono_runtime_run_main (object.c:3678)
39 MyApp 0x0056250c mono_jit_exec (driver.g.c:1009)
40 MyApp 0x005e69a0 main (main.m:489)
41 libdyld.dylib 0x3b8bdab4 start + 0
Related
I'm currently having production crashes reported by Firebase pointing to some auto-layout work being done on a background thread. While the fix would be obviously wrapping the offending code on a dispatch main block, we can't find anything pointing to that code.
This scenario seems particularly hard to reproduce - we haven't been able to reproduce it in development.
The crash seems to happen during / after launch, and it varies a little from user to user, which could mean some async work triggering it based on the variance. I checked all the threads provided by the stack trace and couldn't find anything meaningful.
This is the stack trace provided by Firebase - absolutely no mention of app code triggering that update. Wondering if anyone may have some insight.
Modifications to the layout engine must not be performed from a background thread after it has been accessed from the main thread.
Thread that crashes
Fatal Exception: NSInternalInconsistencyException
0 CoreFoundation 0x9270c __exceptionPreprocess
1 libobjc.A.dylib 0x14f04 objc_exception_throw
2 CoreAutoLayout 0x5000 -[NSISEngine withAutomaticOptimizationDisabled:]
3 CoreAutoLayout 0x9e00 -[NSISEngine _optimizeWithoutRebuilding]
4 CoreAutoLayout 0xbd2c -[NSISEngine optimize]
5 CoreAutoLayout 0x49b4 -[NSISEngine performPendingChangeNotifications]
6 UIKitCore 0x3331a0 -[UIView(Hierarchy) layoutSubviews]
7 UIKitCore 0x17c738 -[UIView(CALayerDelegate) layoutSublayersOfLayer:]
8 QuartzCore 0x3cedc CA::Layer::layout_if_needed(CA::Transaction*)
9 QuartzCore 0x2fc90 CA::Layer::layout_and_display_if_needed(CA::Transaction*)
10 QuartzCore 0x4367c CA::Context::commit_transaction(CA::Transaction*, double, double*)
11 QuartzCore 0x4c164 CA::Transaction::commit()
12 QuartzCore 0x9fa08 CA::Transaction::release_thread(void*)
13 libsystem_pthread.dylib 0x3da0 _pthread_tsd_cleanup
14 libsystem_pthread.dylib 0x6c18 _pthread_exit
15 libsystem_pthread.dylib 0x225c pthread_main_np
16 libsystem_pthread.dylib 0x1e98 _pthread_wqthread
17 libsystem_pthread.dylib 0x193c start_wqthread
Main thread trace
com.apple.main-thread
0 libsystem_kernel.dylib 0x14e0 mach_msg_trap + 8
1 libsystem_kernel.dylib 0x1b24 mach_msg + 76
2 CoreFoundation 0x7820 __CFRunLoopServiceMachPort + 372
3 CoreFoundation 0xbcac __CFRunLoopRun + 1180
4 CoreFoundation 0x1f6b8 CFRunLoopRunSpecific + 600
5 GraphicsServices 0x1374 GSEventRunModal + 164
6 UIKitCore 0x513e88 -[UIApplication _run] + 1100
7 UIKitCore 0x2955ec UIApplicationMain + 364
8 MyApp 0x671c main + 20 (main.swift:20)
9 ??? 0x102689ce4 (Missing)
My app is integrated with Fabric, and I was able to see crash stack traces for a long time. All of a sudden recently I noticed that the crash reports stopped making sense. All I see for my app stack trace is this:
Crashed: com.apple.main-thread
0 myApp 0x102a005b0 _hidden#5298_ (__hidden#5526_:499)
1 myApp 0x102a018e0 _hidden#5310_ (__hidden#5526_:346)
2 myApp 0x102a0f1e4 _hidden#5361_ (__hidden#5526_)
3 myApp 0x102bc00e0 _hidden#1801_ (__hidden#19024_)
4 libdispatch.dylib 0x180e48b24 _dispatch_call_block_and_release + 24
5 libdispatch.dylib 0x180e48ae4 _dispatch_client_callout + 16
6 libdispatch.dylib 0x180e89d60 _dispatch_main_queue_callback_4CF$VARIANT$armv81 + 964
7 CoreFoundation 0x1814ff070 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
8 CoreFoundation 0x1814fcbc8 __CFRunLoopRun + 2272
9 CoreFoundation 0x18141cda8 CFRunLoopRunSpecific + 552
10 GraphicsServices 0x1833ff020 GSEventRunModal + 100
11 UIKit 0x18b3fd78c UIApplicationMain + 236
12 myApp 0x10299bc14 main (__hidden#1255_:18)
13 libdyld.dylib 0x180eadfc0 start + 4
Fabric is not reporting any dSYMs missing or anything.
Does anyone know what's going on and how to fix this?
In my app, I have used one textfield. When tap on textfield the device keyboard will appear and than I type some text in that textfield. On that time the app get crashed in iPad Pro 11.2.5 version. I don't know why the app getting crashed because the same code works perfect in iPad Pro 10.3 version. Please review the my crash analytics report below
Crashed: com.apple.main-thread
0 libobjc.A.dylib 0x184410430 objc_msgSend + 16
1 CoreFoundation 0x18514513c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 20
2 CoreFoundation 0x1851446dc _CFXRegistrationPost + 420
3 CoreFoundation 0x185144440 ___CFXNotificationPost_block_invoke + 60
4 CoreFoundation 0x1851c1e24 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1408
5 CoreFoundation 0x18507ad60 _CFXNotificationPost + 380
6 Foundation 0x185aa7348 -[NSNotificationCenter postNotificationName:object:userInfo:] + 68
7 UIFoundation 0x18f8c4570 -[NSTextStorage processEditing] + 240
8 UIFoundation 0x18f8c41d8 -[NSTextStorage endEditing] + 92
9 UIKit 0x18e914368 -[UITextInputController _insertText:fromKeyboard:] + 488
10 UIKit 0x18e9136d0 -[UITextInputController insertText:] + 400
11 UIKit 0x18ead3518 -[UIFieldEditor insertFilteredText:] + 968
12 UIKit 0x18f3eb3a0 -[UITextField insertFilteredText:] + 104
13 UIKit 0x18e91343c -[UIKeyboardImpl insertText:] + 136
14 UIKit 0x18ebd735c -[UIKeyboardImpl performKeyboardOutput:] + 756
15 UIKit 0x18ebd665c __55-[UIKeyboardImpl handleKeyboardInput:executionContext:]_block_invoke_2 + 256
16 UIKit 0x18f431fac -[UIKeyboardTaskEntry execute:] + 192
17 UIKit 0x18e7975f0 -[UIKeyboardTaskQueue continueExecutionOnMainThread] + 384
18 Foundation 0x185baf2e4 __NSThreadPerformPerform + 340
19 CoreFoundation 0x18515b77c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
20 CoreFoundation 0x18515b6fc __CFRunLoopDoSource0 + 88
21 CoreFoundation 0x18515af84 __CFRunLoopDoSources0 + 204
22 CoreFoundation 0x185158b5c __CFRunLoopRun + 1048
23 CoreFoundation 0x185078c58 CFRunLoopRunSpecific + 436
24 GraphicsServices 0x186f24f84 GSEventRunModal + 100
25 UIKit 0x18e7d15c4 UIApplicationMain + 236
26 Q App 0x1050b756c main (main.m:16)
27 libdyld.dylib 0x184b9856c start + 4
As my crash reports, I didn't use NotificationCenter/observer in that screen. But the crash reports are showing in the NotificationCenter. Please Any know the solution for this ?
Note: The following is without knowing all required details because you did not provide any source code on how you implemented the feature nor does the crash report shown here contain any information about the exception code/signal being thrown.
The top frame shows the method objc_msgSend being invoked. This method is always used when the runtime tries to send a message (method) to an object. And crashes in this method usually mean the object doesn't exist any longer which means it was deallocated but your code still holds a reference.
So this looks like a memory management issue in your code. Without your actual implementation it is impossible to provide any meaningful help.
The best way to debug this is to run the app in debug mode and the device attached to Xcode and get more details. The Instrument tools can also help finding out where the problem is.
My app is working perfectly fine in development but switching to production / AdHoc release it crashes on the transition to the third UIViewController of my application flow.
Between the build there shouldn't be any difference. I have retrieved the log from the Devices window:
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x00000001000d49ac
Triggered by Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 MYAPP 0x00000001000d49ac 0x100010000 + 805292
1 UIKit 0x00000001868a8954 -[UIViewController loadViewIfRequired] + 688
2 UIKit 0x00000001868a8664 -[UIViewController view] + 28
3 UIKit 0x0000000186f9c1cc -[_UIFullscreenPresentationController _setPresentedViewController:] + 72
4 UIKit 0x0000000186ba378c -[UIPresentationController initWithPresentedViewController:presentingViewController:] + 116
5 UIKit 0x0000000186bbeb4c -[UIViewController _presentViewController:withAnimationController:completion:] + 1968
6 UIKit 0x0000000186bc0f64 __62-[UIViewController presentViewController:animated:completion:]_block_invoke + 116
7 UIKit 0x0000000186995c48 -[UIViewController presentViewController:animated:completion:] + 212
8 MYAPP 0x0000000100090dcc 0x100010000 + 527820
9 MYAPP 0x0000000100090bd0 0x100010000 + 527312
10 PromiseKit 0x000000010032a9f4 0x1002e8000 + 272884
11 PromiseKit 0x00000001002ee820 0x1002e8000 + 26656
12 libdispatch.dylib 0x00000001936c1990 _dispatch_call_block_and_release + 20
13 libdispatch.dylib 0x00000001936c1950 _dispatch_client_callout + 12
14 libdispatch.dylib 0x00000001936c6208 _dispatch_main_queue_callback_4CF + 1604
15 CoreFoundation 0x00000001820522e8 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 8
16 CoreFoundation 0x0000000182050390 __CFRunLoopRun + 1488
17 CoreFoundation 0x0000000181f7d1f0 CFRunLoopRunSpecific + 392
18 GraphicsServices 0x000000018b39f6f8 GSEventRunModal + 164
19 UIKit 0x000000018690e108 UIApplicationMain + 1484
20 MYAPP 0x00000001000be820 0x100010000 + 714784
21 libdyld.dylib 0x00000001936eea04 start + 0
What is bugging me:
There is a clear inconsistency between the environments I am working on.
The calls from MYAPP doesn't seem to be linked to any component / method call. I'm working with Swift maybe it does cause problem to resolve symbols. Which could make sense since PromiseKit calls are also unresolved.
I have no idea about how to debug this, not even about how to put log everywhere (because I wouldn't know how to get them).
Any help is welcome!
In Build settings, try changing Swift compiler -> Optimization Level -> Release to None. There's still a bug where sometimes the compiler messes up closures when optimizations are on. Maybe that's what's happening to you.
I have an app in the store that use LiveSDK API to log the user into OneDrive. The last release was pushed before iOS8 came out, but it works without problem with iOS8
Now I want to push an update (unrelated to OneDrive features) and I am using xcode 6.1.1 but testing the app I noticed that every time the user is authenticated into OneDrive the app will crash as soon as return from a segue or flipside view to the Main View.
I was able to isolate the issue to this line added in viewDidLoad:
self.liveClient = [[LiveConnectClient alloc] initWithClientId:APP_CLIENT_ID
delegate:self
userState:#"initialize"];
and I really followed the basic instructions on how to login that can be found here:
http://msdn.microsoft.com/en-us/library/dn631822.aspx#sign_the_user_in
The steps to reproduce the issue (on both thee device and the simulator) are the following:
a) app starts
b) click to the cloud service login button that will trigger a flipsideviewcontroller
c) log into OneDrive with the code provided by MS
d) go back to the main controller
e) CRASH!
The trace is the following:
#########################################################
*** First throw call stack:
(
0 CoreFoundation 0x028dd1e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x026598e5 objc_exception_throw + 44
2 CoreFoundation 0x0297a243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x028cd50b ___forwarding___ + 1019
4 CoreFoundation 0x028cd0ee _CF_forwarding_prep_0 + 14
5 CloudFella 0x0015c867 -[LiveConnectClientCore dealloc] + 48
6 libobjc.A.dylib 0x0266a692 _ZN11objc_object17sidetable_releaseEb + 268
7 libobjc.A.dylib 0x0266baeb -[NSObject release] + 25
8 CloudFella 0x00158af1 -[LiveConnectClient dealloc] + 44
9 libobjc.A.dylib 0x0266a692 _ZN11objc_object17sidetable_releaseEb + 268
10 libobjc.A.dylib 0x02669e81 objc_release + 49
11 libobjc.A.dylib 0x02669e3e objc_storeStrong + 39
12 CloudFella 0x00157b9d -[CFFlipsideViewController .cxx_destruct] + 249
13 libobjc.A.dylib 0x026582d4 _ZL27object_cxxDestructFromClassP11objc_objectP10objc_class + 128
14 libobjc.A.dylib 0x0265824f object_cxxDestruct + 20
15 libobjc.A.dylib 0x0266327a objc_destructInstance + 48
16 libobjc.A.dylib 0x026632ab object_dispose + 20
17 UIKit 0x01433d1a -[UIViewController dealloc] + 1854
18 UIKit 0x01430915 -[UIViewController release] + 89
19 libobjc.A.dylib 0x02669e97 objc_release + 71
20 libobjc.A.dylib 0x02656bf0 objc_setProperty_nonatomic + 48
21 UIKit 0x01a6167d -[_UIViewControllerOneToOneTransitionContext _setFromViewController:] + 47
22 UIKit 0x01a61490 -[_UIViewControllerOneToOneTransitionContext dealloc] + 43
23 libobjc.A.dylib 0x0266a692 _ZN11objc_object17sidetable_releaseEb + 268
24 libobjc.A.dylib 0x0266baeb -[NSObject release] + 25
25 UIKit 0x01a60834 -[_UIViewControllerTransitionContext completeTransition:] + 135
26 UIKit 0x01a7a5b1 -[UIViewControllerBuiltinTransitionViewAnimator transitionViewDidComplete:fromView:toView:removeFromView:] + 50
27 UIKit 0x01416137 -[UITransitionView notifyDidCompleteTransition:] + 345
28 UIKit 0x01415e61 -[UITransitionView _didCompleteTransition:] + 1333
29 UIKit 0x014181b7 -[UITransitionView _transitionDidStop:finished:] + 107
30 UIKit 0x013666dc -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 267
31 UIKit 0x013669c8 -[UIViewAnimationState animationDidStop:finished:] + 80
32 QuartzCore 0x00fd6bb4 _ZN2CA5Layer23run_animation_callbacksEPv + 304
33 libdispatch.dylib 0x0326b4d0 _dispatch_client_callout + 14
34 libdispatch.dylib 0x03259726 _dispatch_main_queue_callback_4CF + 340
35 CoreFoundation 0x0294243e __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 14
36 CoreFoundation 0x028835cb __CFRunLoopRun + 1963
37 CoreFoundation 0x028829d3 CFRunLoopRunSpecific + 467
38 CoreFoundation 0x028827eb CFRunLoopRunInMode + 123
39 GraphicsServices 0x0301f5ee GSEventRunModal + 192
40 GraphicsServices 0x0301f42b GSEventRun + 104
41 UIKit 0x01316f9b UIApplicationMain + 1225
42 CloudFella 0x000eeea6 main + 94
43 libdyld.dylib 0x034af6d9 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
#
If I log into the other cloud services available in my app (Google drive , dropbox, evernote) I got no issues at all.
The problem is happening with both the old LiveSDK API (the one included in the current good release out in the store) and the newest build (2 months old) added to the app to solve some validation issues described here: https://github.com/liveservices/LiveSDK-for-iOS/issues/43
I suspect that going from Xcode 5 to xcode 6 something changed in the building parameters that is causing the issue, however I am not sure where the issue is and how to workaround.
As test I forced building the app for 32 bit architectures only but it crashed as well: this was expected as the LiveSDK API is compatible with 64 bit arch, but certainly wanted to try... .
Any help is greatly appreciated.
Thanks,
dom
Turns out this may be indeed a bug on the liveSDK.
Opened the following issue:
https://github.com/liveservices/LiveSDK-for-iOS/issues/53
and another API user (https://github.com/sylverb) that ran into the same issue gave me a good workaround until the bug is fixed:
"It was crashing because of "[authRefreshRequest cancel];" in the release method of LiveConnectClientCore.m . I had a temporary fix by adding "self" at this line in refreshSessionWithDelegate method (also in LiveConnectClientCore.m) :
self.authRefreshRequest = [[[LiveAuthRefreshRequest alloc] initWithClientId:_clientId
scope:_scopes
refreshToken:refreshToken
delegate:delegate
userState:userState
clientStub:self]
autorelease];
"
Closing the post as solved because a workaround is provided and I added a link to the open bug opened for any other user that wants to follow up on this issue.