fix(tracks): dispose video source and stop transceiver on unpublish#2
Merged
Merged
Conversation
Co-authored-by: davidliu <242400+davidliu@users.noreply.github.com>
LocalVideoTrack.dispose() left its VideoSource undisposed, leaking the source's native memory for the lifetime of the process; only the track and capturer were released. Unpublishing a video track removed the track from its sender but never stopped the transceiver, which is created fresh on every publish (plus one per backup codec), so transceivers accumulated until the connection closed.
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.
Brings the video publish/unpublish leak fix into our fork's
masterahead of the upstream merge.Fixes livekit#521. Upstream PR: livekit#971.
Two native leaks build up on every video publish/unpublish cycle:
LocalVideoTrack.dispose()released the track and capturer but not theVideoSource, leaking the source's native memory for the lifetime of the process.restartTrack()already disposes the old source, so terminal dispose was the only path missing it.unpublishTrack()removed the track from its sender but never stopped theRtpTransceiver. A new transceiver is created on every publish, so they accumulated until the connection closed. Stopping the now-unused video transceiver releases it and frees the SDP m-section for reuse. Same approach as the iOS fix (Huge memory leaks produced by publishing/unpublishing camera tracks livekit/client-sdk-swift#420).This branch also carries
chore(pinact)(livekit#954) from vanillamain.Merge with a merge commit (not squash) so the vanilla commit stays distinct from the fix.