Repository navigation
sfu: don't reset a stream tracker that is unpaused while not paused - #5191
Merged
boks1971 merged 1 commit intoNov 11, 2026
Merged
Conversation
Since livekit#4453, StreamTrackerManager.UpdateTrackInfo calls SetPaused(trackInfo.Muted) on every track info update, not only when the mute state changes. StreamTracker.SetPaused(false) reset the tracker even when it was not paused, so any track info update of an unmuted video track (video size, codec info, simulcast layer SSRCs, UpdateLocalVideoTrack) marked every live layer stopped, removed it from the available layers, and zeroed its bitrate until the next packet and bitrate report. SetPaused now returns early when the paused state does not change, as StreamTrackerDependencyDescriptor.SetPaused already does. A new tracker starts unpaused in its reset state, so the SetPaused call in AddTracker behaves the same.
boks1971
approved these changes
Nov 11, 2026
boks1971
left a comment
Contributor
There was a problem hiding this comment.
Thank you for this! Really appreciate it.
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.
Since #4453, every track info update calls
SetPaused(trackInfo.Muted)on a video track's stream trackers.StreamTracker.SetPaused(false)resets the tracker even when it was not paused.As a result, updating an unmuted track's video size, codec info or simulcast layer SSRCs marked every live layer stopped, dropped it from the available layers, and zeroed its bitrate until the next bitrate report.
SetPausednow returns early when the paused state does not change, matchingStreamTrackerDependencyDescriptor.SetPaused.Fixes #5190
Decisions
StreamTracker.SetPausedrather than inStreamTrackerManager.UpdateTrackInfo. That waySetPausedis idempotent for every caller, and bothStreamTrackerWorkerimplementations behave the same.Reset(), and the packet tracker's zero value equals its reset state. SoAddTrackercallingSetPaused(false)on a new tracker behaves as before.Verification
go test ./pkg/sfu/streamtracker/ -run 'TestStreamTracker$' -race: the newstays active when unpaused while not pausedsubtest fails on master (expected: StreamStatusActive, actual: StreamStatusStopped) and passes with the fix. The newresets when unpaused after pausesubtest passes before and after, which shows that a real unpause still resets the tracker.go test ./pkg/sfu/streamtracker/ -race -count=3: passes.go test ./pkg/sfu/... ./pkg/rtc/... -race: passes.gofmt -s -landgo vet ./pkg/sfu/streamtracker/ ./pkg/sfu/: clean.StreamTrackerManager-level test, not included in this PR: an active layer followed byUpdateTrackInfowith an unmutedTrackInfo. It fails on master because the layer leavesGetLayeredBitrate's available layers, and it passes with the fix.