Repository navigation
fix: keep the track processor across mute and restartTrack - #1249
Draft
hiroshihorie wants to merge 1 commit into
Draft
hiroshihorie wants to merge 1 commit into
hiroshihorie wants to merge 1 commit into
Conversation
restartTrack called stop(), which destroys the processor and clears _processor, before it read _processor to attach it to the new track, so the processor was always dropped. Mute went through stop() too. With the default stopAudioCaptureOnMute and stopCameraCaptureOnMute (both true), muting stops the media track and unmuting restarts it, so a microphone or camera processor was lost after the first mute and unmute, and on every camera switch. mute and restartTrack now stop the media track and keep the processor, and restartTrack moves it to the new track as before. stop() still releases it, also when a mute already stopped the media track.
This branch has not been deployed
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.
Problem
A
TrackProcessorset on a local track is silently dropped in two cases:restartTrack(): it callsstop(), which destroys the processor and clears_processor, before it reads_processorto attach it to the new track. So the processor is always lost.setCameraPosition()andswitchCamera()go throughrestartTrack(), so a camera switch drops a video processor.stopAudioCaptureOnMuteandstopCameraCaptureOnMuteboth default totrue. Muting then callsstop(), and unmuting callsrestartTrack(), so a microphone or camera processor is gone after the first mute and unmute. Apps that set these options tofalseonly toggleenabledand are not affected.Fix
mute()andrestartTrack()now stop and dispose the media track without releasing the processor, andrestartTrack()moves it to the new track as before.stop()still releases the processor, also when a stop-on-mute already stopped the media track. Before, that case skippedstopProcessor().stop()keeps callingsuper.stop()itself becauseTrack.stopis@mustCallSuper, so the shared teardown takes its result as a parameter.Testing
test/track/local_track_processor_test.dart: mute and unmute,restartTrack(), andstop()after a mute. Againstmain'slocal.dart, the first two fail withprocessornull.flutter test test/track/: 21 passed.flutter analyzeis clean.TrackProcessor(flutter_webrtc's desktopAddVideoProcessor, feat(desktop): let native plugins attach video processors to local tracks flutter-webrtc/flutter-webrtc#2233). AfterrestartTrack(), the processor moves to the newMediaStreamTrackand the subscriber keeps decoding processed frames. Without this change, the processor is gone after the restart. Passed 3 runs in a row.Found while working on CLTCU-14 (desktop video processors for Proton).