Skip to content

Conversation

@Hernqvist
Copy link

@Hernqvist Hernqvist commented Sep 16, 2025

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:

  • "fallback"/"fallbackFrames" terminology is replaced with "underrun".
  • Duration types are changed from DOMHighResTimestamp to double.
  • Time units are changed from milliseconds to seconds.

Related issue: #2642


Preview | Diff

Copy link
Member

@hoch hoch left a 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?

@Hernqvist
Copy link
Author

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!

Copy link
Member

@hoch hoch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@hoch hoch requested a review from padenot September 18, 2025 15:58
@hoch
Copy link
Member

hoch commented Sep 18, 2025

@padenot Could you take a look?

index.bs Outdated
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]]}}

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

  1. occasional spike
  2. consistent overload -> consistent underruns (every quantum processed)
  3. periodic overload. as an example, a misaligned block based computation that ends up processing every N frames

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi!

  1. An occasional spike will manifest as a single increase in underrunDuration, and an increase in underrunEvents by 1.
  2. Consistent underruns will manifest as many small increases in underrunDuration, and many increases in underrunEvents.
  3. 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 towards sampleRate / N, so you could also look for that.

Co-authored-by: Christoph Guttandin <chrisguttandin@media-codings.com>
Copy link
Member

@padenot padenot left a 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
Comment on lines 11570 to 11575
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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I rephrased, how about now?

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.
Copy link
Member

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).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, the side channel is likely only possible/efficient on a subset of systems, but should we mention this in the spec?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to have a sentence or two about this yes, to convey a nuanced level of importance.

Hernqvist and others added 2 commits September 30, 2025 16:40
Co-authored-by: Paul Adenot <paul@paul.cx>
Co-authored-by: Paul Adenot <paul@paul.cx>
@Hernqvist Hernqvist force-pushed the playoutstats branch 2 times, most recently from f36f524 to 92be88e Compare October 13, 2025 14:56
Copy link
Author

@Hernqvist Hernqvist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review!

index.bs Outdated
Comment on lines 11570 to 11575
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.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I rephrased, how about now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants