v131 · multimedia
Playback Statistics API for WebAudio
This feature adds an AudioContext.playbackStats attribute which returns an AudioPlaybackStats object. This object provides audio playback statistics such as average latency, minimum/maximum latency, underrun duration, and underrun count. This API allows web applications to monitor audio playback quality and detect glitches.
concepts
-
WebAudio Playback Stats
WebAudio context exposes playback statistics (frames rendered, late frames, deviations). Sites can monitor audio pipeline health.
-
Live glitch detector
The motivating DAW use case: alarm on underruns in real time, with synthetic load and a rolling capacity chart.
-
Latency meter (rolling chart)
Sample
outputLatencyevery 200ms and draw a rolling line chart. Suspend/resume the context and watch the gap. -
Worklet under load (induce underruns)
An AudioWorklet with a load slider. Push past the render quantum budget and watch
fallbackFramesDurationtick up.
why it shipped
There is currently no way to detect whether WebAudio playout has glitches (gaps in the played audio, which typically happens due to underperformance in the audio pipeline). There is an existing way to measure the instantaneous playout latency using AudioContext.outputLatency, but no simple way to measure average/minimum/maximum latency over time. With this API, we want to propose a way to be able to measure the delay of that audio and the glitchiness of the audio.