fix: await ICE gathering before publisher ICE restart - #5
Draft
cursor[bot] wants to merge 1 commit into
Draft
Conversation
A FAST reconnect calls restart_ice() on the publisher PeerConnection, but
the ICE agent rejects a restart while it is still gathering candidates
("ICE Agent can not be restarted when gathering"). When a FAST reconnect
immediately follows a freshly recreated publisher PC, it can race the
gatherer and fail every attempt, so a reconnect that should recover to
Joined never settles.
Wait for the publisher's ICE gathering state to leave Gathering (bounded
by a 3s timeout) before restarting, so the restart succeeds once
candidates have settled. Browsers restart ICE implicitly during
gathering; this brings the native path in line.
Co-authored-by: Neevash Ramdial (Nash) <mail@neevash.com>
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.
Summary
A FAST reconnect calls
restart_ice()on the publisherPeerConnection. The native ICE agent rejects a restart while it is still gathering candidates (ICE Agent can not be restarted when gathering). When a FAST reconnect immediately follows a freshly recreated publisher PC (for example, after a REJOIN attempt), it can race the gatherer and fail every attempt, so a reconnect that should recover toJoinednever settles.Browsers restart ICE implicitly during gathering; the native path did not. This change waits for the publisher's ICE gathering state to leave
Gathering(bounded by a 3s timeout) before restarting, so the restart succeeds once candidates have settled.Changes
restart_icenow awaitswait_for_ice_gathering_to_settlebefore callingrestart_ice()on the publisher.Testing
This fixes the live reconnect test
live_forced_media_restore_failure_is_surfaced_and_recovers, which previously timed out because the forced-fault reconnect never returned toJoined. It now recovers reliably (verified across repeated runs). Full gate is green:cargo fmt --all --check,cargo clippy --locked --all-targets --all-features -- -D warnings,cargo test --locked,cargo test --locked --doc, andRUSTDOCFLAGS="-D warnings" cargo doc --locked --no-deps.