Skip to content

fix(tracks): dispose video source and stop transceiver on unpublish#2

Merged
adrian-niculescu merged 2 commits into
masterfrom
fix-video-publish-unpublish-leaks
Jun 24, 2026
Merged

fix(tracks): dispose video source and stop transceiver on unpublish#2
adrian-niculescu merged 2 commits into
masterfrom
fix-video-publish-unpublish-leaks

Conversation

@adrian-niculescu

Copy link
Copy Markdown
Owner

Brings the video publish/unpublish leak fix into our fork's master ahead 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 the VideoSource, 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 the RtpTransceiver. 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 vanilla main.

Merge with a merge commit (not squash) so the vanilla commit stays distinct from the fix.

davidliu and others added 2 commits June 23, 2026 21:09
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.
@adrian-niculescu adrian-niculescu merged commit 0af48b7 into master Jun 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Memory leaks produced by publishing/unpublishing camera tracks

2 participants