Samsung, you suck.
Let me explain that! For my last two games, Space Grunts and Heroes of Loot 2, I developed the game as much for PC as I did for Android (and android based consoles). So I took some risks with adding more resources to my game. One of those resources are the sound-effects.
In Heroes of Loot 2 I ended up with about 75 sound-effects (excluding the music) and Space Grunts was also at 70+
No problems on the PC version, no problems on the iOS version and for the most part, no problems on Android devices. Sadly, after release the first reports started coming in: “The game freezes every few seconds”. If it’s just a few reports, like anything below 10, I’d normally say it has to do with other stuff running on the effected devices.
However, those reports started piling up pretty fast with all devices being Samsung based devices (mostly Galaxy, because those devices sold like free cookies). Strangely, I did notice that people running Android 6 on their Galaxy were rating my game 5/5 as awesome and problem free.
For some weird reason there is very little found on this problem on the internet. Searching for Samsung and freeze issues does come up with a lot of finger pointing at Samsung’s Touchwiz interface, but that didn’t seem related to the problems my game was having on Samsung devices.
Eventually I did stumble upon some more developer-based reports showing issues with sound. Some say using OGG instead of MP3 could fix it, others mentioned the rate and format of sound samples as a possible fix.
I tried all of these in short game updates on Android, but nothing seemed to fix the problem. Eventually I received some actual crash reports from users, and they all showed the strange thing that at the time of the game freezing the logs show that the “MediaPlayer” crashed and restarted (I can imagine this freezes the whole device for a second or so). Now of course searching for Samsung and Media player brings up a lot of media playing apps, but nothing about the actual MediaPlayer service (great naming there Google!).
When I ask the players to first turn off the sound-effects in the game menu, and then play, they all told me that freezes were gone.. so.. there’s a clue!
Not sure where I found the final solution to this, but I eventually stumbled onto another thread about issues on Samsung devices and someone there mentioned a “known bug” that these devices can’t handle more than 32 sound effects. Personally I think it has more to do with the combined size of those sounds, but it does sound like a good point to start looking. My older games like Gunslugs and Gunslugs 2 use far less sounds and they never had issues either.
Few days ago I added some code to Heroes of Loot 2 that detects a Samsung device running something older than Android 6 (that’s a lot of them) and then simply disables the loading and playing of various sound effects. It means the game is slightly crippled, but it’s a lot more entertaining for the end-user who won’t notice missing sounds unless they play on another device and there are far less freezes (in some cases even none).
The positive side is that it seems that Samsung finally fixed it in their Android 6 builds, and as soon as they upgrade their devices it should be a historical bug, but until then: I’ll just limit the amount of sound effects on Samsung.
One more note on this. I’m using the standard Android SoundLoop code for my games. There are possibly solutions and engines like Unity, that use openAL and thus don’t run into these issues (hence players always telling me such and such game had no issues and looked much more graphical then mine). But for most Java programmers, Android’s SoundLoop is still, sadly, the best and only solution.