Closed Bug 1880244 Opened 9 months ago Closed 7 months ago

With duplex streams, stream_init and stream_destroy are slow on Mac

Categories

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

defect

Tracking

()

RESOLVED FIXED
126 Branch
Tracking Status
firefox126 --- fixed

People

(Reporter: pehrsons, Assigned: pehrsons)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 1 obsolete file)

Because of the VoiceProcessingIO audio unit we started using in bug 1670633, creating (mainly) and destroying (somewhat) a duplex stream is very slow because creating (mainly) and destroying (somewhat) a VoiceProcessingIO audio unit is very slow. This caused bug 1878380 and while that bug fixes the video freeze during device reconfiguration in Meet, audio input and output are still frozen for the time the reconfiguration takes, while UX is not informing the user of this.

We can speed this up with a couple of tricks:

  • Have gecko tell the cubeb backend it is planning to use input audio, the backend then, async, creates a VoiceProcessingIO audio unit and caches it.
    • Creating and immediately destroying a duplex stream without the VOICE pref will be quick and can be used by the backend as the signal.
  • Optionally as part of getUserMedia wait for creating and immediately destroying a duplex stream with the VOICE pref such that this will wait until the cached VoiceProcessingIO audio unit is ready, to ensure that getUserMedia does not resolve seconds before audio flows, possibly leading to unexpected UX.
  • In the backend only allow one duplex stream per context to use VoiceProcessingIO.
    • One document will only ever request one duplex stream, however
    • ...there is up to one context per process, i.e. all documents within a process share the context, so
    • ...in a scenario where two tabs are sitting in a room, only the first to request audio input would get VoiceProcessingIO. Fortunately, this is not a common real-world use case.
  • Re-use the VoiceProcessingIO audio unit by returning it to the cache on stream_destroy.
Blocks: 1881609
Attachment #9390302 - Attachment description: Bug 1880244 WIP - Update cubeb-coreaudio-rs. → Bug 1880244 - Update cubeb-coreaudio-rs to 2e27b80665. r?#cubeb-reviewers
Attachment #9390302 - Attachment description: Bug 1880244 - Update cubeb-coreaudio-rs to 2e27b80665. r?#cubeb-reviewers → WIP: Bug 1880244 - Update cubeb-coreaudio-rs to 65f718b423. r?#cubeb-reviewers
Attachment #9390302 - Attachment description: WIP: Bug 1880244 - Update cubeb-coreaudio-rs to 65f718b423. r?#cubeb-reviewers → Bug 1880244 - Update cubeb-coreaudio-rs to 361d2bbe65. r?#cubeb-reviewers
Attachment #9390303 - Attachment is obsolete: true
Attachment #9390302 - Attachment description: Bug 1880244 - Update cubeb-coreaudio-rs to 361d2bbe65. r?#cubeb-reviewers → Bug 1880244 - Update cubeb-coreaudio-rs to 7b10217149. r?#cubeb-reviewers

I rewrote the priming patch after the latest cubeb backend updates. The priming is typically user-observable though, and I currently don't have a way to avoid priming when there is a persistent block on gUM audio for a given site. For now I'm deferring priming as future work. If I figure out a decent way to avoid priming when the user has persistently blocked gUM audio I'll file a followup.

Pushed by pehrsons@gmail.com: https://hg.mozilla.org/integration/autoland/rev/17662e43cc85 Update cubeb-coreaudio-rs to 7b10217149. r=cubeb-reviewers,padenot
Blocks: 1890873
Status: ASSIGNED → RESOLVED
Closed: 7 months ago
Resolution: --- → FIXED
Target Milestone: --- → 126 Branch

Hey Andreas, do you still think this work will address Bug 1879093?

Flags: needinfo?(apehrson)

I think it will affect the numbers as a mitigation but it might not address the crash signatures fully. The root cause seems to be an OS library issue after all. Should fully adress the reported use case though.

Flags: needinfo?(apehrson)
Regressions: 1893106
Blocks: 1871417
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: