Repository navigation
fix(playback): detect silent media stalls, surface load errors - #149
Merged
Merged
Conversation
The <audio> transport's failure telemetry covered exactly two channels: play() rejecting (autoplay policy) and the element's `error` event (resource error). A third state slipped through both: the element accepts the src, fires loadstart, and then never delivers a byte — readyState stays 0, play()'s promise stays pending forever (per spec it only settles when playback starts or aborts), and no error ever fires. Observed with a wedged Chrome media pipeline: every screen showed a "playing" transport with a frozen clock, forever, with zero feedback. Three fixes: - stall-detector.ts: pure clock-progress detector. Wired as a setInterval watchdog (not RAF — background tabs) in useAudioMaster (editor) and use-pingpong-transport (triage + arrange): store says playing but the active element's clock hasn't moved for 1.5 s → editor surfaces an error + notice and flips isPlaying back; triage/ arrange fall back to the onPlayRejected path (honest stopped transport instead of a phantom playing one). Deliberately not gated on isReady — the not-ready case is exactly where the editor's play effect no-ops while the transport already shows "playing". - Metadata timeout (editor): loadedmetadata lands in milliseconds for local OPFS/blob sources; after 5 s of silence the load is declared dead and the decoding overlay explains itself instead of pulsing forever. - MasterAudio overlay z-order: the compositor canvas is a later sibling in the same stacking context and painted OVER the decoding/error overlay — on a stuck load the stage just looked black. z-10 makes the existing overlay actually visible; the pulse bar hides once an error is shown. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011JCm6qu9qx6kKGPCbiWaeu
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.
Problem
The
<audio>transport (editor, triage, arrange — all on the shared ping-pong engine) has exactly two failure channels:play()rejecting (autoplay policy) and the element'serrorevent (resource error). A third state slips through both: the element accepts the src, firesloadstart, and then never delivers a byte —readyStatestays 0, noprogress, noerror, and per specplay()'s promise stays pending forever (it only settles when playback actually starts or aborts).Observed in the wild with a wedged Chrome media pipeline (browser-wide
HTMLMediaElementstall;fetch, WebAudio and WebCodecs all healthy — the render pipeline worked while every transport froze): all three screens showed a "playing" transport with a frozen clock, forever, with zero feedback. On top of that, the editor's existing "Decoding studio audio" / error overlay was painted underneath the compositor canvas (later sibling, same stacking context, z auto) — so even the state that should have been visible wasn't: the stage just looked black.Fix
stall-detector.ts— pure clock-progress detector (any change counts as progress, including backward jumps from loop wraps). Wired as a 250 mssetIntervalwatchdog (not RAF — background tabs) inuseAudioMaster(editor) anduse-pingpong-transport(triage + arrange): store says playing but the active element's clock hasn't moved for 1.5 s →pushNotice("AUDIO STALLED — PLAYBACK STOPPED")+setPlaying(false)onStalledcallback, defaulting to the existingonPlayRejectedpath → transport honestly flips back to PlayisReady: the not-ready case is exactly where the editor's play effect no-ops while the transport already shows "playing"loadedmetadatalands in milliseconds for local OPFS/blob sources; after 5 s of silence the load is declared dead and the overlay explains itself ("audio never loaded — the browser is not delivering media data …") instead of pulsing forever.MasterAudio.tsx) —z-10so the existing decoding/error overlay actually paints above the canvas; the pulse bar hides once an error is shown.Verified
stall-detectortests + 5 newuseAudioMasterwatchdog/timeout tests (fake timers incl.performance); full unit suite: 1695 passed. The 6 failures insrc/editor/render/feature-flag.test.tsare pre-existing — they fail identically on unmodifiedmainin this environment.<audio>):useAudioMaster.loop.browser.test.tsxgreen — 6+ s of real playback across loop wraps and chunk hops without a false-positive stop. Full browser suite: failure set identical to amainbaseline run in the same environment (74 env-related failures on both, same test names — none playback-related).🤖 Generated with Claude Code
https://claude.ai/code/session_011JCm6qu9qx6kKGPCbiWaeu