Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 02ffbc50d8a6ce4d67e41c7137f58f0ff1f883ec
      
https://github.com/WebKit/WebKit/commit/02ffbc50d8a6ce4d67e41c7137f58f0ff1f883ec
  Author: Jer Noble <jer.no...@apple.com>
  Date:   2023-10-12 (Thu, 12 Oct 2023)

  Changed paths:
    M Source/WTF/wtf/PlatformHave.h
    M Source/WTF/wtf/Threading.h
    M Source/WTF/wtf/posix/ThreadingPOSIX.cpp
    M Source/WebKit/WebProcess/GPU/media/RemoteAudioDestinationProxy.cpp
    M Source/WebKit/WebProcess/GPU/media/RemoteAudioDestinationProxy.h

  Log Message:
  -----------
  WebAudio: Limit the number of realtime audio threads, and constrain their 
runtime
https://bugs.webkit.org/show_bug.cgi?id=263074
rdar://116864442

Reviewed by Chris Dumez.

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.

Limit the number of concurrent realtime audio threads that can be created to 3. 
This should allow
well behaved sites to use a small number of concurrent AudioContexts (e.g., 
with different
latencies and sample rates), while still mitigating the impact of degenerate 
sites making tens or
even hundreds of AudioContexts.

Additionally, adopt threading APIs (on Darwin OSs, for now) to constrain the 
runtime characteristics
of these threads. These time constraints will inform the kernel scheduler what 
the predicted
periodicty and runtime duration of these realtime threads are, and these limits 
are derivable from
the size of the WebAudio rendering quantum size and its sample rate. When these 
limits are
exceeded, the scheduler will de-prioritize the realtime thread, reverting it to 
a standard QOS
thread.

Together, these two limits will mitigate the impact of creating many realtime 
threads, as well as
mitigating the impact of a small number of poorly behaving realtime threads.

* Source/WTF/wtf/PlatformHave.h:
* Source/WTF/wtf/Threading.h:
* Source/WTF/wtf/posix/ThreadingPOSIX.cpp:
(WTF::Thread::setThreadTimeConstraints):
* Source/WebKit/WebProcess/GPU/media/RemoteAudioDestinationProxy.cpp:
(WebKit::RemoteAudioDestinationProxy::startRenderingThread):
(WebKit::RemoteAudioDestinationProxy::stopRenderingThread):
* Source/WebKit/WebProcess/GPU/media/RemoteAudioDestinationProxy.h:

Canonical link: https://commits.webkit.org/269291@main


_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to