Since we upgraded from FMOD 2.02.28 to 2.03.14 in July, our Android app has been crashing now and then when it goes to the background. It’s a segmentation fault inside sem_post in the system C library. The code that calls it isn’t visible in our crash reports, but everything points to FMOD. So far it’s been about 50 crashes across several device types and Android versions. We never saw it on 2.02.28, and it doesn’t happen on iOS or Windows.
The odd part is that it doesn’t seem to depend much on what we do when the app goes to the background. We’ve tried three approaches, and all of them crashed:
- Only muting the master channel group. No
mixerSuspendat all. - Calling
mixerSuspend()when going to the background, andmixerResume()when coming back. - Calling
flushCommands()first, thenmixerSuspend(), with nothing else of ours touching FMOD at the same time. Here our logs show the crash happening within a few milliseconds ofmixerSuspendstarting. OftenmixerSuspendstill returns OK afterwards, so it looks like another thread is the one crashing.
The third case sounds a lot like Crash in mixerSuspend. But since we also saw it with no mixerSuspend at all, we suspect the same problem can be hit some other way as well, maybe when FMOD rebuilds its audio output on its own.
Following the suggestion in that thread, our latest release pauses the master channel group on Android instead of suspending the mixer:
// Going to the background
coreSystem.getMasterChannelGroup(out ChannelGroup master);
master.setPaused(true);
// Coming back
master.setPaused(false);
It’s too early to say how much that helps. Given case 1, our guess is that it will reduce the crashes but not get rid of them completely. We’ll post an update once we have more data.
It would be great to hear when the fix from the other thread is expected to land. If our case 1 sounds like something that fix wouldn’t cover, we’re happy to help track it down.