Fix/no explicit dispose - #68
Merged
Merged
Conversation
🔗 Merge Alignment ReminderIf this PR targets Both repos should be merged in coordination to avoid breaking changes. Do not merge one without the other being ready. |
4 tasks
sandrade-dcl
approved these changes
May 15, 2026
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.
What does this PR change?
Prevents LiveKit FFI callback threads from blocking Unity's application exit by marking them as background threads, and standardizes internal logging through
Utils.Debugwith UTC timestamps.Problem
When Unity's
Application.Quit()is called, the runtime waits for all foreground threads to complete before the process can exit. The LiveKit native SDK spawns threads for FFI callbacks (FFICallback), and these threads remain as foreground threads by default. If a callback is in-flight or the native SDK keeps dispatching events during shutdown, the application hangs — contributing to the exit delay investigated in unity-explorer#8770.Additionally, some log calls in
FFIClientusedDebug.Logdirectly instead of the SDK's ownUtils.Debugwrapper, bypassing theLK_DEBUGconditional compilation and lacking consistent formatting.Solution
Background thread marking (
FFIClient.FFICallback):FFICallback, checksThread.CurrentThread.IsBackgroundand sets it totrueif it isn't already.Application.Quit()is called.IsBackgroundon an already-background thread is a no-op.Logging standardization:
Debug.Logcalls inFFIClient.cswithUtils.Debugto route them through the SDK's conditional (LK_DEBUG) logging path.captureLogsflag value to the initialization log for easier diagnostics.HH:mm:ss.fff) to bothUtils.DebugandUtils.Erroroutput for better correlation with exit timing diagnostics.Note
An initial approach (
silent drop fix) was attempted and reverted in favor of the current, simpler background-thread solution.Test Instructions
manifest.json).[LK]prefixed messages — they should include UTC timestamps.Quality Checklist