Bug 263074

Summary: WebAudio: Limit the number of realtime audio threads, and constrain their runtime
Product: WebKit Reporter: Jer Noble <jer.noble>
Component: MediaAssignee: Jer Noble <jer.noble>
Status: RESOLVED FIXED    
Severity: Normal CC: webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Other   
Hardware: Unspecified   
OS: Unspecified   

Description Jer Noble 2023-10-12 08:40:04 PDT
In 268047@main, RemoteAudioDestinationProxy threads were made to run in realtime mode, thereby avoiding audible stutters and dropouts in periods of high thread contention. However realtime threads come at a cost, and creating too many realtime threads is problematic from a kernel scheduling perspective. In some degenerate cases, sites can create many, many AudioContexts, each with their own realtime thread. Long term, this should be fixed via bug #263073, by coalescing compatable threads together. Until then, limit the number of concurrent realtime audio threads that can be created to 3, and adopt threading APIs (on Darwin OSs, for now) to constrain the runtime of these threads such that, when exceeded, the scheduler will demote the priority and runtime class of the thread to normal values.
Comment 1 Radar WebKit Bug Importer 2023-10-12 08:40:20 PDT
<rdar://problem/116864442>
Comment 2 Jer Noble 2023-10-12 09:28:56 PDT
Pull request: https://github.com/WebKit/WebKit/pull/19000
Comment 3 EWS 2023-10-12 18:53:26 PDT
Committed 269291@main (02ffbc50d8a6): <https://commits.webkit.org/269291@main>

Reviewed commits have been landed. Closing PR #19000 and removing active labels.