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

Fix mute button getting stuck on iOS #14178

Merged

Conversation

docEdub
Copy link
Contributor

@docEdub docEdub commented Aug 18, 2023

On iOS, if AudioEngine.unlock() is called from any other event handler than a click event handler, then the promise returned by audioContext.resume never resolves and the audio engine _tryToRun flag never gets set back to false. This causes all subsequent calls to AudioEngine._triggerRunningState() to early out making it impossible to resume the audio context again.

This change fixes the issue by checking the _tryToRun flag. If it is true then the audio context is suspended and the _tryToRun flag is reset to false before attempting to resume the audio context.

Reported on forum: https://forum.babylonjs.com/t/unmute-icon-remove/257/25

Tested on iOS using playground https://playground.babylonjs.com/#35VF39#3

On iOS, if `AudioEngine.unlock()` is called from any other event handler than a `click` event handler, then the promise returned by `audioContext.resume` never resolves and the audio engine `_tryToRun` flag never gets set back to `false`. This causes all subsequent calls to `AudioEngine._triggerRunningState()` to early out making it impossible to resume the audio context again.

This change fixes the issue by checking the `_tryToRun` flag. If it is `true` then the audio context is suspended and the `_tryToRun` flag is reset to `false` before attempting to resume the audio context.
@docEdub docEdub added the bug label Aug 18, 2023
@BabylonJS BabylonJS deleted a comment from bjsplat Aug 18, 2023
@BabylonJS BabylonJS deleted a comment from bjsplat Aug 18, 2023
@bjsplat
Copy link
Collaborator

bjsplat commented Aug 18, 2023

@docEdub docEdub marked this pull request as ready for review August 18, 2023 15:55
@docEdub docEdub enabled auto-merge August 18, 2023 16:05
@docEdub docEdub merged commit b1d9091 into BabylonJS:master Aug 18, 2023
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants