Crash happening when the application is going to background

0

I dont know how to repro this crash but is is happening a lot. The stack shows that the application is going to background at #16 below.

I could not find any help regarding this crash.

When the application is going to background, why its trying to process keyboard tasks ? Lines #1-5 shows that its trying to do some keyboard tasks.

What might be happening here ?

#  1  _dispatch_barrier_sync_f_slow + 518 (libdispatch.dylib + 0x00010c68)        0x0
#  2  __88-[UIKeyboardLayout recognizer:releaseTouchToLayoutWithId:startPoint:endPoint:whenReady:]_block_invoke + 95 (UIKit + 0x004297fd)        0x0
#  3  __88-[UIKeyboardLayout recognizer:releaseTouchToLayoutWithId:startPoint:endPoint:whenReady:]_block_invoke + 93 (UIKit + 0x004297fb)  0x74cd0c8
#  4  -[UIKeyboardTaskQueue continueExecutionOnMainThread] + 393 (UIKit + 0x0003737d)  0x74cd0f8
#  5  __39-[UIKeyboardLayout resetHRRLayoutState]_block_invoke + 625 (UIKit + 0x0042a809)  0x74cd118
#  6  _dispatch_client_callout + 21 (libdispatch.dylib + 0x00001781)  0x74cd2b0
#  7  _dispatch_barrier_sync_f_invoke + 49 (libdispatch.dylib + 0x0000da33)  0x74cd2c0
#  8  -[UIKeyboardLayout resetHRRLayoutState] + 107 (UIKit + 0x0042a56b)  0x74cd2dc
#  9  +[UIKeyboardImpl applicationWillResignActive:] + 223 (UIKit + 0x0012fe35)  0x74cd304
# 10  __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 9 (CoreFoundation + 0x000a6db7)  0x74cd318
# 11  _CFXRegistrationPost + 381 (CoreFoundation + 0x000a66f7)  0x74cd320
# 12  ___CFXNotificationPost_block_invoke + 39 (CoreFoundation + 0x000a64df)  0x74cd35c
# 13  -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1241 (CoreFoundation + 0x00101307)  0x74cd378
# 14  _CFXNotificationPost + 539 (CoreFoundation + 0x0000a033)  0x74cd6f0
# 15  -[NSNotificationCenter postNotificationName:object:userInfo:] + 65 (Foundation + 0x000060ab)  0x74cd8bc
# 16  -[UIApplication _deactivateForReason:notify:] + 815 (UIKit + 0x00073e0f)  0x74cd8d0
# 17  __61-[UIApplication _sceneSettingsPreLifecycleEventDiffInspector]_block_invoke + 93 (UIKit + 0x00282255)  0x74cd908
# 18  __52-[FBSSettingsDiffInspector inspectDiff:withContext:]_block_invoke.27 + 165 (FrontBoardServices + 0x00020cfd)  0x74cd928
# 19  __NSIndexSetEnumerate + 437 (Foundation + 0x000af3df)  0x74cd9b8
# 20  -[NSIndexSet enumerateIndexesWithOptions:usingBlock:] + 65 (Foundation + 0x00030bcd)  0x74cda48
# 21  -[BSSettingsDiff inspectChangesWithBlock:] + 101 (BaseBoard + 0x00035a57)  0x74cda6c
# 22  -[FBSSettingsDiff inspectOtherChangesWithBlock:] + 89 (FrontBoardServices + 0x0001b025)  0x74cda98
# 23  -[FBSSettingsDiffInspector inspectDiff:withContext:] + 299 (FrontBoardServices + 0x00020b5b)  0x74cdab8
# 24  __70-[UIApplication scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke + 101 (UIKit + 0x00283427)  0x74cdb20
# 25  -[UIApplication scene:didUpdateWithDiff:transitionContext:completion:] + 823 (UIKit + 0x00283131)  0x74cdb50
# 26  -[UIApplicationSceneClientAgent scene:handleEvent:withCompletion:] + 411 (UIKit + 0x00588aa1)  0x74cdc18
# 27  __80-[FBSSceneImpl updater:didUpdateSettings:withDiff:transitionContext:completion:]_block_invoke + 209 (FrontBoardServices + 0x0000af65)  0x74cdc7c
# 28  __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 17 (FrontBoardServices + 0x00035c11)  0x74cdca8
# 29  -[FBSSerialQueue _performNext] + 219 (FrontBoardServices + 0x00035acb)  0x74cdcb8
# 30  -[FBSSerialQueue _performNextFromRunLoopSource] + 43 (FrontBoardServices + 0x00035db5)  0x74cdd94
# 31  __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 11 (CoreFoundation + 0x000b6fdb)  0x74cdda4
# 32  __CFRunLoopDoSources0 + 423 (CoreFoundation + 0x000b6b03)  0x74cddac
# 33  __CFRunLoopRun + 1159 (CoreFoundation + 0x000b4f4f)  0x74cdde8
# 34  CFRunLoopRunSpecific + 469 (CoreFoundation + 0x000080ed)  0x74cea88
# 35  CFRunLoopRunInMode + 103 (CoreFoundation + 0x00007f0f)  0x74ceb70
# 36  GSEventRunModal + 79 (GraphicsServices + 0x00009b3f)  0x74ceb98
# 37  UIApplicationMain + 149 (UIKit + 0x00071e81)  0x74cebb8
# 38  UIApplicationMain (ApplicationHooks.m:50) (MyApp + 0x0002235f)  0x74cebdc
# 39  main (main.mm:18) (MyApp + 0x003a227f)  0x74cebfc
# 40  0x1b33a4e9 in start + 1 (libdyld.dylib + 0x000034e9)  0x74cec18

Thread 1:

#  1  0x1b40d808 in __psynch_cvwait + 24 (libsystem_kernel.dylib + 0x00015808)        0x0
#  2  0x1b4c3cb3 in _pthread_cond_wait + 561 (libsystem_pthread.dylib + 0x00002cb3)        0x0
#  3  0x1b4c5033 in pthread_cond_wait + 37 (libsystem_pthread.dylib + 0x00004033) 0x190e50a0
#  4  0x1be0ed7 in SyncCondition::Wait() (SyncSynchronization.h:592) (MyApp + 0x01ba9ed7) 0x190e50ac
#  5  0x1be0f0b in SyncCondition::WaitForDuration(unsigned long) (MyAppSync.cpp:469) (MyApp + 0x01ba9f0b) 0x190e50b4
#  6  0x446ebef in invocation function for block in wlm_dispatch_create_block_wrapper(void () block_pointer) (MyAppThread_objc.mm:203) (MyApp + 0x04437bef) 0x190e5e78
#  7  0x1b30d795 in _dispatch_call_block_and_release + 9 (libdispatch.dylib + 0x00001795) 0x190e5f24
#  8  0x1b31ab1b in _dispatch_queue_override_invoke + 535 (libdispatch.dylib + 0x0000eb1b) 0x190e5f30
#  9  0x1b31c1b3 in _dispatch_root_queue_drain + 325 (libdispatch.dylib + 0x000101b3) 0x190e5f58
# 10  0x1b31c00d in _dispatch_worker_thread3 + 105 (libdispatch.dylib + 0x0001000d) 0x190e5f90
# 11  0x1b4c28eb in _pthread_wqthread + 1039 (libsystem_pthread.dylib + 0x000018eb) 0x190e5fa0
# 12  0x1b4c24ca in start_wqthread + 6 (libsystem_pthread.dylib + 0x000014ca) 0x190e5fe0
ios
crash
crashlytics
asked on Stack Overflow Sep 21, 2017 by Rajendra Batta • edited Sep 21, 2017 by Rajendra Batta

1 Answer

1

Without knowing anything about your app: if it's using OpenGL, strictly UIKit, etc. And without knowing the exception type you're seeing or the use case that causes that, here are some things to consider.

If an app is crashing going into the background, especially when you don't see those crashes when debugging in Xcode (these are user crashes?), something to look at is what's happening as your app is going into the background, meaning applicationWillResignActive and applicationDidEnterBackground, but also any scheduled tasks (timers, async code that could be in flight, scheduled update loops, etc. Make sure you're shutting down anything that's not allowed in the background (OpenGL drawing for example), and stop/pause any long running tasks or do them in a background task using beginBackgroundTaskWithName/endBackgroundTask. And finally, make sure your code doesn't take long to return from applicationDidEnterBackground or the system will kill your app.

Some other things to realize are that backgrounding/resigning does not just happen by pressing the home button. Your app gets suspended when you pull down the Notification Center, go into the Touch ID alert authentication dialog, get a call, and so on. Maybe that will help you determine the scenario that's causing it.

The keyboard dropping is interesting and I think it indicates indicates that a view is getting an endEditing message or something like that when the view is becoming inactive. Do you have any code that executes when the keyboard dismisses? If so, again, make sure that's not doing anything you shouldn't do while backgrounded.

The fact that it's a UI crash made me think about something that's not directly related to backgrounding, and that's making UI calls on a thread other than the main thread, which isn't safe. Xcode 9 has a checker for that, so you might enable that and see if it finds anything. Those tend to be tricky things to track down and Xc9 helps a lot with that.

The crash logs you should be seeing in Xcode (from Apple) if this is a released app, or on the devices of people who are crashing, will have a lot more information than the two threads above. Just those two threads are not super useful for tracking this down. If you can get hold of a full symbolicated iOS crash log, this will probably be easier to figure out.

If you can make the crash happen, but not while debugging in Xcode, you can also run the app outside of Xcode, but pull up the Window>Devices and Simulators window and watch the device's system console when the crash occurs. Maybe there will be a hint there, like Springboard killing your app. You can also look at the logs after the fact (not live) in the same way. You'll need to isolate the time of the crash to know where to look in the system log, but the app crash logs on the phone should help.

answered on Stack Overflow Sep 21, 2017 by clarus

User contributions licensed under CC BY-SA 3.0