Fix LocalTrackPublished handle leak#1065
Draft
MaxHeimbrock wants to merge 1 commit intomainfrom
Draft
Conversation
The forward_event handler for RoomEvent::LocalTrackPublished was allocating a fresh FfiPublication, calling FfiServer::store_handle, and then sending the proto event without the handle id. Because proto::LocalTrackPublished only carries track_sid, the foreign-language client never received the id and had no way to call drop_handle on it. Each local publish_track call therefore leaked one publication entry in the FFI handle table for the lifetime of the process. The publication is already wrapped and handed to the client via the PublishTrackCallback path (publish_track at the top of this file). The LocalTrackPublished event is a notification that fires after that callback to let the client run any post-publish bookkeeping; it does not need its own handle. Drop the redundant allocation entirely. Surfaced while investigating untracked memory growth in the Unity SDK, where the FFI handle table held two publication entries per local track across a session and only one of them could be dropped on disconnect. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
No changeset foundThis PR modifies the following packages but doesn't include a changeset: Directly changed:
Click here to create a changeset The link pre-populates a changeset file with If this change doesn't require a version bump, add the |
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.
Summary
The
forward_eventhandler forRoomEvent::LocalTrackPublishedwas allocating a freshFfiPublication, callingFfiServer::store_handle, and then sending the proto event without the handle id. Becauseproto::LocalTrackPublishedonly carriestrack_sid, the foreign-language client never received the id and had no way to calldrop_handleon it. Each localpublish_trackcall therefore leaked one publication entry in the FFI handle table for the lifetime of the process.The publication is already wrapped and handed to the client via the
PublishTrackCallbackpath. TheLocalTrackPublishedevent is a notification that fires after that callback to let the client run any post-publish bookkeeping; it does not need its own handle. Drop the redundant allocation entirely.Surfaced while investigating untracked memory growth in the Unity SDK, where the FFI handle table held two publication entries per local track across a session and only one of them could be dropped on disconnect.
Test plan
🤖 Generated with Claude Code