Skip to content

fix: await ICE gathering before publisher ICE restart - #5

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
fix/reconnect-ice-restart-gathering-race
Draft

fix: await ICE gathering before publisher ICE restart#5
cursor[bot] wants to merge 1 commit into
mainfrom
fix/reconnect-ice-restart-gathering-race

Conversation

@cursor

@cursor cursor Bot commented Sep 9, 2026

Copy link
Copy Markdown

Summary

A FAST reconnect calls restart_ice() on the publisher PeerConnection. 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 to Joined never 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_ice now awaits wait_for_ice_gathering_to_settle before calling restart_ice() on the publisher.
  • The wait is bounded: if gathering has not settled within the timeout, the restart proceeds and any resulting error is retried by the reconnect driver rather than blocking indefinitely.

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 to Joined. 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, and RUSTDOCFLAGS="-D warnings" cargo doc --locked --no-deps.

Open in WebView Automation

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant