Repository navigation
Fix fast publication eligibility and response handling - #1300
xianshijing-lk wants to merge 2 commits into
Conversation
| } | ||
|
|
||
| // Codec support permits overlap independently of the publisher warm-up hint. | ||
| _enabledPublishCodecs = event.response.enabledPublishCodecs; |
There was a problem hiding this comment.
🟡 Empty video codec during fallback
With subscriberPrimary=true and fastPublish=false, _enabledPublishCodecs activates broken video fallback for audio-first codec lists. Given Opus/VP8 and requested VP9, _publishVideoTrack converts Opus into an empty codec. AddTrackRequest then carries an empty primary video codec instead of VP8.
Learn more
Caching codecs for subscriber-primary connections without warm-up also enables the existing video codec fallback, not just overlapping negotiation. The fallback in _publishVideoTrack checks supported video codecs but selects the first entry from the unfiltered list. mimeTypeToVideoCodecString returns an empty string for audio/opus. That empty string becomes the primary SimulcastCodec and the track's codec rather than a supported video codec.
Example: Join with subscriberPrimary=true, fastPublish=false, and codecs [audio/opus, video/vp8]. Publish a camera track with VideoPublishOptions(videoCodec: 'vp9'). The fallback selects Opus and produces videoCodec: '', rather than selecting VP8.
Recommended fix: Filter the advertised codecs to supported video codecs before selecting a fallback in _publishVideoTrack. If no supported video codec remains, handle that case explicitly rather than converting an audio codec. Add a video publication regression test with warm-up disabled, an audio-first codec list, and an unavailable requested video codec.
Was this helpful? React with 👍 or 👎 to provide feedback.
Flutter already overlaps AddTrack registration and sender/SDP setup when server codecs are available, including in its default dual-PC mode. This follows up on livekit/rust-sdks#1704 by making the response lifecycle safe for that existing fast path: registration currently sends AddTrack before installing its per-call event listener, and rejection/disconnect can leave publication waiting for the full timeout.
Keep one CID-keyed response completer owned by the engine. Register it before sending AddTrack, resolve it on publication acceptance, fail it on request rejection or teardown, and remove it on every exit. Reject duplicate in-flight CIDs without replacing the original waiter. Clear cached publish codecs during cleanup so a later legacy connection cannot inherit the previous connection's fast-publication eligibility. Save advertised codecs regardless of
fastPublish: that flag controls join-time publisher warm-up, while advertised codecs determine whether ordinary registration and SDP can overlap.No public API or dependency changes. Codec-based eligibility is now independent of the publisher warm-up hint, matching JS and the revised Rust implementation. Fast and sequential publication retain their existing completion behavior. This main branch currently has no exposed single-PC connect option; this change works on its existing dual-PC transport and does not depend on adding SPC.
Validation with Flutter 3.44.9:
git diff --checkpassed.Includes a patch changeset. Local initial-track/connect work is left untouched in its original checkout; this PR is based on current main and addresses ordinary track registration.