Search code examples
androidcocos2d-xsoundpool

Sound Related Crashes on Wildfire S w/ cocos2dx


I am having trouble with a frequent crash on the HTC Wildfire S related to sound (there are similar looking, but less frequent, crashes on other devices like Thunderbolt). I have tried a wide variety of things to fix it, or at least learn more about what exactly the problem is without luck.

I am certain the issue is related to sound. When I comment out SoundPool.play() the issue disappears. I don't think it is SoundPool specific since I have tried using OpenSL ES instead which did not reduce the crashes.

I also have a hard time accepting that it is necessarily an issue with lower level sound since it only happens on this title; but not (as far as I have been able to establish) on other games built with the same sound code. In addition I have found virtually no evidence of others experience the same issue.

However game specific things I could think of that would lead to this (lots of simultaneous sounds, frequent sounds, sound format) do not seem to be a problem (I have reduced to only a single sound at a time, switch to WAV, smaller files, OGG, ignore without blocking sounds that happen to recently from another sound).

Our common code is built on top of cocos2dx, and it appears (although I am not wholly convinced) that the crash increased with an adjustment in *Cocos2dxSound.java* so that it would only sleep the main thread after SoundPool.play(...) returned 0 the first time.

Also, in case it could be an issue, some sounds come from the APK are downloaded after installation.

Any ideas or suggestions are greatly appreciated; this has taken way longer than it should have.


Solution

  • The issue was due to an unrelated issue. When sounds played it exposed the problem. Unsure what about playing did it; but we suspect playing the sound for whatever reason was putting most low/mid range phones over the edge for memory (ndk-profiler was recently checked in, however it was not disabled when checked in so it was still profiling).