Open Bug 1895773 Opened 2 years ago Updated 9 days ago

Audio stutters when other tabs call `new AudioContext` [MaxxAudioAPO driver]

Categories

(Core :: Audio/Video: cubeb, defect, P3)

defect

Tracking

()

ASSIGNED

People

(Reporter: tcampbell, Assigned: kinetik)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

STR:

  1. Play music in a background tab. Both Spotify and YouTube reproduce for me.
  2. In a new tab navigate to https://ubuntu.com/blog/canonical-releases-landscape-24-04-lts

Expected:
Music continues to play

Actual:
Audio stutters for half a second / is chopped up

CPU isn't maxed when this happens (and when I do stress foreground tab to max out CPU, the audio still runs smooth). It is possible this is some weird pageload scheduling quirk but media team might have some ideas here.

Here is a profile with Media Preset: https://share.firefox.dev/3WsI8lj

  • I load the page normally, and also refresh it once. Each time there is a consistent stutter for me.

This shows up prominently here on the MDSM thread: https://share.firefox.dev/3wqWoAm

alwu, any guesses what might be going wrong here?

Flags: needinfo?(alwu)

Calling new AudioContext for the first time in a new process is all that is needed to trigger the stuttering.

Summary: Background tab audio (Spotify/Youtube) stutters during pageload of Ubuntu Blog → Background tab audio (Spotify/Youtube) stutters the first time any other tab calls `new AudioContext`
Attached file bug1895773.html —

Here is a minimal version that hits the issue for me. This is all done in one page, but the stutter happens even if running in separate processes.

  • Start audio playback with play button
  • Hit "stutter' button

I think this is related with AudioIPC or Cubeb.

By checking the profiled result from the comment1, first you can notice that there are some AudioStream::GetPosition markers taking very long time, which blocks the MediaDecoderStateMachine thread so no audio decoding happened during that period of time. As no audio data were pushed into the audio queue, it caused the audio underrun in AudioIPC Client Callback thread (see AudioSink::PopFrames - Underrun 480 frames missing), which would push silence and result in audio stuttering.

I couldn't reproduce this issue on my Windows 11, but the reporter is also on a Windows 11. So I suspect that the different audio setup causes the problem. It's somehow understandable that the issue happens when creating a AudioContext because the underlying audio clock driver of AudioContext would open a new cubeb stream.

By further checking the flame graph, the most time we spent is inside the audio ipc code. That indicates on some audio setup, creating a new cubeb stream might affect the existing cubeb stream.

Component: Audio/Video → Audio/Video: cubeb
Flags: needinfo?(alwu)

Matthew, would you mind to take a look on this issue? Thanks!

Severity: -- → S3
Flags: needinfo?(kinetik)
Priority: -- → P2

Here is a simplified profile of the test case I attached: https://share.firefox.dev/3wiQIZn
The cubeb_stream_init calls are 1100ms and 600ms, and seem to block the AudioIPC Server RPC thread which results in results in the playing audio cutting out each time an new AudioIPC Client creates a stream object.

Here is a pretty minimal ETW profile showing the problem: https://share.firefox.dev/4bcDKeA
The system I'm having trouble with is using the MaxxAudioAPO.dll driver which seems to take 500+ms to open the audio stream.

Summary: Background tab audio (Spotify/Youtube) stutters the first time any other tab calls `new AudioContext` → Audio stutters when other tabs call `new AudioContext` [MaxxAudioAPO driver]

Ted, does the same thing happen in Chrome?

Flags: needinfo?(tcampbell)

Chrome ETW profile: https://share.firefox.dev/3wx2KOH

The audio playback in Chrome is smooth even though I see the same MaxxAudioAPO slowdown when creating streams (and new AudioContext does create the stream immediately similar to us). The Audio Device Thread seems to run along smoothly even as the new stream is created.

Flags: needinfo?(tcampbell)
Assignee: nobody → kinetik
Status: NEW → ASSIGNED
Flags: needinfo?(kinetik)
Priority: P2 → P3
Duplicate of this bug: 2059968
Duplicate of this bug: 2090573
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: