Repository navigation
Web calls: an audio codec error no longer ends the call - #2476
Merged
Merged
Conversation
WebCodecs closes an AudioEncoder or AudioDecoder after its error callback; the next encode, decode or configure threw InvalidStateError, which went up with `?` and ended the call loop. Video already recovered. A closed Opus encoder (voice, thin copy, screen sound) is now built anew with its current bitrate, packet length and planned loss on its next frame; a closed decoder of a remote stream is replaced on its next decode, so the stream goes on after a short gap. Rebuilds of one codec run at most once a second, so a codec that keeps failing costs a rebuild a second, not one per 20 ms frame. Each rebuild reaches the call's telemetry, which reports CallAudioCodecRebuilt (encoder or decoder) once per call, without content. Tested in Chromium with an injected codec error (an unsupported configuration, which closes the codec through its error callback). Fixes #2460 Signed-off-by: unbekannt3 <me@unbekannt3.eu>
unbekannt3
enabled auto-merge (squash)
November 27, 2026 01:51
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.
Fixes #2460
WebCodecs closes an
AudioEncoderorAudioDecoderafter its error callback. In web calls the nextencode,decodeorconfigureon the closed codec threwInvalidStateError, which went up with?and ended the whole call. Video already recovered (decoder replaced plus a keyframe request, encoder replaced); audio now does too.What changes
OpusEncoder: the voice, its thin copy and the screen's sound): when WebCodecs has closed it, the next frame builds a new one with the configuration it had (bitrate, packet length, planned loss). A reconfiguration that arrives while it is closed (uplink loss, voice step) only updates the fields, and the rebuild uses them.RemoteAudio, WebCodecs path): when WebCodecs has closed a remote stream's decoder, its nextdecode_duereplaces it. The output count still on its way is reset, so the stream's audio continues after a short gap. The voice worker path already fell back by itself.AUDIO_CODEC_REBUILD_EVERY). A codec that fails every time it starts costs one rebuild a second, not one every 20 ms frame. Meanwhile the samples are a gap, and the jitter buffer (bounded) holds the remote packets.CallEngineEvent::AudioCodecRebuilt(Encoder|Decoder)to the call telemetry. It reports a newCallProblem::AudioCodecRebuilt(CallAudioCodecRebuilt, warning, fingerprintcall / audio_codec_rebuilt / encoder|decoder) once per call and puts a trail line in. The report carries no content and no IDs: the side only (AudioCodecRole, with anUnknowncatch-all). Documented in docs/crash-reports.md.Decision: the rebuild happens lazily, where the codec is next used (
state == "closed"), rather than by routing the error callback to the right codec instance. This covers every encoder and decoder instance the same way, and it can't race the callback: WebCodecs setsclosedin the same task that runs the error callback.Tests
call_web::tests::browser_audio_codecs, wasm-bindgen-test; it runs withWASM_BINDGEN_USE_BROWSER=1). The test configures the codec with a configuration no browser runs, so WebCodecs closes it through its error callback, the same path a codec failing mid-call takes. Checked in Chromium, both pass:AudioCodecRebuilt(Encoder)) and real Opus packets come out again; a second failure right away is not rebuilt within the second;decode_duerebuilds it (AudioCodecRebuilt(Decoder)) and decoded samples of that stream arrive.RebuildGatepacing; telemetry reports once per call with a trail line;CallProblem::AudioCodecRebuiltfingerprint, message, type, level, and JSON round trip, plus an unknown side.teamcraft-media --features web,call-view --all-targets), native clippy (media, client-api, web-calls),scripts/check-feature-combos.sh teamcraft-media.Robustness checklist
max_depth_packets).🤖 Generated with Claude Code