fix: release RTP transceiver and FFI handle resources when unpublishing a track - #1381
Open
OlympusM wants to merge 7 commits into
Open
fix: release RTP transceiver and FFI handle resources when unpublishing a track#1381OlympusM wants to merge 7 commits into
OlympusM wants to merge 7 commits into
Conversation
…/OlympusM/rust-sdks into fix-videotrackunpublication-leak
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
When a local track is unpublished, some resources associated with it were never released:
RtpSenderwas removed from the peer connection, but the underlyingRtpTransceiverwas never stopped, so it stayed alive.local_publication_lookupmap had no corresponding cleanup, so the publication's server handle was never dropped after unpublishing, leaking the handle.This meant repeated publish/unpublish cycles would accumulate resources that were never freed which was especially bad on a video track.
Fix
LocalParticipant::unpublish_tracknow grabs theRtpTransceiver(instead of just itsRtpSender) and passes it throughRtcEngine::remove_track/RtcSession::remove_track, which now calltransceiver.stop()after removing the sender from the peer connection.remove_tracksignatures were updated fromRtpSendertoRtpTransceiveracrosslocal_participant.rs,rtc_engine/mod.rs, andrtc_session.rs; the sender is now derived from the transceiver internally where needed.local_publication_lookupon publish, and removes + drops that handle on unpublish (room.rs), preventing the FFI-side leak as well.Notes