Repository navigation
Conversation
Once UDP is blocked, libwebrtc falls back to a TURN relay over TCP/TLS and stays there after UDP comes back, until something restarts ICE. On a link measured end to end, that path sent 3x less video, froze 5x more often and added about 150 ms of audio latency. An app can see the selected pair in getStats(), but had no public way to restart ICE: Engine, handleReconnect and ClientDisconnectReason are internal. Room.restartIce() reuses the regular resume path with RR_SWITCH_CANDIDATE, the protocol's reason for this case: an iceRestart offer for the publisher, while the server restarts the subscriber. The mock peer connection now implements restartIce() as a no-op, which the resume path calls on native platforms. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
|
| Future<void> restartIce() => engine.handleReconnect( | ||
| ClientDisconnectReason.reconnect, | ||
| reconnectReason: lk_models.ReconnectReason.RR_SWITCH_CANDIDATE, | ||
| ); |
There was a problem hiding this comment.
🔴 ICE restart future completes too early
When a connected app awaits restartIce(), it completes before ICE restarts. handleReconnect only schedules a timer, so later failures never reach the caller.
Learn more
The public method returns the future from handleReconnect, which completes after scheduling a retry timer. The timer later invokes attemptReconnect; that method catches reconnect failures and starts further retries without completing the original future. A caller cannot await ICE restart completion or distinguish success from eventual disconnect.
Example: An app calls await room.restartIce() and immediately reads the candidate pair. The await completes before the zero-delay timer even opens a new signaling socket, so the old TCP pair is still selected.
Recommended fix: Give the requested reconnect a completion future tied to the final successful resume or failure, and return that future from Room.restartIce(). Preserve the engine's retry behavior and settle the future on disconnect or disposal.
Was this helpful? React with 👍 or 👎 to provide feedback.
Once UDP is blocked, libwebrtc falls back to a TURN relay over TCP/TLS and stays there after UDP comes back, until something restarts ICE. On a link measured end to end, that path sent 3x less video, froze 5x more often and added about 150 ms of audio latency. An app can see the selected pair in getStats(), but had no public way to restart ICE: Engine, handleReconnect and ClientDisconnectReason are internal.
Room.restartIce() reuses the regular resume path with RR_SWITCH_CANDIDATE, the protocol's reason for this case: an iceRestart offer for the publisher, while the server restarts the subscriber.
The mock peer connection now implements restartIce() as a no-op, which the resume path calls on native platforms.