Repository navigation
fix: release the microphone stream and audio context that increaseMicLevel opens - #185
Open
RaphaelFakhri wants to merge 1 commit into
Open
RaphaelFakhri wants to merge 1 commit into
RaphaelFakhri wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
increaseMicLevel()leaks a microphone stream and anAudioContexton every call.Problem
Each call opens a
getUserMediastream and anAudioContextand keeps no reference to them. Nothing stops the tracks or closes the context, not when a later call replaces the boost, not onstop(), and not when setting the input device fails. The microphone stays captured after the call ends, and repeated calls accumulate contexts until the browser refuses to create more.Solution
The SDK now keeps the stream and context of the active boost in
micBoost.increaseMicLevel()releases the previous boost after the new track is in place.stop()and the internal cleanup release the active boost.stop()that lands while the boost is being set up, releases the resources that this call opened.Testing
Adds
__tests__/micBoost.test.ts(fakegetUserMediaandAudioContext, no browser):stop()releases the active stream and context.stop()during setup releases the resources that the interrupted call opened.Run with
npx jest __tests__/micBoost.test.ts. Without the change tovapi.ts, 4 of 4 tests fail. With it, 4 pass. The full suite (65 tests) passes andtsc --noEmitis clean.Fixes #184