Fix Unity media stream lifetime leaks and add latest-frame video coalescing#198
Open
xianshijing-lk wants to merge 4 commits intomainfrom
Open
Fix Unity media stream lifetime leaks and add latest-frame video coalescing#198xianshijing-lk wants to merge 4 commits intomainfrom
xianshijing-lk wants to merge 4 commits intomainfrom
Conversation
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.
This PR tightens Unity-side media stream lifetime management and reduces unnecessary video frame retention under bursty delivery.
What changed
Why
Before this change, Unity media streams could retain stale event subscriptions and native resources across unsubscribe/disconnect/reconnect flows. AudioStream and VideoStream subscribed to long-lived FfiClient events but did not fully
tear down owned resources, and audio callback-scoped frame wrappers were not being disposed.
For video, Unity also only had a single active buffer slot, which was less explicit about producer/consumer separation and did not document/latest-frame coalescing behavior clearly. This PR makes that behavior explicit and ensures
older pending frames are dropped immediately rather than retained.
Behavioral impact
Testing