简体   繁体   中英

How to debug a crash which happened when come back from background

There is a crash happen when coming back from background through app icon.

However I cannot see any detail info in console log. There is a signal to terminate, but we cannot find signal number.

<FBApplicationProcess: 0x117bcb930; Maixxxx; pid: 1762> exited abnormally via signal.

Process exited: <FBApplicationProcess: 0x117bcb930; Maixxx; pid: -1> -> <FBApplicationProcessExitContext: 0x17103f820; exitReason: signal; terminationReason: (none)>

控制台日志

The procedures to reproduce my crash is as follow:

  1. Start app through click on app icon.
  2. Use the app as normal user.
  3. Press home to put it in background.
  4. Wait for some minutes.
  5. Click the app icon on springboard screen in order to use it again.
  6. The app crash&exit.

Since the crash only happen when coming back from background, and required to enter background for some minutes, I cannot run in debug mode with lldb attached.

I didn't use any of background features.

Also, I didn't see any crash report in Fabric's Crashlytics. So I think signal handler could not be called neither?

How to investigate this kind of problem?

These things can be tough, I know that from similar experiences. Without knowing more about your app I can only offer hints and no definitive answer, but perhaps this helps you.

The fallback and tedious approach to use direct logging with print and so on notwithstanding there are a two ways to try to "catch" a process.

However, first let me stress that "background" is not always the same and people unfortunately use the term often loosely. Depending on what state transition causes your crash you might run out of luck and have to simply experiment using manual logging. Apps can be in background, ie not in the foreground, but still running. This is usually the case when the debugger is attached, otherwise it couldn't do its job. Alternatively they can be suspended (or even terminated) by the OS. The debugger prevents this, which you probably already figured out.

The two things that might help you are:

  1. If you're using background fetch, ie "coming back from background mode" as you describe it happens automatically you can activate the "Launch due to a background fetch event" option in your build scheme's "Run" configuration section.

  2. Run your app from the Home screen, put it into background with the Home button and wait a bit (you've probably done so in the past already to get a feeling for when the crash would happen). Your app should eventually go into the suspended state (but you have no way to actually see that anywhere AFAIK). Instead of getting it to the foreground again via the multitasking UI, simply attach the debugger again via the "Debug - Attach to process" menu. This should get your app from the suspended state back into the background state, where the crash probably really happens (if it were to happen when coming from background to foreground you probably would have been able to debug it as usual). Hopefully the debugger has finished attaching to it in time, otherwise I'm out of ideas. :(

I haven't run into this specific problem myself personally, but I know background stuff can be tricky. Maybe this discussion also helps you (I took part of my info from there as well).

Run the app in debug mode on a real device. Press the Home button to send the app to background and continue the debugging. Then you can bring the app to foreground and keep debugging, or put a breakpoint at applicationWillEnterForeground.

You can't debug this on the real device. When the debugger is attached, your apps will never go to background mode in the real device.

You can try to debug this on a simulator. Anyway please check your class attributes and set attributes to strong to make sure this is not happened by missing attributes.

I have read several StackOverflow questions that have FBApplicationProcess. Usually, this one happened by missing array or something when the app started.

Best regards.

I have gone through all the above answers and all have given proper answers. Though, I would like to share my point of view.

  1. If the app is running on any iOS real device with debug mode and wire plug-in or even on Simulator, App will never go in the background.

  2. If the app is running without wire plug-in or run without Xcode(directly launch the app in iPhone) and then put the app in the background, the app will be running in the background of next 3 mins. After 3 mins, the App will automatically be suspended and removed from the main thread. Now, when we open the app again, It will be considered a fresh launch.

  3. If your app having any Background Capabilities ON, then your app will be alive even in the background, but you can't do any UI changes during that time.

  4. To keep app alive in the background, Background Capabilities must be handled properly. ie. If Location is used in your app with 'While-App is in Foreground' condition, app will not run more than 3 mins in background. So, If you want to run your app continuously in background, you must have to represent proper reason in Info.plist file with Battery drain word, or else, Apple will reject it.

  5. Ping me for more detail on your question.

Thanks.

Crash logs still available on your test device.

To get the crash log try the following steps:

  • Connect your test device to the Mac through USB.
  • Launch Xcode. Go to Windows > Devices and Simulators.
  • Choose your device from the devices section on the left side of the screen.
  • Select View Device Logs button.
  • Identify and select the Crash Log to see the contents.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM