Closed henbos closed 3 months ago
WDYT @o1ka @hoch @padenot ?
I was curious how fluctuant the values are in practice. I built a little demo to check it.
https://stackblitz.com/edit/js-jfkhex?file=index.js,index.html
When testing this on macOS with the internal speakers I get a constant outputLatency
value for Chrome and Firefox. The demo doesn't work in Safari because it doesn't implement outputLatency
and has a bug in its getOutputTimestamp()
implementation.
My test is obviously very simple and not really a real life audio app. @henbos Is there anything obvious I could do to provoke a changing outputLatency
?
@chrisguttandin non-default AudioContextOptions should help to trigger outputLatency changes (ex.: 44.1 kHz sample rate, "playback" latency hint).
@henbos SG, though I'd rather call it resetOutputLatencyStats(), to not confuse with outputLatency.
Since this idea is pursued by the WICG issue link, I believe we can close this.
Describe the feature Output latency is an instantaneous value. Some apps might be interested in the average, minimum and maximum output latency over an app-defined interval without having to do high frequency polling. Avoiding high frequency polling when not needed should not only be convenient but also have performance benefits.
Is there a prototype? No but outputLatency is shipped so shimming based on high frequency polling is possible.
Describe the feature in more detail Output latency can be measured via AudioContext.outputLatency, which can be useful for synchronization use cases when polling at high frequency:
In Chromium, this can change all the time.
But apps may want to monitor this less frequently in which case an infrequent poll of
outputLatency
may not be as representative. In MediaStreamTrackAudioStats, the instantaneouslatency
value is complemented with a min, max and average latency since the last time the app calledresetLatency()
, allowing the app to easily control what periods of time this should be measured over.Should WebAudio use the same pattern for its latency? Proposal: