A real-time digital human conversation is not a simple HTTP request. A mobile user can change from office Wi-Fi to cellular service while the browser still holds a peer connection, signaling session, media tracks and pending AI response. An engineering team needs to know which parts should recover and which must not restart without consent. The MDN restartIce reference describes the WebRTC API and its negotiation behavior; the W3C WebRTC Statistics API Candidate Recommendation Draft of September 25, 2025 describes observable quality data. This runbook turns those specifications into reproducible application tests, not a claim that one ICE restart guarantees a clean reconnection on every network.
Start with a precise connection-state ledger
Build one session timeline from device network events, signaling messages, ICE connection state, media track state and AI response identifiers. Use monotonic timestamps in client logs so clock changes cannot reverse events. Record when the link changes, when ICE moves through checking, connected, disconnected or failed, when negotiation starts, and when useful audio returns. This separation matters because the UI might display “connected” while RTP audio is silent, or a connection may briefly recover while the AI backend has already discarded a turn. Do not treat a single green status indicator as a successful call. The W3C stats specification defines objects exposed through getStats and provides a more defensible quality vocabulary. Collect only data required for reliability diagnostics; avoid copying user speech or personal conversation text into a network telemetry stream.
Use restartIce deliberately, not as an infinite retry
According to MDN, calling restartIce requests new ICE candidate gathering and causes negotiationneeded; the next offer triggers the restart. It is not equivalent to destroying every media track or rebuilding the entire application session. Wrap negotiation in a serialized state machine that respects stable signaling state and glare handling. If incoming and outgoing offers collide, follow a defined perfect-negotiation pattern or the chosen signaling library’s documented equivalent. Establish a bounded retry budget and a cooldown so network flapping does not create dozens of offers. Track the reason for each restart, including network type change, ICE failed state, or manual recovery. Never restart camera or microphone permission flows as a side effect of retrying connectivity; transport recovery and capture consent are separate concerns.
Measure usable media recovery rather than socket success
Define a recovery event that matters to the person using the call: speech can be heard, a digital human response resumes or text fallback is available. Capture inbound and outbound packet counters, packet-loss indicators, jitter, candidate pair changes and frame activity, using whichever statistics the browser actually supports. Not all W3C draft members are implemented uniformly, so check for missing fields without treating absence as zero. Store an anonymized sequence of sampled values, not a continuously identifying endpoint history. Measure three times separately: detection time, negotiation time and usable-media return time. A test might set a hypothetical target for median or upper-tail recovery, but such a target must be labeled as a release gate rather than a measured production result. Pair numbers with a human playback test because metrics alone cannot tell whether the avatar’s sentence became incomprehensible.
Protect unfinished AI turns and conversation order
An AI backend can receive a completed user utterance just as the client loses connectivity. If the client retransmits without a stable turn ID, the service may generate two replies, bill twice or store duplicate memories. Give each user turn an idempotency identifier and distinguish acknowledged input from displayed output. When a reconnection occurs, query authoritative turn status rather than assuming the last local transcript is complete. The client should allow the user to cancel a pending answer or switch to text instead of replaying potentially private audio automatically. Keep model-generation retries independent from ICE retries; a healthy media session does not prove generation should be restarted. Test whether a late old answer can overwrite a newer conversation message. A strict ordering ledger prevents a transport recovery from turning into a social context or billing defect.
Test six controlled failure modes across devices
Run a repeatable matrix: Wi-Fi to cellular, cellular to Wi-Fi, router loss without OS network-change notification, temporary DNS disruption, background-and-foreground transition, and headset switching during renegotiation. Add slow signaling and simultaneous offer cases where feasible. Use at least one real iOS and Android device because desktop emulation cannot reproduce operating-system behavior exactly. Before each trial, note capture permissions, selected audio route, session identity and a short artificial utterance that contains no personal information. After recovery, confirm that microphone and camera indicators match real track state, AI response order is unchanged, and stop or hang-up remains immediately accessible. Review attempts where the test tool reports success but the participant sees a frozen face; those failures should not disappear behind a networking-only dashboard.
Write a release decision that can be falsified
Publish a table of expected behavior for every failure mode, with observed timestamps, missing stats, user-visible labels and whether the result met its agreed threshold. Include a hard stop for cases that reactivate media capture without permission or mix two users’ sessions. Treat a stable reconnection rate as an outcome to measure, not an assertion that the proposed implementation has achieved it. Provide a clearly named degraded mode: text replies, retry later or end the call. Keep the same experiment script across builds to detect regressions from changes in TURN infrastructure, transport libraries or AI streaming gateways. The engineering win is not an invisible workaround; it is a documented recovery boundary that preserves user choice while allowing a mainstream digital human experience to continue gracefully.
Sources
- MDN — RTCPeerConnection.restartIce() reference (Living documentation, checked Nov 9 2026)
- W3C — WebRTC Statistics API Candidate Recommendation Draft (September 25, 2025)
Illustrative licensed Unsplash stock photography; not a screenshot from the tested system.