App crashing when re-opening fast

Hello,
Using Defold 1.2.188-beta, iOS 14.7.1

Encountering a weird issue:

  1. Open app
  2. Close it 1 second after open
  3. Re-open app
  4. App crashes with logs:
Thread 0 Crashed:
0   libsystem_kernel.dylib        	0x00000001c3051b54 __semwait_signal + 8
1   libsystem_c.dylib             	0x000000019fe1fab4 nanosleep + 212
2   libsystem_c.dylib             	0x000000019fe1f98c usleep + 64
3   Mygame                  		dmDeviceOpenAL::DeviceOpenALClose(void*) (in Mygame) (device_openal.cpp:137)
4   Mygame                  		dmSound::Finalize() (in Mygame) (sound.cpp:450)
5   Mygame                  		dmEngine::Delete(dmEngine::Engine*) (in Mygame) (engine.cpp:289)
6   Mygame                  		ShutdownEngine (in Mygame) (AppDelegate.m:133)
7   CoreFoundation                	0x00000001971efa10 __invoking___ + 144
8   CoreFoundation                	0x00000001970d1720 -[NSInvocation invoke] + 300
9   CoreFoundation                	0x00000001970d1c84 -[NSInvocation invokeWithTarget:] + 76

Strange thing is, it doesn’t happen when re-open the app after a longer time (~10 seconds). It seems that sounds are not closing properly when closing the app quickly after open.

Has anyone encountered this?

Interesting. We did make a few changes recently to avoid crashes if the sound device failed to creation, but I believe this is something else.

Thank you for also creating an issue on GH (https://github.com/defold/defold/issues/6116). I asked a follow-up question there.

OK I’m experimenting this exactly:

Some asynchronous activity is not being properly terminated in the backrgound. I suspect it has to do with the sound but I could be wrong.

Here is the complete crashlog:

My guess (but I could be wrong) is this sleep() function hanging up the app:

OK it gets even weirder:
In my current app, I get this problem only when downloaded from testflight.
If I build the app in debug OR in release, with a developer identity:

  1. I open the app
  2. After 1s I close it and kill it
  3. I open it back, everything works

On my testflight app:

  1. I open the app
  2. After 1s I close it and kill it
  3. I open it back, 0x"badfood" 0x8BADF00D crash (see blog article above).

Any pointer? I’m slowly losing my mind here :sweat_smile:

No idea really. Is TestFlight modifying the app somehow?

In any case, we’ll look into this ourselves as well.

I’m thinking, maybe if the app is from the store/testflight, the watchdog (the one mentioned related to the “badfood” crash) gets activated. I’m only guessing though.

1 Like

OK, turns out my app does crash also locally (ie. not from TestFlight). The crash happens when opening back the app, and the app restarts automatically, so it just looks like the app takes longer to open, whereas it’s actually crashing (I can see from the device logs).