We recently noticed that sometimes the sound of our games is not being resumed. This happens on our iOS devices if safari was minimized or the phone was on standby for about at least 20 seconds.
The project we used to reproduce this was the same as used in this ticket by @yaustar. The phone we’re using is an iPhone 12 with OS version 15.5. These are the steps we took to reproduce this issue:
Initially the audio context is suspended since the app waits for user interaction
Tap anywhere on the screen to resume the audio context. It is running and we can hear the audio
Minimize Safari and quickly reopen it. The context is suspended because of the visibility change. No audible sound
Tap anywhere on the screen to resume the context again. We can hear the audio again
Minimize Safari again, wait at least 20 seconds and reopen the browser. The console output tells us the context was not suspended but is still running. We can’t hear anything though.
We’re not sure what the cause for this issue is. Was this bug re-introduced by an update of the iOS version or the PlayCanvas engine? Are we missing something obvious, like a script or fix that we need to add to a project ourselves? Looking forward to hear your input on this
AFAIK, we haven’t had any changes to the audio system for a long while, not since the original bug was ‘fixed’. Joao was ill this week so I poke him when he is back
I managed to also reproduce the bug on iPhone 13, but we’ll need a bit more time to investigate. During my testing, I sometimes (apparently less than 50%) got a Failed to start the audio device exception thrown. Are you seeing this exception too?
From PlayCanvas side, the test case you mentioned was thoroughly tested back in March for the issue you linked (4062), and we have not changed any part of the Audio system that could have triggered this issue to re-appear. My only guess is a recent Safari update.
I’ll keep this post updated as soon as we know more.
Sorry, I didn’t notice any message like Failed to start the audio device. Was the bug only reproduceable when the exception was thrown, or did the bug also occur when you didn’t see it?
Thanks for looking into this, let me know if I can help.
I’m just wondering if you managed to find out more or had some progress on this?
Also how I can help in this if needed. Shall I create another issue on the repo, or reopen the one mentioned above? Or did you already open one, which I overlooked?
Feel free to test out this PlayCanvas build which uses a custom engine with the changes: sound resume issue - PLAYCANVAS and please let me know if you still encounter the bug.