Little things can add a lot of otherwise unnoticed polish to the apps we use and the games we play on a daily basis. Thanks to animations, sound effects, music, and custom graphics, our software tends to feel more responsive and engaging. But sometimes a bug comes along and breaks a part of that experience. Today, we're going to take a look at one of the more user-facing bugs to sneak out with Android 4.3: automatically looping sounds are broken in numerous apps.
The issue comes up when making a simple call to the play() method of the SoundPool class. One of the parameters passed in during the call will set the chosen sound to automatically repeat, either continuously or for a specific number of times. The problem in Android 4.3 is that the sound will only ever play once, regardless of how many repetitions are expected. This video demonstrates the correct behavior on a Nexus 7 with Android 4.2.2, followed by the bug on a Nexus 4 with Android 4.3:
If you would like to try this out for yourself, I've written another sample application to try on your own devices. Yes, that sound in the video is of a windshield being broken. I've also uploaded the source code to Github.
This issue won't affect all apps and games because developers have a few options for generating sound. Many music players are likely to rely on the MediaPlayer class because it handles most of the heavy lifting for different formats, large files, and streaming over a network. Most game developers working with the NDK (Native Development Kit) are more likely to need very precise timing and minimal overhead, which means they will reach for OpenSL ES (the audio counterpart to OpenGL ES). But developers who simply need some background music and a few sound effects can take advantage of SoundPool, which is both easy to use and generally lightweight. Optionally, the AudioTrack class offers a bit more control at the cost of simplicity, and is actually what SoundPool uses behind the scenes.
Don't be too concerned about this bug, the Android team has already acknowledged the issue and posted a fix. Technically, the problem was located in the underlying AudioTrack class, but circumstances for hitting it were exposed due to the popular use of SoundPool. As noted by the Android team, developers may want to consider creating workarounds for devices running 4.3, which probably means programming manual looping routines of their own. Fortunately, of the relatively small pool of devices running Android 4.3 this early, all of them should progress to 4.3.1 shortly after it rolls out, ultimately eradicating the issue.
For now, be a bit forgiving of apps and don't be too surprised if things like background sounds go mysteriously silent. Like most transient bugs of this nature, they will be short-lived and easily forgotten. Try to give developers a bit of time to find solutions, and hope for Google's engineers to launch an update swiftly. Meanwhile, take another opportunity to enjoy some of the great new features Android 4.3 has to offer.[AOSP Issue Tracker #58113, Bug Fix]