OpenAL randomly stops playing some sounds, can only fix with reboot
Asked Answered
U

1

17

THE APPS: Two Cocos2d universal iOS games with a large customer base.

THE PROBLEM: Several months back (in 2011) reports started coming in, sounds would randomly cut out, only some of the sounds would play in the app, others wouldn’t. This problem can ONLY be fixed by a device reboot.

IMPORTANT NOTES & DETAILS:

  • The SAME code and SAME sound files played fine for over a year with NO bug reports of this sort. I wish I could pinpoint a date, but I believe the problem started with an iOS update.

  • The bug is incredibly hard to reproduce. I have personally seen it once, but I have had no luck causing it again. Yet we get 1-2 support emails a day with the same issue, some of which come in the form a bad reviews. If I had to pull a number out of the air, I’d guess we’re looking at a 1 in 1000 incidence. It seems maybe more common on the iPad, but I’m not sure.

  • Restarting the device is the ONLY way to fix the problem. Restarting the app does nothing, deleting the app and reinstalling does nothing, has to be a power down and turn back on.

  • A few weeks ago in an attempt to blindly fix I dumped the Cocos2d Sound engine and switched one of the apps over to ObjectAL (another openAL based sound engine), hoping it might have fixed the problem. It did not, same issue is occurring. As you'd note, both of these are just interfaces for OpenAL.

  • The sound files themselves were converted from wavs to cafs using Apple’s recommend method ( https://developer.apple.com/library/ios/#codinghowtos/AudioAndVideo/_index.html ), although we also used the -c 1 flag to make them single channel.

  • Just to be clear, the bug has nothing to do with the usual sound issues (mute switch, volume). A portion of the sounds continue playing fine, but they will never all play again until the device is powered down and restarted.

If anyone has any ideas I’d all, I’d be very grateful for the help. I’m at wits end here trying to fix a persistent bug I can’t recreate and that appears to be caused by something outside my control.

Undrape answered 22/2, 2012 at 15:25 Comment(5)
Sounds like a deep lying bug in the OpenAL implementation for the iOS, possibly but not necessarily a hardware problem with the GPUnit in the A4. Why? Well, anything you could do wrong in code should be fixed with an application restart. I think you should explain that to your customers and file a bug report with Apple. Just for curiosity. If a user has both of your apps installed and one of them starts to show the problem, how does the other app behave? Ask the customers who are affected.Admetus
@peter: I may have the same problem, did you find any solution for it?Permalloy
Several years ago, when I reviewed Apple's OpenAL source, it was riddled with threading bugs and could easily be induced to fail by heavy tests (play 20 sounds a second, leave computer running overnight). Sounds like nothing's changed.Relativistic
I just changed the sound engine from CocosDenshion, the one within cocos2dx, to ObjectAL hope to fix the random sound lost issue and I just encountered the issue again. No luck for me.Proliferation
This issue can be consistently recreated. Play a loop of your sound files using openAL. Make sure your app is enabled for background mode audio. Play app and sound effects. Go to background. (Sound is still playing). Open another app that uses audio...(your app is now not playing sound). When you bring your app into foreground, the code for openAL will still be running but no sound appears. No errors either. The only way to get sound, without restarting device, is to do a proper dealloc (clean up everything) then proper init.Unilobed
H
3

I've had similar problems with OpenAL, as the commenters stated. We had spurious problems on different hardware and on different OS releases. Really, it was nearly impossible to reproduce. The only reason we even found out about the problem was the significant percentage of users who experienced crashes or other severe audio problems. We tried for months trying to make it work, but in the end the stability problems we experienced just weren't manageable. We ended up going with another library and took OpenAL completely out of the picture. I certainly would not recommend it for new projects.

Hexahydrate answered 31/8, 2013 at 16:19 Comment(1)
Do you have any suggested libraries to replace OpenAL?Proliferation

© 2022 - 2024 — McMap. All rights reserved.