feat(realtime): connection pre-warming via startMuted + mute/unmute#3
Merged
Conversation
Establish an authenticated, idle session up front and hold it unbilled, then go live with no startup latency. Adds ConnectOptions::startMuted (publishes the input track muted) and RealtimeSession::mute()/unmute(). An idle WebRTC track emits keepalive frames, so we mute the LiveKit local track before publishing — muting, not withholding captureFrame, is what keeps the warmed session free. Includes the realtime_warmup example, README docs, and thread-safe access to the published track. Verified live: a session alive 18.4s billed only 5s (the post-unmute generation window); the muted warmup window billed zero.
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
Adds connection pre-warming for realtime sessions, so apps can make the "Start" moment feel instant.
Why
Normally, when a user starts a realtime session there's a noticeable wait while the connection authenticates and the media path is established. Pre-warming lets you do all of that ahead of time and hold the session idle — at no cost — so the instant the user hits Start, generation begins with no startup latency. Billing tracks active generation, so a warmed-but-idle session is free; if the user never starts or cancels, you just disconnect and aren't charged.
What's new (public API)
ConnectOptions::startMuted— connect and authenticate now, transmit nothing yet.RealtimeSession::mute()/unmute()— pause/resume transmission at runtime.decart::ConnectOptions options; options.model = model; options.initialState.prompt = decart::Prompt{"A watercolor painting", /*enhance=*/true}; options.startMuted = true; // warm + authenticate, but stay idle (unbilled) auto session = client.realtime().connect(source, options); // When the user clicks Start: session->unmute(); source->captureFrame(frame); // generation begins here // Pause without disconnecting — stops generation (and billing), keeps the session warm: session->mute(); // Resume instantly later: session->unmute(); // If they cancel entirely: session->disconnect(); // no chargeAlso ships a runnable
realtime_warmupexample and a README section.Verified end-to-end: a warmed, idle session incurs no billing, and billing begins only once the session goes live.