[webkit-changes] [WebKit/WebKit] 346895: [Cocoa] RemoteAudioDestinationProxy threads are cr...

Jer Noble noreply at github.com
Fri Sep 15 19:29:49 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 3468951fe890ae71911f72a444617be38c39c14f
      https://github.com/WebKit/WebKit/commit/3468951fe890ae71911f72a444617be38c39c14f
  Author: Jer Noble <jer.noble at apple.com>
  Date:   2023-09-15 (Fri, 15 Sep 2023)

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

  Log Message:
  -----------
  [Cocoa] RemoteAudioDestinationProxy threads are created with too low a priority for realtime audio
https://bugs.webkit.org/show_bug.cgi?id=261619
rdar://115513480

Reviewed by Chris Dumez.

On macOS and iOS, when a thread is configured for a QOS, it can be de-prioritized
by the scheduler when workloads are heavy, and will then be pre-empted by higher-priority
threads. When a RemoteAudioDestinationProxy render thread is pre-empted, this manifests
as an audible "stutter" or "skip" in the resulting WebAudio output.

The CoreAudio Audio IO thread is configured to run as a Realtime thread, which opts out of
the QOS de-prioritization logic. It also runs at a very high priority level, 97.

Configure the RemoteAudioDestinationProxy render thread similarly to the CoreAudio IO thread.
This requires adding a "SchedulingPolicy" enum to Thread.h and implementing that policy in
ThreadingPOSIX.cpp. (The Windows Threading implementation already ignores QOS; it will
further ignore SchedulingPolicy).  The Linux (POSIX) port has its own implementation of
scheduling policy, which treats UserInteractive as Realtime. Retain this logic, and only apply
a specific scheduling policy when it's explicitly set.

* Source/WTF/wtf/PlatformHave.h:
* Source/WTF/wtf/Threading.cpp:
(WTF::Thread::create):
* Source/WTF/wtf/Threading.h:
* Source/WTF/wtf/posix/ThreadingPOSIX.cpp:
(WTF::schedPolicy):
(WTF::Thread::establishHandle):
* Source/WTF/wtf/win/ThreadingWin.cpp:
(WTF::Thread::establishHandle):
* Source/WebKit/WebProcess/GPU/media/RemoteAudioDestinationProxy.cpp:
(WebKit::RemoteAudioDestinationProxy::startRenderingThread):

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




More information about the webkit-changes mailing list