New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AudioSessionException on iOS 8.4 #4119
Comments
Seems fixed on ios9, i have no crashes on that platform for 5 days. |
While this is fixed in iOS 9, it still occurs in iOS 7 and 8, which has a large install base for a while. Any info on why this might be happening? |
I've found somewhat of a workaround. The crash occurs in the AudioSession.SetActive(true) call, as indicated by the previous post. I played around with it a bit and found out that if I try/catch and consume the exception, the app will continue, but no more audio plays:
Of course that's only a half-solution because it does mean the game is silent until the user relaunches the app. I continued to mess around with it and I found that if I got a crash, I could detect that and delay the re-activation of the Audio Session as follows:
Sure enough that solved it, but it does add a delay to the resuming of the app. In my opinion it's a valid workaround because I think a 1 second delay (which maybe could be reduced) is better than a crash which cannot be caught in the game code. If the powers that be consider this a valid fix to the problem, then I can check it in. To be clear, this issue is only an issue on iOS 7 and 8, so iOS 9 devices should never be impacted by this restart delay, and as they are phased out, this issue will also go away. Shall I PR it? Update: 500 milliseconds seems to work on my iPad 3, 250 did not. Hard to say what time we should put in there though as it may depend on device. I'd say 500 - 1000 milliseconds. |
Have you tried to monitor the |
When returning from background, sometimes AudioToolbox throws an exception. Here's stack trace (sorry for lack of lines and file names - data is from BugSense):
The text was updated successfully, but these errors were encountered: