100% crash on galaxy s II I9100 caused by audio engine

100% crash on galaxy s II I9100 caused by audio engine
0.0 0


We’ve been getting frequent reports from users about our game crashing halfway through our tutorial on GT-I9100 devices, and we wasted considerable time trying to dig into it before finally just buying an I9100 and debugging locally. Once we had the device, it was nearly trivial to find out that it was caused by loading too many sound effects.

Now, on researching specifically that issue, it’s clear in http://www.cocos2d-x.org/projects/cocos2d-x/wiki/Use_OpenSL_ES_to_play_effect_on_Android that there’s a limit to 31 sound effects.

I have 2 points to make here:

  1. That limitation is hard to discover and causes an app crash.
  2. It should be very easy to build in safety checks to the OpenSLEngine.cpp. Either a system that tracks the loaded effects and unloads, the oldest when you try to play a new effect, or simply a system that stops playing new effects when you get over the limit. Lack of audio or more delays to play effects is a much preferred outcome over an app crash.

I’m going to be implementing a system to unload older effects, but I’ll be implementing it in JS,where it won’t be very useful to anyone not using JS Bindings. It’d probably be a very good idea for someone to implement some safety checks into the C++ code

Something like 50% of our app’s 1 star ratings were caused by this bug, and we’ve had to disable the I9100 for our last couple of releases.


What was your solution? I’m not sure if this is causing any of the issues with our game, but have only seen them occur with users who all have the GS2 (GT-I900). I’m wondering if since they’re somewhat random it may be an issue with playing sound effects (don’t technically preload, but if I remember correctly looking through CocosDenshion source I believe it preloads on first play).


I believe that a limitation to 31 sounds was put into the audio engine that’s used for the I9100. I think that just stops loading more sounds after reaching the limit though.

We’re using the JS bindings, so we just put a system in our js code that keeps track of what sounds are loaded, and unloads sounds that haven’t been used for a while when we get near the limit on # of effects.


Thanks, I’ll rule out this as crash, and look at the 31 limit unloading for future updates.