Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 4f1a121947d3614fbc3edf5f372ec7c297c38074
      
https://github.com/WebKit/WebKit/commit/4f1a121947d3614fbc3edf5f372ec7c297c38074
  Author: Youenn Fablet <[email protected]>
  Date:   2023-11-22 (Wed, 22 Nov 2023)

  Changed paths:
    M Source/WTF/wtf/NativePromise.h
    M Source/WebCore/platform/mediastream/mac/BaseAudioSharedUnit.h
    M Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.cpp
    M Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.h
    M Source/WebCore/platform/mediastream/mac/CoreAudioSharedUnit.cpp
    M Source/WebCore/platform/mediastream/mac/CoreAudioSharedUnit.h
    M Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp
    M Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.h

  Log Message:
  -----------
  [macOS] Create a VPIO unit in a background thread
https://bugs.webkit.org/show_bug.cgi?id=265017
rdar://118520768

Reviewed by Jean-Yves Avenard.

A VPIO Unit may take a few seconds to be created.
This might block the GPU process main thread, which might block the WebProcess 
main thread.
The impact might be a page freeze.
To prevent this, we create the VPIO unit in a background queue and 
asynchronously start capturing.

To do so, CoreAudioCaptureSource is implementing 
RealtimeMediaSource::whenReady, where we prewarm the audio unit.
The impact is to delay the resolution of the getUserMedia promise.

To improve the handling of AudioUnit, we introduce StoredAudioUnit to make sure 
we always dispose a created audio unit.
We then refactor the code to use move-only audio units.

Covered by existing tests in macOS with MockAudioSharedUnit.
Manually tested as well.

* Source/WTF/wtf/NativePromise.h:
* Source/WebCore/platform/mediastream/mac/BaseAudioSharedUnit.h:
(WebCore::BaseAudioSharedUnit::prewarmAudioUnitCreation):
* Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.cpp:
(WebCore::CoreAudioCaptureSource::whenReady):
* Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.h:
* Source/WebCore/platform/mediastream/mac/CoreAudioSharedUnit.cpp:
(WebCore::CoreAudioSharedUnit::AudioUnitDeallocator::operator() const):
(WebCore::createAudioUnit):
(WebCore::CoreAudioSharedInternalUnit::create):
(WebCore::CoreAudioSharedInternalUnit::CoreAudioSharedInternalUnit):
(WebCore::CoreAudioSharedInternalUnit::~CoreAudioSharedInternalUnit):
(WebCore::CoreAudioSharedInternalUnit::initialize):
(WebCore::CoreAudioSharedInternalUnit::uninitialize):
(WebCore::CoreAudioSharedInternalUnit::start):
(WebCore::CoreAudioSharedInternalUnit::stop):
(WebCore::CoreAudioSharedInternalUnit::set):
(WebCore::CoreAudioSharedInternalUnit::get):
(WebCore::CoreAudioSharedInternalUnit::render):
(WebCore::CoreAudioSharedUnit::~CoreAudioSharedUnit):
(WebCore::CoreAudioSharedUnit::setStoredVPIOUnit):
(WebCore::CoreAudioSharedUnit::reconfigureAudioUnit):
(WebCore::CoreAudioSharedUnit::migrateToNewDefaultDevice):
(WebCore::CoreAudioSharedUnit::prewarmAudioUnitCreation):
(WebCore::CoreAudioSharedInternalUnit::storeVPIOUnitIfNeeded): Deleted.
* Source/WebCore/platform/mediastream/mac/CoreAudioSharedUnit.h:
* Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp:
(WebKit::UserMediaCaptureManagerProxy::createMediaSourceForCaptureDeviceWithConstraints):

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


_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to