Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

console log

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?

like image 275
xi.lin Avatar asked Jul 04 '19 01:07

xi.lin


People also ask

How do you debug a crashed application?

You can use the stack trace available in the report details if you are using Play Console or the output of the logcat tool. If you don't have a stack trace available, you should locally reproduce the crash, either by manually testing the app or by reaching out to affected users, and reproduce it while using logcat.


1 Answers

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, i.e. 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, i.e. "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).

like image 122
Gero Avatar answered Sep 27 '22 16:09

Gero