2

My app is very similar to a fitness tracker and I have the following bug that I reproduced on iphone 5s and 5c: when I start tracking a run, under certain conditions, the application gets killed while running in the background.

The conditions seem to be:

  • as soon as I click on the start tracking button in the app, lock the screen after no more than 2 seconds
  • leave the application running in the background for 30 min at least.

I managed to get the crash log on the device, and symbolicate the report, but it doesn't give me any more hint. It just mentions generic react native js and ios classes where it receives the error.

I am using bugsnag to collect crash reports, but in that case it doesn't submit any report (maybe because the app gets killed and it hasn't time to submit the report).

  • Does someone has idea about what's going on?
  • Any idea about how to push the investigation further?
  • Anything significant that I missed from the crash log?

Thanks!

Interesting bits from the crash log:

Exception Type:  EXC_CRASH (SIGKILL)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note:  EXC_CORPSE_NOTIFY
Termination Reason: Namespace <0xF>, Code 0x8badf00d
Triggered by Thread:  0

xcrun atos -arch arm64 -o appDsyms/4C682DF9-82D7-342C-ABC3-6218A1EED4F6.dSYM/Contents/Resources/DWARF/MyApp -l 0x100074000 0x000000010007b2bc 0x00000001001452f4 0x0000000100145318 0x00000001000aba84

main (in MyApp) (main.m:16)
ksmachexc_i_handleExceptions (in MyApp) (KSCrashSentry_MachException.c:237)
ksmachexc_i_handleExceptions (in MyApp) (KSCrashSentry_MachException.c:233)
+[RCTJSCExecutor runRunLoopThread] (in MyApp) (RCTJSCExecutor.mm:211)

complete crash log

Jeremie
  • 1,267
  • 12
  • 33

1 Answers1

3

Took me ages to understand what was going on. Could never get anything from crashlogs or bugsnag.

Had to profile it on long periods of time with XCode to understand what was going on: I had a memory leak. And if your app is using too much memory, and running in the background, at some point iOS is going to consider it as a harmful app and simply kill it.

ISSUE

In short, the issue was that the retrieval of gps coordinates and display of the update on the UI (where I calculate distance spent, average speed, and other analytics) was bounded.

So redux actions were triggered in the background while there was no update to make on the UI. On top of that I was storing gps coordinates in redux store, which after some time, consisted in a huge array. This resulted in a lot of unnecessary processing + silly use of memory.

FIX

I fixed it by separating those

  • the retrieval and storage of gps coordinates (simply store coordinates in AsyncStorage, no computing action)

  • the update of the UI: update every sec the timer counting the time spent + check every 2sec if I had new gps coordinates and calculate analytics if so

RESULT

CPU and Memory usage dramatically reduced when app was active, simply because I stopped using redux to store large amounts of data (which it's not for, it's there just to store your UI state).

CPU and Memory usage became completely flat when app in background because I'm only storing stuff.

So my new knowledge on the subject!.. Be smart, separate concerns.. Profile over long periods. If you have any memory leak, think about where and how often you're storing data. If your app runs in the background, limit as much as possible what's going on at this stage (avoid redux updates, avoid computations, store to work on it later)

Community
  • 1
  • 1
Jeremie
  • 1,267
  • 12
  • 33