-
Notifications
You must be signed in to change notification settings - Fork 170
Add AudioPlayoutStats interface #2645
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally looks good with some nits.
Also could you wrap the text at the column 80?
From @hoch Co-authored-by: Hongchan Choi <hongchan.choi@gmail.com>
Implemented your comments and wrapped the lines at 80 (except where it would have cut through a link, which seems to be the standard for the rest of the document), thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks!
@padenot Could you take a look? |
1. Set {{[[underrun duration]]}} to the total duration of all | ||
[=underrun frames=] (in seconds) that | ||
{{[[audio context]]}} has played since its construction. | ||
1. Set {{[[underrun events]]}} to the number of times that {{[[audio context]]}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious if this design holds up to distinguish these three cases
- occasional spike
- consistent overload -> consistent underruns (every quantum processed)
- periodic overload. as an example, a misaligned block based computation that ends up processing every N frames
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi!
- An occasional spike will manifest as a single increase in
underrunDuration
, and an increase inunderrunEvents
by 1. - Consistent underruns will manifest as many small increases in
underrunDuration
, and many increases inunderrunEvents
. - Similar to 1, but periodic. Since the API updates at most once per second (for privacy reasons), this might not be possible to immediately detect if N is small enough that we get several underruns per second. If N is large, it should be possible to see that the underruns occur at regular intervals. Also (if my math is correct)
underrunEvents / currentTime
should converge steadily towardssampleRate / N
, so you could also look for that.
Co-authored-by: Christoph Guttandin <chrisguttandin@media-codings.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments.
index.bs
Outdated
Audio underruns (also commonly called glitches) are gaps in the audio | ||
playout which occur when the audio pipeline cannot deliver audio on time. | ||
Underruns (often manifesting as audible "clicks" in the playout) are bad | ||
for the user experience, so if any of these occur it | ||
can be useful for the application to be able to detect them and possibly | ||
take some action to improve the playout. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Audio underruns (also commonly called glitches) are gaps in the audio | |
playout which occur when the audio pipeline cannot deliver audio on time. | |
Underruns (often manifesting as audible "clicks" in the playout) are bad | |
for the user experience, so if any of these occur it | |
can be useful for the application to be able to detect them and possibly | |
take some action to improve the playout. | |
Audio underruns (also commonly called glitches) are gaps in the audio | |
playback that occur when an audio pipeline cannot deliver audio on time. | |
Underruns (often manifesting as audible "clicks" in the playout) are bad | |
for the user experience, so if any of these occur it | |
can be useful for the application to be able to detect them and possibly | |
take some action to improve the playout. |
we probably need to rephrase this. When the audio isn't delievered on time, it causes an audio underrun, that causes a discontinuity, that causes and audible click, that can be called a glitch. This is because of the synchronous nature of the AudioContext
, unlike for example a PeerConnection
, that will do something when audio input is missing to cover it up.
index.bs
Outdated
{{AudioContext's}} playout path via | ||
{{AudioDestinationNode}} and the associated output device. This allows |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{{AudioContext's}} playout path via | |
{{AudioDestinationNode}} and the associated output device. This allows | |
{{AudioContext's}} playout path via the | |
{{AudioDestinationNode}} and its associated audio output device. This allows |
index.bs
Outdated
applications to measure underruns occurring due to underperforming | ||
AudioWorklets as well as underruns and latency originating in the playout | ||
path between the {{AudioDestinationNode}} and the output device. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is important, but unrelated to AudioWorklet
. We want to point out two possible causes:
- The audio graph itself is too expensive for the current setup -- latency is too low, computer is generally too slow, etc.
- The audio graph itself would render fine, but an external factor causes issues: other audio program on the device, global system overload, overload because of thermal throttling, etc.
it is important to make it extra clear what is being discussed here (especially in relation to the other section).
index.bs
Outdated
{{[[latency reset time]]}}. | ||
</div> | ||
|
||
<h4>Privacy considerations of glitch stats</h4> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use the API name here, and not introduce another term.
covert channel between two cooperating sites. | ||
One site could transmit information by intentionally causing audio glitches | ||
(by causing very high CPU usage, for example) while the other site | ||
could detect these glitches. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but only if:
- There is a linearization point somewhere on the system (typically the audio mixer, be it in the OS or in the browser)
- The callbacks are effectively synchronous all the way from this linearization point, without a buffer in between that could flatten load spikes (that could be because of a different
AudioContextLatencyCategory
).
index.bs
Outdated
<h5 id="AudioPlayoutStats-mitigations">Mitigations</h5> | ||
To inhibit the usage of such a covert channel, the API implements these | ||
mitigations. | ||
- The values returned by the API should not be updated more than once per |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not MUST?
index.bs
Outdated
mitigations. | ||
- The values returned by the API should not be updated more than once per | ||
second. | ||
- The API should be restricted to sites that fulfill at least one of the following |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also why not MUST? Is this normative at all?
index.bs
Outdated
if (playoutDelay > 0.2) { | ||
// Do something to reduce latency, like suggesting alternative | ||
// playout methods | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the current prose makes this example unnecessary, it's already quite clear.
Co-authored-by: Paul Adenot <paul@paul.cx>
Co-authored-by: Paul Adenot <paul@paul.cx>
Integrates the Playout Statistics API for WebAudio spec into the WebAudio spec.
The following changes are made between the version incubated in WICG and this PR:
Related issue: #2642
Preview | Diff