Fix leaks when audio context cannot be unlocked (MacOS Safari) #1338
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Symptom is the _html5AudioPool fills with unbounded number of elements if unable to unlock (seen on MacOS Safari).
When not allowed to unlock audio, we're seeing
unlock
being called on every touch event indefinitely, leaking Audio elements, causing a big slowdown in our app after a few minutes. This happens on Mac OS Safari when audio is not allowed to be unlocked (microphone was in use by another tab, I think).It appears to also be thrashing AudioBufferSources and related state as it keeps making new sources and trying to play them and binding new onended callbacks, but I don't see an easy way around that.
My fork has diverged quite a bit, but I think this PR captures the change into the right place for the mainline.