[webkit-changes] [WebKit/WebKit] a78127: [Cocoa] Audio distortion during media playback whe...

Jer Noble noreply at github.com
Fri Feb 23 16:07:38 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: a78127adb38a402b5d0fe6b17367aba32a38eb22
      https://github.com/WebKit/WebKit/commit/a78127adb38a402b5d0fe6b17367aba32a38eb22
  Author: Jer Noble <jer.noble at apple.com>
  Date:   2024-02-23 (Fri, 23 Feb 2024)

  Changed paths:
    M Source/WebCore/Headers.cmake
    M Source/WebCore/Sources.txt
    M Source/WebCore/WebCore.xcodeproj/project.pbxproj
    A Source/WebCore/platform/audio/SharedAudioDestination.cpp
    A Source/WebCore/platform/audio/SharedAudioDestination.h
    M Source/WebCore/platform/audio/cocoa/AudioDestinationCocoa.cpp
    M Source/WebCore/platform/graphics/MediaSourcePrivate.cpp
    M Source/WebKit/WebProcess/GPU/media/WebMediaStrategy.cpp

  Log Message:
  -----------
  [Cocoa] Audio distortion during media playback when many AudioContexts are created
https://bugs.webkit.org/show_bug.cgi?id=269833
rdar://122590884

Reviewed by Chris Dumez.

In WebKit, each AudioContext created results in an additional thread serving that context's
AudioDestination. (In WebKitLegacy, each AudioContext will result in an additional
AudioOutputUnit running on a single high-priority audio thread.) When many threads
(or AudioOutputUnits) are created, the overhead alone can cause underruns. And when this
happens on the high-priority audio thread, it affects all audio playback within that
process.

Rather than create new threads or AudioOutputUnits (that are all rendering on the same
thread to the same buffer in the end) for each AudioContext, a shared AudioDestination
can be used for multiple AudioContext's with the same number of channels and sample rate.
For common scenarios, this means only one high-priority audio thread will be created
and serviced by a single AudioDestination. Specifically for WebKit, it means a single
RemoteAudioDestination/Proxy pair for each WebContent process.

* Source/WebCore/platform/audio/SharedAudioDestination.cpp: Added.
(WebCore::SharedAudioDestinationAdapter::framesPerBuffer const):
(WebCore::SharedAudioDestinationAdapter::sharedMap):
(WebCore::SharedAudioDestinationAdapter::ensureAdapter):
(WebCore::SharedAudioDestinationAdapter::SharedAudioDestinationAdapter):
(WebCore::m_configurationSemaphore):
(WebCore::SharedAudioDestinationAdapter::addRenderer):
(WebCore::SharedAudioDestinationAdapter::removeRenderer):
(WebCore::SharedAudioDestinationAdapter::configureRenderThread):
(WebCore::SharedAudioDestinationAdapter::render):
(WebCore::SharedAudioDestination::create):
(WebCore::SharedAudioDestination::SharedAudioDestination):
(WebCore::SharedAudioDestination::~SharedAudioDestination):
(WebCore::SharedAudioDestination::start):
(WebCore::SharedAudioDestination::stop):
(WebCore::SharedAudioDestination::framesPerBuffer const):
(WebCore::SharedAudioDestination::setIsPlaying):
* Source/WebCore/platform/audio/SharedAudioDestination.h: Added.
* Source/WebCore/platform/audio/cocoa/AudioDestinationCocoa.cpp:
(WebCore::AudioDestination::create):
* Source/WebKit/WebProcess/GPU/media/WebMediaStrategy.cpp:
(WebKit::WebMediaStrategy::createAudioDestination):

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



To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications


More information about the webkit-changes mailing list