Skip to content
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

iOS 15 sound does not resume when woken from sleep #3977

Closed
yaustar opened this issue Feb 3, 2022 · 6 comments · Fixed by #4062 or #4462
Closed

iOS 15 sound does not resume when woken from sleep #3977

yaustar opened this issue Feb 3, 2022 · 6 comments · Fixed by #4062 or #4462
Assignees

Comments

@yaustar
Copy link
Collaborator

yaustar commented Feb 3, 2022

Test Project: https://playcanvas.com/project/878048/overview/ios-15-sound-resume-issue

  • Set the autolock in settings to be 1m
  • Clear Safari Cache
  • Open https://playcanv.as/e/p/o6Ew3BtU/
  • Touch the screen to start playing sound
  • Wait to phone autolocks
  • Wait 20s
  • Unlock phone
  • Audio does not resume, even after touching the device

(Note, may take a few tries)

There's a script that is printing out the status of the context. When it locks, it has interrupted state and when it is unlocked, it prints 'running' which is odd. Do we need to create a new Audio Context because the old one is corrupted?

@yaustar
Copy link
Collaborator Author

yaustar commented Feb 14, 2022

Risen in priority as a vendor cannot pass a TRC with this bug

@yaustar
Copy link
Collaborator Author

yaustar commented Feb 18, 2022

Related issue with another JS library: goldfire/howler.js#1525

@yaustar
Copy link
Collaborator Author

yaustar commented Feb 18, 2022

Reading more into it, I don't think there's an easy solution to this. To get around this issue, we would have to recreate the entire sound system in PlayCanvas and the sound components in the scene when this happens

@mvaligursky
Copy link
Contributor

sounds similar to graphics engine handling context lost and restored events, where we need to re-create all graphics resources. Perhaps something similar is needed for sound.

@jpauloruschel
Copy link
Contributor

Reopening due to issue re-appearing: https://forum.playcanvas.com/t/ios-audio-not-resuming-after-standby/26408

@jpauloruschel jpauloruschel reopened this Jul 15, 2022
@jpauloruschel
Copy link
Contributor

I've been investigating this issue and here are my findings:

  • Issue occurs consistently 100% of the time on iPhone 13 Safari and Chrome;
  • Issue never occurs on any non-mobile device;
  • When issue occurs, WebAudio's AudioContext has a running state and successfully returns all .resume() requests;
  • There are 2 ways to programmatically determine the AudioContext is actually broken:
    • attempt to play any sound (which will succeed), but will actually never finish (onended event will never be fired)
    • query AudioContext.currentTime, which will have the same value forever

I believe the issue has something to do with PlayCanvas not correctly verifying if the AudioContext is unlocked before being used (which should not be done), leading to an undefined internal state in the browser's implementation. Currently still working on a way of fixing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants