Skip to content

Loop to print handle counts#1079

Draft
MaxHeimbrock wants to merge 1 commit into
mainfrom
max/debug-handle-counting
Draft

Loop to print handle counts#1079
MaxHeimbrock wants to merge 1 commit into
mainfrom
max/debug-handle-counting

Conversation

@MaxHeimbrock
Copy link
Copy Markdown
Contributor

@MaxHeimbrock MaxHeimbrock commented May 11, 2026

Info

Just a loop that prints the handles stored in the FFI Client to debug leaks in our cleanup.

@github-actions
Copy link
Copy Markdown
Contributor

No changeset found

This PR modifies the following packages but doesn't include a changeset:

Directly changed:

  • livekit-ffi

Click here to create a changeset

The link pre-populates a changeset file with patch bumps for all affected packages.
Edit the description and bump types as needed before committing.

If this change doesn't require a version bump, add the internal label to this PR.

MaxHeimbrock added a commit that referenced this pull request May 15, 2026
## Summary

Found while counting handles during Unity sessions via
#1079

### Background

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. 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.
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.

1 participant