Explicitly drop FFI handles on dispose#1174
Open
alan-george-lk wants to merge 3 commits into
Open
Conversation
Contributor
ChangesetThe following package versions will be affected by this PR:
|
Clear remaining FFI handles during dispose so owned native resources are released across repeated initialize/shutdown cycles. Co-authored-by: Cursor <cursoragent@cursor.com>
860b96d to
9209583
Compare
stephen-derosa
approved these changes
Jun 16, 2026
ladvoc
approved these changes
Jun 16, 2026
Log PlatformAudio FFI handle lifecycle details so repeated shutdown/init runs can confirm whether handles are dropped before dispose or cleared during dispose. Co-authored-by: Cursor <cursoragent@cursor.com>
xianshijing-lk
approved these changes
Jun 17, 2026
| .iter() | ||
| .filter(|handle| handle.value().is::<platform_audio::FfiPlatformAudio>()) | ||
| .count(); | ||
| log::debug!( |
Contributor
There was a problem hiding this comment.
unless we add an explicit API to shutdown the PlatformAudio, otherwise it is expected that some platform_audio_handles will remain valid here.
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.
Before you submit your PR
Make sure the following is true before submitting your PR:
PR description
This PR resolves an issue observed in the downstream C++ SDK during repeated unit/integration test runs, where the FFI handle state was not completely cleared and caused issues for different test cases intended to be atomic, but within the same process boundary. This specifically raised a crash in PlatformAudio tests.
Breaking changes
N/A
MSRV
If the PR modifies the crate's MSRV (Minimum Supported Rust Version), document it here.
Testing
Validated in a downstream C++ SDK run against this branch.
Async
We want the project to be runtime-agnostic, so please reuse what's already in livekit-runtime and feel free to add anything missing. It's ok to use Tokio directly, when writing unit tests, if necessary. When testing, do not use artificial delays for the state to "catch up"; instead, respect the event flow and subscribe properly using channels or other mechanisms.