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

Close and recreate audiocontext for every play #674

Closed
wants to merge 2 commits into from

Conversation

Evert-R
Copy link
Contributor

@Evert-R Evert-R commented Dec 19, 2023

This PR closes and recreates the audiocontext of webaudio after each played sound.
https://devcodef1.com/news/1068842/fixing-ios-17-web-audio-issue

Hopefully this resolves issue #628
#628

If not, this PR can be discarded, for efficiency reasons.
(I cannot test this myself on IOS17)

@Evert-R Evert-R added this to the That's My Song milestone Dec 19, 2023
@Evert-R Evert-R requested a review from BeritJanssen December 19, 2023 13:29
Copy link
Collaborator

@BeritJanssen BeritJanssen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should work!

@@ -107,6 +107,11 @@ export const stopBuffer = () => {

// play buffer by section.id
export const playBuffer = (id) => {
// temporary solution for ios17
// https://devcodef1.com/news/1068842/fixing-ios-17-web-audio-issue
audioContext.close();
Copy link
Contributor

@drikusroor drikusroor Dec 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this throw an error if audioContext isn't (yet) defined, or is that impossible to happen? It is is possible to happen, perhaps we can play it defensively, e.g.:

    if (audioContext) {
        audioContext.close();
        audioContext = new (window.AudioContext || window.webkitAudioContext)();
    }
    
    // and continue

@BeritJanssen
Copy link
Collaborator

BeritJanssen commented Jan 15, 2024

It turns out that the problem with no audio persists on some iOS versions even when recreating the audioContext every time, so I think we shouldn't merge this.

@Evert-R Evert-R deleted the bugfix-er/ios17-webaudo branch February 22, 2024 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants