Repository navigation
fix: use prepared publications during Session startup (CLT-3610) - #1523
Open
xianshijing-lk wants to merge 3 commits into
Open
xianshijing-lk wants to merge 3 commits into
xianshijing-lk wants to merge 3 commits into
Conversation
xianshijing-lk
requested review from
1egoman,
lukasIO and
thomasyuill-livekit
as code owners
November 20, 2026 22:39
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
This PR bumps
Also bumped
|
Contributor
size-limit report 📦
|
1 of 2 tasks
This branch was successfully deployed
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 and why
CLT-3610. Use the device-free publication preparation API from livekit/client-sdk-js#2292 during
useSession().start(), so credential acquisition and JOIN proceed independently of microphone/camera initialization. Late capture can attach to a sender already negotiated in JOIN.The public Session API and startup options remain unchanged. The helper derives microphone publication intent from existing publish options, and camera dimensions/frame rate from the room's configured capture resolution. Codec, encoding, simulcast and audio settings continue to come from existing publication/room defaults. It never opens a device to discover publication configuration before JOIN.
end(), abort, unmount and disconnection; stop media that arrives after cancellation and cancel unused reservations. Remove startup/disconnect listeners on their lifecycle boundaries. Failed startup disconnects and cleans up acquired media.Validation
Reproduce the real-browser cases with
scripts/test-session-publication.mjs; prerequisites and commands are inscripts/README.md. The companion SDK PR contains the signaling-latency benchmark (roughly 150 ms to 2–4 ms after capture with 100 ms injected signaling RTT) and the real dual-PC/server-codec fallback matrix.This can be reviewed independently and continues to work with older SDK releases. The startup performance improvement becomes available when applications adopt the companion SDK release.
Session UX benchmark
A separate feature A/B measures the actual React Session hook and UI with a real SFU. Across 100 measured runs (ten per variant per scenario, plus ten excluded warmups), the user's signaling and ICE/DTLS/media pass through latency relays. The warm fixture agent connects directly to the SFU. Both variants use the same SDK build, isolating the old versus prepared Session flow.
P50 seconds from the Connect click, existing → prepared, at 150 ms network RTT:
The first response proxy improves 1.265 → 1.138 s in the 800 ms case and 2.472 → 2.310 s in the two-second case. Fast capture and one-second credentials show little meaningful median gain: normal publication overlaps transport setup. The credential stage remains 1.004 s in both variants.
The main perceived benefit is an early welcome while device access is pending. JOIN publisher intent can make the remote participant visible before capture, interacting with the SFU's subscriber-only update batching. This greeting gain is not purely a two-RTT saving and depends on the agent's greeting policy. The existing
session.isConnectedstate can render Connected early; an app awaiting all ofstart()still waits for its devices.Full report, reproduction, p95s and all 100 raw samples. Audio measurements use real decoded waveforms as a playout proxy; these are controlled Chrome/warm-agent results, with no production authentication, page-load, agent cold-start, STT/LLM/TTS or physical-speaker measurement.
AI assistance: Codex.