Title: [274435] trunk/Source
Revision
274435
Author
[email protected]
Date
2021-03-15 13:38:55 -0700 (Mon, 15 Mar 2021)

Log Message

[Cocoa] Adopt AudioComponentApplyServerRegistrations()
https://bugs.webkit.org/show_bug.cgi?id=223188
<rdar://75433850>

Reviewed by Eric Carlson.

Source/WebCore/PAL:

* pal/cf/AudioToolboxSoftLink.cpp:
* pal/cf/AudioToolboxSoftLink.h:

Source/WebKit:

The WebKit sandbox will block access to the AudioComponent XPC service when the
GPU process is enabled. Adopt new API to fetch the registered component data from
the priviledged UIProcess and consume that registration data in the WebContent
process, making it unnecessary to communicate with the AudioComponent XPC service
to instantiate components.

* UIProcess/Cocoa/WebProcessProxyCocoa.mm:
(WebKit::WebProcessProxy::sendAudioComponentRegistrations):
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::initializeNewWebProcess):
* UIProcess/WebProcessProxy.h:
* WebProcess/WebProcess.h:
* WebProcess/WebProcess.messages.in:
* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::consumeAudioComponentRegistrations):

Modified Paths

Diff

Modified: trunk/Source/WebCore/PAL/ChangeLog (274434 => 274435)


--- trunk/Source/WebCore/PAL/ChangeLog	2021-03-15 20:11:48 UTC (rev 274434)
+++ trunk/Source/WebCore/PAL/ChangeLog	2021-03-15 20:38:55 UTC (rev 274435)
@@ -1,3 +1,14 @@
+2021-03-15  Jer Noble  <[email protected]>
+
+        [Cocoa] Adopt AudioComponentApplyServerRegistrations()
+        https://bugs.webkit.org/show_bug.cgi?id=223188
+        <rdar://75433850>
+
+        Reviewed by Eric Carlson.
+
+        * pal/cf/AudioToolboxSoftLink.cpp:
+        * pal/cf/AudioToolboxSoftLink.h:
+
 2021-03-13  Tim Horton  <[email protected]>
 
         Adopt DDMacAction instead of DDAction on macOS

Modified: trunk/Source/WebCore/PAL/pal/cf/AudioToolboxSoftLink.cpp (274434 => 274435)


--- trunk/Source/WebCore/PAL/pal/cf/AudioToolboxSoftLink.cpp	2021-03-15 20:11:48 UTC (rev 274434)
+++ trunk/Source/WebCore/PAL/pal/cf/AudioToolboxSoftLink.cpp	2021-03-15 20:38:55 UTC (rev 274435)
@@ -32,10 +32,14 @@
 #include <wtf/SoftLinking.h>
 
 SOFT_LINK_FRAMEWORK_FOR_SOURCE(PAL, AudioToolbox)
+SOFT_LINK_PRIVATE_FRAMEWORK_FOR_SOURCE_WITH_EXPORT(PAL, AudioToolboxCore, PAL_EXPORT)
 
 SOFT_LINK_FUNCTION_FOR_SOURCE(PAL, AudioToolbox, AudioFormatGetProperty, OSStatus, (AudioFormatPropertyID inPropertyID, UInt32 inSpecifierSize, const void* inSpecifier, UInt32* ioPropertyDataSize, void* outPropertyData), (inPropertyID, inSpecifierSize, inSpecifier, ioPropertyDataSize, outPropertyData))
 SOFT_LINK_FUNCTION_FOR_SOURCE(PAL, AudioToolbox, AudioConverterNew, OSStatus, (const AudioStreamBasicDescription* inSourceFormat, const AudioStreamBasicDescription* inDestinationFormat, AudioConverterRef* outAudioConverter), (inSourceFormat, inDestinationFormat, outAudioConverter))
 SOFT_LINK_FUNCTION_FOR_SOURCE(PAL, AudioToolbox, AudioConverterSetProperty, OSStatus, (AudioConverterRef inAudioConverter, AudioConverterPropertyID inPropertyID, UInt32 inPropertyDataSize, const void* inPropertyData), (inAudioConverter, inPropertyID, inPropertyDataSize, inPropertyData))
 SOFT_LINK_FUNCTION_FOR_SOURCE(PAL, AudioToolbox, AudioConverterGetProperty, OSStatus, (AudioConverterRef inAudioConverter, AudioConverterPropertyID inPropertyID, UInt32* ioPropertyDataSize, void* outPropertyData), (inAudioConverter, inPropertyID, ioPropertyDataSize, outPropertyData))
+SOFT_LINK_FUNCTION_MAY_FAIL_FOR_SOURCE_WITH_EXPORT(PAL, AudioToolboxCore, AudioComponentFetchServerRegistrations, OSStatus, (CFDataRef* outBundleRegistrations), (outBundleRegistrations), PAL_EXPORT)
+SOFT_LINK_FUNCTION_MAY_FAIL_FOR_SOURCE_WITH_EXPORT(PAL, AudioToolboxCore, AudioComponentApplyServerRegistrations, OSStatus, (CFDataRef inBundleRegistrations), (inBundleRegistrations), PAL_EXPORT)
 
+
 #endif // USE(AVFOUNDATION)

Modified: trunk/Source/WebCore/PAL/pal/cf/AudioToolboxSoftLink.h (274434 => 274435)


--- trunk/Source/WebCore/PAL/pal/cf/AudioToolboxSoftLink.h	2021-03-15 20:11:48 UTC (rev 274434)
+++ trunk/Source/WebCore/PAL/pal/cf/AudioToolboxSoftLink.h	2021-03-15 20:38:55 UTC (rev 274435)
@@ -28,7 +28,13 @@
 
 #include <wtf/SoftLinking.h>
 
+typedef UInt32 AudioConverterPropertyID;
+typedef UInt32 AudioFormatPropertyID;
+typedef struct AudioStreamBasicDescription AudioStreamBasicDescription;
+typedef struct OpaqueAudioConverter* AudioConverterRef;
+
 SOFT_LINK_FRAMEWORK_FOR_HEADER(PAL, AudioToolbox)
+SOFT_LINK_FRAMEWORK_FOR_HEADER(PAL, AudioToolboxCore)
 
 SOFT_LINK_FUNCTION_FOR_HEADER(PAL, AudioToolbox, AudioConverterGetProperty, OSStatus, (AudioConverterRef inAudioConverter, AudioConverterPropertyID inPropertyID, UInt32* ioPropertyDataSize, void* outPropertyData), (inAudioConverter, inPropertyID, ioPropertyDataSize, outPropertyData))
 #define AudioConverterGetProperty softLink_AudioToolbox_AudioConverterGetProperty
@@ -38,6 +44,9 @@
 #define AudioConverterSetProperty softLink_AudioToolbox_AudioConverterSetProperty
 SOFT_LINK_FUNCTION_FOR_HEADER(PAL, AudioToolbox, AudioFormatGetProperty, OSStatus, (AudioFormatPropertyID inPropertyID, UInt32 inSpecifierSize, const void* inSpecifier, UInt32* ioPropertyDataSize, void* outPropertyData), (inPropertyID, inSpecifierSize, inSpecifier, ioPropertyDataSize, outPropertyData))
 #define AudioFormatGetProperty softLink_AudioToolbox_AudioFormatGetProperty
+SOFT_LINK_FUNCTION_MAY_FAIL_FOR_HEADER(PAL, AudioToolboxCore, AudioComponentFetchServerRegistrations, OSStatus, (CFDataRef* outBundleRegistrations), (outBundleRegistrations))
+#define AudioComponentFetchServerRegistrations softLinkAudioToolboxCoreAudioComponentFetchServerRegistrations
+SOFT_LINK_FUNCTION_MAY_FAIL_FOR_HEADER(PAL, AudioToolboxCore, AudioComponentApplyServerRegistrations, OSStatus, (CFDataRef inBundleRegistrations), (inBundleRegistrations))
+#define AudioComponentApplyServerRegistrations softLinkAudioToolboxCoreAudioComponentApplyServerRegistrations
 
-
 #endif // USE(AVFOUNDATION)

Modified: trunk/Source/WebKit/ChangeLog (274434 => 274435)


--- trunk/Source/WebKit/ChangeLog	2021-03-15 20:11:48 UTC (rev 274434)
+++ trunk/Source/WebKit/ChangeLog	2021-03-15 20:38:55 UTC (rev 274435)
@@ -1,3 +1,27 @@
+2021-03-15  Jer Noble  <[email protected]>
+
+        [Cocoa] Adopt AudioComponentApplyServerRegistrations()
+        https://bugs.webkit.org/show_bug.cgi?id=223188
+        <rdar://75433850>
+
+        Reviewed by Eric Carlson.
+
+        The WebKit sandbox will block access to the AudioComponent XPC service when the
+        GPU process is enabled. Adopt new API to fetch the registered component data from
+        the priviledged UIProcess and consume that registration data in the WebContent
+        process, making it unnecessary to communicate with the AudioComponent XPC service
+        to instantiate components.
+
+        * UIProcess/Cocoa/WebProcessProxyCocoa.mm:
+        (WebKit::WebProcessProxy::sendAudioComponentRegistrations):
+        * UIProcess/WebProcessPool.cpp:
+        (WebKit::WebProcessPool::initializeNewWebProcess):
+        * UIProcess/WebProcessProxy.h:
+        * WebProcess/WebProcess.h:
+        * WebProcess/WebProcess.messages.in:
+        * WebProcess/cocoa/WebProcessCocoa.mm:
+        (WebKit::WebProcess::consumeAudioComponentRegistrations):
+
 2021-03-15  Kimmo Kinnunen  <[email protected]>
 
         WebGL IPC should use shared memory for synchronous messages

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebProcessProxyCocoa.mm (274434 => 274435)


--- trunk/Source/WebKit/UIProcess/Cocoa/WebProcessProxyCocoa.mm	2021-03-15 20:11:48 UTC (rev 274434)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebProcessProxyCocoa.mm	2021-03-15 20:38:55 UTC (rev 274435)
@@ -31,6 +31,7 @@
 #import "Logging.h"
 #import "ObjCObjectGraph.h"
 #import "SandboxUtilities.h"
+#import "SharedBufferDataReference.h"
 #import "WKBrowsingContextControllerInternal.h"
 #import "WKBrowsingContextHandleInternal.h"
 #import "WKTypeRefWrapper.h"
@@ -58,6 +59,8 @@
 SOFT_LINK_CONSTANT(TCC, kTCCServiceAccessibility, CFStringRef)
 #endif
 
+#import <pal/cf/AudioToolboxSoftLink.h>
+
 namespace WebKit {
 
 static const Seconds unexpectedActivityDuration = 10_s;
@@ -281,4 +284,19 @@
 }
 #endif
 
+void WebProcessProxy::sendAudioComponentRegistrations()
+{
+    using namespace PAL;
+
+    if (!isAudioToolboxCoreFrameworkAvailable() || !canLoad_AudioToolboxCore_AudioComponentFetchServerRegistrations())
+        return;
+
+    CFDataRef registrations { nullptr };
+    if (noErr != AudioComponentFetchServerRegistrations(&registrations) || !registrations)
+        return;
+
+    auto registrationData = SharedBuffer::create(registrations);
+    send(Messages::WebProcess::ConsumeAudioComponentRegistrations({ registrationData }), 0);
 }
+
+}

Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.cpp (274434 => 274435)


--- trunk/Source/WebKit/UIProcess/WebProcessPool.cpp	2021-03-15 20:11:48 UTC (rev 274434)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.cpp	2021-03-15 20:38:55 UTC (rev 274435)
@@ -859,6 +859,10 @@
     process.send(Messages::WebProcess::BacklightLevelDidChange(displayBrightness()), 0);
 #endif
 
+#if PLATFORM(COCOA)
+    process.sendAudioComponentRegistrations();
+#endif
+
 #if PLATFORM(MAC)
     registerDisplayConfigurationCallback();
 #endif

Modified: trunk/Source/WebKit/UIProcess/WebProcessProxy.h (274434 => 274435)


--- trunk/Source/WebKit/UIProcess/WebProcessProxy.h	2021-03-15 20:11:48 UTC (rev 274434)
+++ trunk/Source/WebKit/UIProcess/WebProcessProxy.h	2021-03-15 20:38:55 UTC (rev 274435)
@@ -334,6 +334,8 @@
     bool hasAudioCaptureExtension() const { return m_mediaCaptureSandboxExtensions & Audio; }
     void grantAudioCaptureExtension() { m_mediaCaptureSandboxExtensions |= Audio; }
     void revokeAudioCaptureExtension() { m_mediaCaptureSandboxExtensions &= ~Audio; }
+
+    void sendAudioComponentRegistrations();
 #endif
 
 #if ENABLE(REMOTE_INSPECTOR) && PLATFORM(COCOA)

Modified: trunk/Source/WebKit/WebProcess/WebProcess.h (274434 => 274435)


--- trunk/Source/WebKit/WebProcess/WebProcess.h	2021-03-15 20:11:48 UTC (rev 274434)
+++ trunk/Source/WebKit/WebProcess/WebProcess.h	2021-03-15 20:38:55 UTC (rev 274435)
@@ -74,6 +74,10 @@
 class Object;
 }
 
+namespace IPC {
+class SharedBufferDataReference;
+}
+
 namespace PAL {
 class SessionID;
 }
@@ -511,6 +515,10 @@
     void systemWillSleep();
     void systemDidWake();
 #endif
+
+#if PLATFORM(COCOA)
+    void consumeAudioComponentRegistrations(const IPC::DataReference&);
+#endif
     
     void platformInitializeProcess(const AuxiliaryProcessInitializationParameters&);
 

Modified: trunk/Source/WebKit/WebProcess/WebProcess.messages.in (274434 => 274435)


--- trunk/Source/WebKit/WebProcess/WebProcess.messages.in	2021-03-15 20:11:48 UTC (rev 274434)
+++ trunk/Source/WebKit/WebProcess/WebProcess.messages.in	2021-03-15 20:38:55 UTC (rev 274435)
@@ -196,4 +196,8 @@
     SystemWillSleep()
     SystemDidWake()
 #endif
+
+#if PLATFORM(COCOA)
+    ConsumeAudioComponentRegistrations(IPC::SharedBufferDataReference registrationData)
+#endif
 }

Modified: trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm (274434 => 274435)


--- trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2021-03-15 20:11:48 UTC (rev 274434)
+++ trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2021-03-15 20:38:55 UTC (rev 274435)
@@ -144,6 +144,7 @@
 #import <os/state_private.h>
 #endif
 
+#import <pal/cf/AudioToolboxSoftLink.h>
 #import <pal/cocoa/AVFoundationSoftLink.h>
 #import <pal/cocoa/MediaToolboxSoftLink.h>
 
@@ -1270,6 +1271,22 @@
 }
 #endif
 
+void WebProcess::consumeAudioComponentRegistrations(const IPC::DataReference& data)
+{
+    using namespace PAL;
+
+    if (!isAudioToolboxCoreFrameworkAvailable() || !canLoad_AudioToolboxCore_AudioComponentApplyServerRegistrations())
+        return;
+
+    auto registrations = adoptCF(CFDataCreate(kCFAllocatorDefault, data.data(), data.size()));
+    if (!registrations)
+        return;
+
+    auto err = AudioComponentApplyServerRegistrations(registrations.get());
+    if (noErr != err)
+        RELEASE_LOG_ERROR_IF_ALLOWED(Process, "Could not apply AudioComponent registrations, err(%ld)", static_cast<long>(err));
+}
+
 } // namespace WebKit
 
 #undef RELEASE_LOG_SESSION_ID
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to