iOS Audio not resuming after standby

Hey hey :slight_smile:

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.

This was a known issue that we thought should have been fixed. Through some digging we found this post from last year which describes the same issue iOS audio context suspended on visibility change. We also found the MR that fixed this issue https://github.com/playcanvas/engine/pull/4062. Now we’re wondering why we’re still having this problem.

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:

  1. Initially the audio context is suspended since the app waits for user interaction
  2. Tap anywhere on the screen to resume the audio context. It is running and we can hear the audio
  3. Minimize Safari and quickly reopen it. The context is suspended because of the visibility change. No audible sound
  4. Tap anywhere on the screen to resume the context again. We can hear the audio again
  5. 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 :slight_smile:

Best Regards
AliMoe

@jpaulo Any ideas on this bug that won’t die :sweat:

Any updates on this matter? :sweat:

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

Hey!

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.

3 Likes

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.

1 Like

Thanks! Interestingly the bug is reproducible both with and without the exception.

Bumping this once

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?

I think it makes sense to re-open that issue (https://github.com/playcanvas/engine/issues/3977), which I just did. Still no concrete fix, though. I’ll keep the linked ticket updated.

3 Likes

This was a tricky one, but I just sent a fix for this: https://github.com/playcanvas/engine/pull/4462 I’m still running tests, but so far I have not been able to reproduce the issue :slight_smile:

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.

2 Likes

Awesome, thanks
I’m not gonna make it today anymore, but I will definetely try it out first thing tomorrow morning.

1 Like