Title: [291296] trunk/Source
Revision
291296
Author
jer.no...@apple.com
Date
2022-03-15 09:40:55 -0700 (Tue, 15 Mar 2022)

Log Message

[Cocoa] Adopt AVAssetPrefersSandboxedParsingOptionKey
https://bugs.webkit.org/show_bug.cgi?id=237832
<rdar://89029829>

Reviewed by Eric Carlson.

Source/WebCore:

Adopt a AVURLAsset option which would allow the media file parser to run out-of-process.
Because this adoption may have a performance impact (though it should not affect the
functionality of AVURLAsset), add a Setting to disable this adoption at runtime for the
purpose of A/B testing.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::requestInstallMissingPlugins):
* html/HTMLMediaElement.h:
* platform/graphics/MediaPlayer.h:
(WebCore::MediaPlayerClient::mediaPlayerPrefersSandboxedParsing const):
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::createAVAssetForURL):

Source/WebCore/PAL:

* pal/cocoa/AVFoundationSoftLink.h:

Source/WebKit:

Propogate the `prefersSandboxedParsing()` property across to the GPU process.

* GPUProcess/media/RemoteMediaPlayerProxy.h:
* GPUProcess/media/RemoteMediaPlayerProxyConfiguration.h:
(WebKit::RemoteMediaPlayerProxyConfiguration::encode const):
(WebKit::RemoteMediaPlayerProxyConfiguration::decode):
* WebProcess/GPU/media/RemoteMediaPlayerManager.cpp:
(WebKit::RemoteMediaPlayerManager::createRemoteMediaPlayer):

Source/WTF:

* Scripts/Preferences/WebPreferencesInternal.yaml:

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (291295 => 291296)


--- trunk/Source/WTF/ChangeLog	2022-03-15 16:37:20 UTC (rev 291295)
+++ trunk/Source/WTF/ChangeLog	2022-03-15 16:40:55 UTC (rev 291296)
@@ -1,3 +1,13 @@
+2022-03-15  Jer Noble  <jer.no...@apple.com>
+
+        [Cocoa] Adopt AVAssetPrefersSandboxedParsingOptionKey
+        https://bugs.webkit.org/show_bug.cgi?id=237832
+        <rdar://89029829>
+
+        Reviewed by Eric Carlson.
+
+        * Scripts/Preferences/WebPreferencesInternal.yaml:
+
 2022-03-14  Mark Lam  <mark....@apple.com>
 
         Enhance StackCheck debugging support and bump up the ASAN reserved zone size.

Modified: trunk/Source/WTF/Scripts/Preferences/WebPreferencesInternal.yaml (291295 => 291296)


--- trunk/Source/WTF/Scripts/Preferences/WebPreferencesInternal.yaml	2022-03-15 16:37:20 UTC (rev 291295)
+++ trunk/Source/WTF/Scripts/Preferences/WebPreferencesInternal.yaml	2022-03-15 16:40:55 UTC (rev 291296)
@@ -745,6 +745,19 @@
       "HAVE(UIKIT_WEBKIT_INTERNALS)": false
       default: true
 
+PreferSandboxedMediaParsing:
+  type: bool
+  humanReadableName: "Prefer Sandboxed Parsing of Media"
+  humanReadableDescription: "Prefer parsing media out-of-process in a sandboxed service"
+  condition: ENABLE(VIDEO)
+  defaultValue:
+    WebCore:
+      default: true
+    WebKitLegacy:
+      default: true
+    WebKit:
+      default: true
+
 ReplayCGDisplayListsIntoBackingStore:
   type: bool
   humanReadableName: "CG Display Lists: Replay for Testing"

Modified: trunk/Source/WebCore/ChangeLog (291295 => 291296)


--- trunk/Source/WebCore/ChangeLog	2022-03-15 16:37:20 UTC (rev 291295)
+++ trunk/Source/WebCore/ChangeLog	2022-03-15 16:40:55 UTC (rev 291296)
@@ -1,3 +1,24 @@
+2022-03-15  Jer Noble  <jer.no...@apple.com>
+
+        [Cocoa] Adopt AVAssetPrefersSandboxedParsingOptionKey
+        https://bugs.webkit.org/show_bug.cgi?id=237832
+        <rdar://89029829>
+
+        Reviewed by Eric Carlson.
+
+        Adopt a AVURLAsset option which would allow the media file parser to run out-of-process.
+        Because this adoption may have a performance impact (though it should not affect the
+        functionality of AVURLAsset), add a Setting to disable this adoption at runtime for the
+        purpose of A/B testing.
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::requestInstallMissingPlugins):
+        * html/HTMLMediaElement.h:
+        * platform/graphics/MediaPlayer.h:
+        (WebCore::MediaPlayerClient::mediaPlayerPrefersSandboxedParsing const):
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVAssetForURL):
+
 2022-03-15  Joseph Griego  <jgri...@igalia.com>
 
         Expose some web APIs on Shadow Realms and Worklets

Modified: trunk/Source/WebCore/PAL/ChangeLog (291295 => 291296)


--- trunk/Source/WebCore/PAL/ChangeLog	2022-03-15 16:37:20 UTC (rev 291295)
+++ trunk/Source/WebCore/PAL/ChangeLog	2022-03-15 16:40:55 UTC (rev 291296)
@@ -1,3 +1,13 @@
+2022-03-15  Jer Noble  <jer.no...@apple.com>
+
+        [Cocoa] Adopt AVAssetPrefersSandboxedParsingOptionKey
+        https://bugs.webkit.org/show_bug.cgi?id=237832
+        <rdar://89029829>
+
+        Reviewed by Eric Carlson.
+
+        * pal/cocoa/AVFoundationSoftLink.h:
+
 2022-03-12  Tim Horton  <timothy_hor...@apple.com>
 
         Adopt FALLBACK_PLATFORM_NAME in place of FALLBACK_PLATFORM

Modified: trunk/Source/WebCore/PAL/pal/cocoa/AVFoundationSoftLink.h (291295 => 291296)


--- trunk/Source/WebCore/PAL/pal/cocoa/AVFoundationSoftLink.h	2022-03-15 16:37:20 UTC (rev 291295)
+++ trunk/Source/WebCore/PAL/pal/cocoa/AVFoundationSoftLink.h	2022-03-15 16:40:55 UTC (rev 291296)
@@ -240,6 +240,8 @@
 #define AVURLAssetCacheKey PAL::get_AVFoundation_AVURLAssetCacheKey()
 SOFT_LINK_CONSTANT_FOR_HEADER(PAL, AVFoundation, AVURLAssetOutOfBandAlternateTracksKey, NSString *)
 #define AVURLAssetOutOfBandAlternateTracksKey PAL::get_AVFoundation_AVURLAssetOutOfBandAlternateTracksKey()
+SOFT_LINK_CONSTANT_MAY_FAIL_FOR_HEADER(PAL, AVFoundation, AVAssetPrefersSandboxedParsingOptionKey, NSString *)
+#define AVAssetPrefersSandboxedParsingOptionKey PAL::get_AVFoundation_AVAssetPrefersSandboxedParsingOptionKey()
 SOFT_LINK_CONSTANT_FOR_HEADER(PAL, AVFoundation, AVURLAssetUsesNoPersistentCacheKey, NSString *)
 #define AVURLAssetUsesNoPersistentCacheKey PAL::get_AVFoundation_AVURLAssetUsesNoPersistentCacheKey()
 SOFT_LINK_CONSTANT_FOR_HEADER(PAL, AVFoundation, AVOutOfBandAlternateTrackDisplayNameKey, NSString *)

Modified: trunk/Source/WebCore/PAL/pal/cocoa/AVFoundationSoftLink.mm (291295 => 291296)


--- trunk/Source/WebCore/PAL/pal/cocoa/AVFoundationSoftLink.mm	2022-03-15 16:37:20 UTC (rev 291295)
+++ trunk/Source/WebCore/PAL/pal/cocoa/AVFoundationSoftLink.mm	2022-03-15 16:40:55 UTC (rev 291296)
@@ -189,6 +189,7 @@
 SOFT_LINK_CONSTANT_FOR_SOURCE_WITH_EXPORT(PAL, AVFoundation, AVURLAssetCacheKey, NSString *, PAL_EXPORT)
 SOFT_LINK_CONSTANT_FOR_SOURCE_WITH_EXPORT(PAL, AVFoundation, AVURLAssetInheritURIQueryComponentFromReferencingURIKey, NSString *, PAL_EXPORT)
 SOFT_LINK_CONSTANT_FOR_SOURCE_WITH_EXPORT(PAL, AVFoundation, AVURLAssetOutOfBandAlternateTracksKey, NSString *, PAL_EXPORT)
+SOFT_LINK_CONSTANT_MAY_FAIL_FOR_SOURCE_WITH_EXPORT(PAL, AVFoundation, AVAssetPrefersSandboxedParsingOptionKey, NSString *, PAL_EXPORT)
 SOFT_LINK_CONSTANT_FOR_SOURCE_WITH_EXPORT(PAL, AVFoundation, AVURLAssetReferenceRestrictionsKey, NSString *, PAL_EXPORT)
 SOFT_LINK_CONSTANT_FOR_SOURCE_WITH_EXPORT(PAL, AVFoundation, AVURLAssetUsesNoPersistentCacheKey, NSString *, PAL_EXPORT)
 SOFT_LINK_CONSTANT_FOR_SOURCE_WITH_EXPORT(PAL, AVFoundation, AVVideoAverageBitRateKey, NSString *, PAL_EXPORT)

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (291295 => 291296)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2022-03-15 16:37:20 UTC (rev 291295)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2022-03-15 16:40:55 UTC (rev 291296)
@@ -7493,6 +7493,11 @@
     });
 }
 
+bool HTMLMediaElement::mediaPlayerPrefersSandboxedParsing() const
+{
+    return document().settings().preferSandboxedMediaParsing();
+}
+
 #if USE(GSTREAMER)
 void HTMLMediaElement::requestInstallMissingPlugins(const String& details, const String& description, MediaPlayerRequestInstallMissingPluginsCallback& callback)
 {

Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (291295 => 291296)


--- trunk/Source/WebCore/html/HTMLMediaElement.h	2022-03-15 16:37:20 UTC (rev 291295)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h	2022-03-15 16:40:55 UTC (rev 291296)
@@ -778,6 +778,7 @@
     const std::optional<Vector<FourCC>>& allowedMediaCaptionFormatTypes() const final;
 
     void mediaPlayerBufferedTimeRangesChanged() final;
+    bool mediaPlayerPrefersSandboxedParsing() const final;
 
 #if USE(GSTREAMER)
     void requestInstallMissingPlugins(const String& details, const String& description, MediaPlayerRequestInstallMissingPluginsCallback&) final;

Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.h (291295 => 291296)


--- trunk/Source/WebCore/platform/graphics/MediaPlayer.h	2022-03-15 16:37:20 UTC (rev 291295)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.h	2022-03-15 16:40:55 UTC (rev 291296)
@@ -291,6 +291,8 @@
     virtual void mediaPlayerOnNewVideoFrameMetadata(VideoFrameMetadata&&, RetainPtr<CVPixelBufferRef>&&) { }
 #endif
 
+    virtual bool mediaPlayerPrefersSandboxedParsing() const { return false; }
+
 #if !RELEASE_LOG_DISABLED
     virtual const void* mediaPlayerLogIdentifier() { return nullptr; }
     virtual const Logger& mediaPlayerLogger() = 0;
@@ -699,6 +701,8 @@
 
     String lastErrorMessage() const;
 
+    bool prefersSandboxedParsing() const { return client().mediaPlayerPrefersSandboxedParsing(); }
+
 private:
     MediaPlayer(MediaPlayerClient&);
     MediaPlayer(MediaPlayerClient&, MediaPlayerEnums::MediaEngineIdentifier);

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (291295 => 291296)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm	2022-03-15 16:37:20 UTC (rev 291295)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm	2022-03-15 16:40:55 UTC (rev 291296)
@@ -903,6 +903,8 @@
     if (!identifier.isEmpty())
         [options setObject:identifier forKey:AVURLAssetClientBundleIdentifierKey];
 #endif
+    if (player()->prefersSandboxedParsing() && PAL::canLoad_AVFoundation_AVAssetPrefersSandboxedParsingOptionKey())
+        [options setObject:@YES forKey:AVAssetPrefersSandboxedParsingOptionKey];
 
     auto type = player()->contentMIMEType();
 

Modified: trunk/Source/WebKit/ChangeLog (291295 => 291296)


--- trunk/Source/WebKit/ChangeLog	2022-03-15 16:37:20 UTC (rev 291295)
+++ trunk/Source/WebKit/ChangeLog	2022-03-15 16:40:55 UTC (rev 291296)
@@ -1,3 +1,20 @@
+2022-03-15  Jer Noble  <jer.no...@apple.com>
+
+        [Cocoa] Adopt AVAssetPrefersSandboxedParsingOptionKey
+        https://bugs.webkit.org/show_bug.cgi?id=237832
+        <rdar://89029829>
+
+        Reviewed by Eric Carlson.
+
+        Propogate the `prefersSandboxedParsing()` property across to the GPU process.
+
+        * GPUProcess/media/RemoteMediaPlayerProxy.h:
+        * GPUProcess/media/RemoteMediaPlayerProxyConfiguration.h:
+        (WebKit::RemoteMediaPlayerProxyConfiguration::encode const):
+        (WebKit::RemoteMediaPlayerProxyConfiguration::decode):
+        * WebProcess/GPU/media/RemoteMediaPlayerManager.cpp:
+        (WebKit::RemoteMediaPlayerManager::createRemoteMediaPlayer):
+
 2022-03-15  Wenson Hsieh  <wenson_hs...@apple.com>
 
         [macOS] Tooltip no longer disappears after leaving hovered element

Modified: trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.h (291295 => 291296)


--- trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.h	2022-03-15 16:37:20 UTC (rev 291295)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.h	2022-03-15 16:40:55 UTC (rev 291296)
@@ -310,6 +310,8 @@
     const std::optional<Vector<WebCore::FourCC>>& allowedMediaAudioCodecIDs() const final { return m_configuration.allowedMediaAudioCodecIDs; };
     const std::optional<Vector<WebCore::FourCC>>& allowedMediaCaptionFormatTypes() const final { return m_configuration.allowedMediaCaptionFormatTypes; };
 
+    bool mediaPlayerPrefersSandboxedParsing() const final { return m_configuration.prefersSandboxedParsing; }
+
     void startUpdateCachedStateMessageTimer();
     void updateCachedState(bool = false);
     void sendCachedState();

Modified: trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxyConfiguration.h (291295 => 291296)


--- trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxyConfiguration.h	2022-03-15 16:37:20 UTC (rev 291295)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxyConfiguration.h	2022-03-15 16:40:55 UTC (rev 291296)
@@ -57,6 +57,7 @@
     bool shouldUsePersistentCache { false };
     bool isVideo { false };
     bool renderingCanBeAccelerated { false };
+    bool prefersSandboxedParsing { false };
 
     template<class Encoder>
     void encode(Encoder& encoder) const
@@ -81,6 +82,7 @@
         encoder << shouldUsePersistentCache;
         encoder << isVideo;
         encoder << renderingCanBeAccelerated;
+        encoder << prefersSandboxedParsing;
     }
 
     template <class Decoder>
@@ -105,7 +107,8 @@
             && decoder.decode(configuration.logIdentifier)
             && decoder.decode(configuration.shouldUsePersistentCache)
             && decoder.decode(configuration.isVideo)
-            && decoder.decode(configuration.renderingCanBeAccelerated);
+            && decoder.decode(configuration.renderingCanBeAccelerated)
+            && decoder.decode(configuration.prefersSandboxedParsing);
     }
 };
 

Modified: trunk/Source/WebKit/WebProcess/GPU/media/RemoteMediaPlayerManager.cpp (291295 => 291296)


--- trunk/Source/WebKit/WebProcess/GPU/media/RemoteMediaPlayerManager.cpp	2022-03-15 16:37:20 UTC (rev 291295)
+++ trunk/Source/WebKit/WebProcess/GPU/media/RemoteMediaPlayerManager.cpp	2022-03-15 16:40:55 UTC (rev 291296)
@@ -175,6 +175,8 @@
     proxyConfiguration.allowedMediaCaptionFormatTypes = player->allowedMediaCaptionFormatTypes();
     proxyConfiguration.playerContentBoxRect = player->playerContentBoxRect();
 
+    proxyConfiguration.prefersSandboxedParsing = player->prefersSandboxedParsing();
+
     auto identifier = MediaPlayerIdentifier::generate();
     gpuProcessConnection().connection().send(Messages::RemoteMediaPlayerManagerProxy::CreateMediaPlayer(identifier, remoteEngineIdentifier, proxyConfiguration), 0);
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to