Repository navigation
Re-initialize FFIClient on entering Play mode without a domain reload - #396
Merged
MaxHeimbrock merged 2 commits intoNov 16, 2026
Merged
MaxHeimbrock merged 2 commits into
MaxHeimbrock merged 2 commits into
Conversation
The Editor raises Application.quitting when Play mode exits, so Quit() disposes the client and sets _isDisposed. Without a domain reload the flag stays set in the next Play session, every FFI event is dropped and Room.Connect times out waiting for ReadyForRoomEventRequest. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MirCore
requested review from
MaxHeimbrock,
changt,
cloudwebrtc,
ladvoc and
xianshijing-lk
as code owners
November 10, 2026 11:47
MirCore
added a commit
to TrIVAs-XR/TrIVA-Unity
that referenced
this pull request
Nov 10, 2026
Uses MirCore/client-sdk-unity at 9bdaa10 until livekit/client-sdk-unity#396 is merged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
I see our CI is not fit to check on forks, I will also look into this. |
Contributor
|
I am able to repro this on MacOS and Unity 6000.3.10f1 and can see your PR fixes the issue. I will wait for you to also include the fix to the events and then see how we satisfy the CI. Thanks for the contribution. |
Rooms and streams from an earlier Play session stayed subscribed to the singleton and were kept alive once it was re-initialized without a domain reload.
MaxHeimbrock
approved these changes
Nov 13, 2026
MaxHeimbrock
left a comment
Contributor
There was a problem hiding this comment.
I ran the CI on my own copy and it looks good. Merge when you feel like it.
Contributor
|
CI run: #398 |
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.
Background
When Enter Play Mode Options skip the domain reload,
FFIClientstays disposed after the first Play session. The Editor raisesApplication.quittingon Play mode exit, andQuit()→Dispose()sets_isDisposed, which only a new domain resets. Every later session drops all FFI events, soRoom.Connecttimes out waiting forReadyForRoomEventRequest.Fixes #395.
Changes
[RuntimeInitializeOnLoadMethod(SubsystemRegistration)]hook toFFIClient. If the previous Play session disposed the client, it clears_isDisposed, re-subscribes the before/after assembly-reload handlers thatQuit()removed, and callsInitializeSdk().#if UNITY_EDITOR.Dispose()now clears allFfiClientevent subscribers afterClearPendingCallbacks()(2578cf5). All current subscribers are per-instance (Room, the audio/video/byte/text streams,DataTrack) and their native handles are invalid after theDisposeRequest, so nothing needs to survive. Without this, rooms and streams from earlier Play sessions stayed reachable through the singleton when domain reload is off.Testing
RoomEventReceived,DisconnectReceivedandAudioStreamEventReceived, and all were back to 0 after Play mode stopped.Scripts~/run_unity.shwith a local livekit-server). Not tested on Unity 2022.3 / 6000.0 or non-Windows Editors.Generated with Claude Code