Title: [271353] trunk/Source/WebCore
Revision
271353
Author
[email protected]
Date
2021-01-11 00:35:41 -0800 (Mon, 11 Jan 2021)

Log Message

[GStreamer] Do not use the registry scanner singleton from the UI process
https://bugs.webkit.org/show_bug.cgi?id=220407

Patch by Carlos Garcia Campos  <[email protected]> and Philippe Normand <[email protected]> on 2021-01-11
Reviewed by Xabier Rodriguez-Calvar.

* platform/RuntimeApplicationChecks.h:
(WebCore::isInNetworkProcess): Simplify ifdefs a bit and allow for glib implementation in a separate file.
* platform/SourcesGLib.txt:
* platform/glib/RuntimeApplicationChecksGLib.cpp: Added.
(WebCore::isInWebProcess): Implementation based on program filename.
(WebCore::isInNetworkProcess): Ditto.
* platform/graphics/gstreamer/GStreamerRegistryScanner.cpp:
(WebCore::GStreamerRegistryScanner::getSupportedDecodingTypes): Static function to get the supported MIME types
for decoding. It uses the singleton if called from the web process or creates a new instance otherwise.
(WebCore::GStreamerRegistryScanner::GStreamerRegistryScanner): Initialize gst when not in the web process.
* platform/graphics/gstreamer/GStreamerRegistryScanner.h:
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::MediaPlayerPrivateGStreamer::getSupportedTypes): Use GStreamerRegistryScanner::getSupportedDecodingTypes().
* platform/graphics/gstreamer/mse/GStreamerRegistryScannerMSE.cpp:
(WebCore::GStreamerRegistryScannerMSE::getSupportedDecodingTypes): Static function to get the supported MIME
types for decoding. It uses the singleton if called from the web process or creates a new instance otherwise.
* platform/graphics/gstreamer/mse/GStreamerRegistryScannerMSE.h:
* platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp:
(WebCore::MediaPlayerPrivateGStreamerMSE::getSupportedTypes): Use GStreamerRegistryScannerMSE::getSupportedDecodingTypes().

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (271352 => 271353)


--- trunk/Source/WebCore/ChangeLog	2021-01-11 05:40:00 UTC (rev 271352)
+++ trunk/Source/WebCore/ChangeLog	2021-01-11 08:35:41 UTC (rev 271353)
@@ -1,3 +1,30 @@
+2021-01-11  Carlos Garcia Campos  <[email protected]> and Philippe Normand  <[email protected]>
+
+        [GStreamer] Do not use the registry scanner singleton from the UI process
+        https://bugs.webkit.org/show_bug.cgi?id=220407
+
+        Reviewed by Xabier Rodriguez-Calvar.
+
+        * platform/RuntimeApplicationChecks.h:
+        (WebCore::isInNetworkProcess): Simplify ifdefs a bit and allow for glib implementation in a separate file.
+        * platform/SourcesGLib.txt:
+        * platform/glib/RuntimeApplicationChecksGLib.cpp: Added.
+        (WebCore::isInWebProcess): Implementation based on program filename.
+        (WebCore::isInNetworkProcess): Ditto.
+        * platform/graphics/gstreamer/GStreamerRegistryScanner.cpp:
+        (WebCore::GStreamerRegistryScanner::getSupportedDecodingTypes): Static function to get the supported MIME types
+        for decoding. It uses the singleton if called from the web process or creates a new instance otherwise.
+        (WebCore::GStreamerRegistryScanner::GStreamerRegistryScanner): Initialize gst when not in the web process.
+        * platform/graphics/gstreamer/GStreamerRegistryScanner.h:
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
+        (WebCore::MediaPlayerPrivateGStreamer::getSupportedTypes): Use GStreamerRegistryScanner::getSupportedDecodingTypes().
+        * platform/graphics/gstreamer/mse/GStreamerRegistryScannerMSE.cpp:
+        (WebCore::GStreamerRegistryScannerMSE::getSupportedDecodingTypes): Static function to get the supported MIME
+        types for decoding. It uses the singleton if called from the web process or creates a new instance otherwise.
+        * platform/graphics/gstreamer/mse/GStreamerRegistryScannerMSE.h:
+        * platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp:
+        (WebCore::MediaPlayerPrivateGStreamerMSE::getSupportedTypes): Use GStreamerRegistryScannerMSE::getSupportedDecodingTypes().
+
 2021-01-10  Zalan Bujtas  <[email protected]>
 
         [LFC][IFC] Make "inline level box affects line box geometry" logic more explicit

Modified: trunk/Source/WebCore/platform/RuntimeApplicationChecks.h (271352 => 271353)


--- trunk/Source/WebCore/platform/RuntimeApplicationChecks.h	2021-01-11 05:40:00 UTC (rev 271352)
+++ trunk/Source/WebCore/platform/RuntimeApplicationChecks.h	2021-01-11 08:35:41 UTC (rev 271353)
@@ -35,17 +35,19 @@
 #if PLATFORM(WIN)
 inline bool isInWebProcess() { return false; }
 inline bool isInGPUProcess() { return false; }
-#elif !PLATFORM(COCOA)
+#elif !PLATFORM(COCOA) && !USE(GLIB)
 inline bool isInWebProcess() { return true; }
 inline bool isInGPUProcess() { return false; }
+inline bool isInNetworkProcess() { return false; }
 #endif
 
-#if PLATFORM(COCOA)
-
+#if PLATFORM(COCOA) || USE(GLIB)
 bool isInWebProcess();
 bool isInGPUProcess();
 bool isInNetworkProcess();
+#endif
 
+#if PLATFORM(COCOA)
 WEBCORE_EXPORT void setApplicationBundleIdentifier(const String&);
 WEBCORE_EXPORT void setApplicationBundleIdentifierOverride(const String&);
 WEBCORE_EXPORT String applicationBundleIdentifier();
@@ -122,10 +124,6 @@
 
 #endif // PLATFORM(IOS_FAMILY)
 
-#else
-
-inline bool isInNetworkProcess() { return false; }
-
 #endif // PLATFORM(COCOA)
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/SourcesGLib.txt (271352 => 271353)


--- trunk/Source/WebCore/platform/SourcesGLib.txt	2021-01-11 05:40:00 UTC (rev 271352)
+++ trunk/Source/WebCore/platform/SourcesGLib.txt	2021-01-11 08:35:41 UTC (rev 271353)
@@ -27,6 +27,7 @@
 platform/glib/KeyedDecoderGlib.cpp
 platform/glib/KeyedEncoderGlib.cpp
 platform/glib/LowPowerModeNotifierGLib.cpp
+platform/glib/RuntimeApplicationChecksGLib.cpp
 platform/glib/SharedBufferGlib.cpp
 platform/glib/UserAgentGLib.cpp
 

Added: trunk/Source/WebCore/platform/glib/RuntimeApplicationChecksGLib.cpp (0 => 271353)


--- trunk/Source/WebCore/platform/glib/RuntimeApplicationChecksGLib.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/glib/RuntimeApplicationChecksGLib.cpp	2021-01-11 08:35:41 UTC (rev 271353)
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2021 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "RuntimeApplicationChecks.h"
+
+#include <mutex>
+#include <wtf/glib/GLibUtilities.h>
+
+namespace WebCore {
+
+#if PLATFORM(GTK)
+static const CString webProcessName = "WebKitWebProcess";
+static const CString networkProcessName = "WebKitNetworkProcess";
+#elif PLATFORM(WPE)
+static const CString webProcessName = "WPEWebProcess";
+static const CString networkProcessName = "WPENetworkProcess";
+#endif
+
+bool isInWebProcess()
+{
+    static bool isWebProcess;
+    static std::once_flag onceFlag;
+    std::call_once(onceFlag, [] {
+        isWebProcess = getCurrentExecutableName() == webProcessName;
+    });
+    return isWebProcess;
+}
+
+bool isInNetworkProcess()
+{
+    static bool isNetworkProcess;
+    static std::once_flag onceFlag;
+    std::call_once(onceFlag, [] {
+        isNetworkProcess = getCurrentExecutableName() == networkProcessName;
+    });
+    return isNetworkProcess;
+}
+
+} // namespace WebCore

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerRegistryScanner.cpp (271352 => 271353)


--- trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerRegistryScanner.cpp	2021-01-11 05:40:00 UTC (rev 271352)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerRegistryScanner.cpp	2021-01-11 08:35:41 UTC (rev 271353)
@@ -23,6 +23,7 @@
 #if USE(GSTREAMER)
 #include "ContentType.h"
 #include "GStreamerCommon.h"
+#include "RuntimeApplicationChecks.h"
 #include <fnmatch.h>
 #include <gst/pbutils/codec-utils.h>
 #include <wtf/PrintStream.h>
@@ -39,6 +40,14 @@
     return sharedInstance;
 }
 
+void GStreamerRegistryScanner::getSupportedDecodingTypes(HashSet<String, ASCIICaseInsensitiveHash>& types)
+{
+    if (isInWebProcess())
+        types = singleton().mimeTypeSet(GStreamerRegistryScanner::Configuration::Decoding);
+    else
+        types = GStreamerRegistryScanner().mimeTypeSet(GStreamerRegistryScanner::Configuration::Decoding);
+}
+
 GStreamerRegistryScanner::ElementFactories::ElementFactories(OptionSet<ElementFactories::Type> types)
 {
     if (types.contains(Type::AudioDecoder))
@@ -174,6 +183,8 @@
 GStreamerRegistryScanner::GStreamerRegistryScanner(bool isMediaSource)
     : m_isMediaSource(isMediaSource)
 {
+    if (!isInWebProcess())
+        gst_init(nullptr, nullptr);
     GST_DEBUG_CATEGORY_INIT(webkit_media_gst_registry_scanner_debug, "webkitregistryscanner", 0, "WebKit GStreamer registry scanner");
 
     ElementFactories factories(OptionSet<ElementFactories::Type>::fromRaw(static_cast<unsigned>(ElementFactories::Type::All)));

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerRegistryScanner.h (271352 => 271353)


--- trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerRegistryScanner.h	2021-01-11 05:40:00 UTC (rev 271352)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerRegistryScanner.h	2021-01-11 08:35:41 UTC (rev 271353)
@@ -36,10 +36,13 @@
 class ContentType;
 
 class GStreamerRegistryScanner {
-    friend NeverDestroyed<GStreamerRegistryScanner>;
 public:
     static GStreamerRegistryScanner& singleton();
+    static void getSupportedDecodingTypes(HashSet<String, ASCIICaseInsensitiveHash>&);
 
+    explicit GStreamerRegistryScanner(bool isMediaSource = false);
+    ~GStreamerRegistryScanner() = default;
+
     enum Configuration {
         Decoding = 0,
         Encoding
@@ -62,9 +65,6 @@
     bool areAllCodecsSupported(Configuration, const Vector<String>& codecs, bool shouldCheckForHardwareUse = false) const;
 
 protected:
-    GStreamerRegistryScanner(bool isMediaSource = false);
-    ~GStreamerRegistryScanner() = default;
-
     struct ElementFactories {
         enum class Type {
             AudioParser  = 1 << 0,

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp (271352 => 271353)


--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp	2021-01-11 05:40:00 UTC (rev 271352)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp	2021-01-11 08:35:41 UTC (rev 271353)
@@ -2623,8 +2623,7 @@
 
 void MediaPlayerPrivateGStreamer::getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>& types)
 {
-    auto& gstRegistryScanner = GStreamerRegistryScanner::singleton();
-    types = gstRegistryScanner.mimeTypeSet(GStreamerRegistryScanner::Configuration::Decoding);
+    GStreamerRegistryScanner::getSupportedDecodingTypes(types);
 }
 
 MediaPlayer::SupportsType MediaPlayerPrivateGStreamer::supportsType(const MediaEngineSupportParameters& parameters)

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/mse/GStreamerRegistryScannerMSE.cpp (271352 => 271353)


--- trunk/Source/WebCore/platform/graphics/gstreamer/mse/GStreamerRegistryScannerMSE.cpp	2021-01-11 05:40:00 UTC (rev 271352)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/mse/GStreamerRegistryScannerMSE.cpp	2021-01-11 08:35:41 UTC (rev 271353)
@@ -18,12 +18,11 @@
  */
 
 #include "config.h"
+#include "GStreamerRegistryScannerMSE.h"
 
 #if USE(GSTREAMER) && ENABLE(MEDIA_SOURCE)
-#include "GStreamerRegistryScannerMSE.h"
+#include "RuntimeApplicationChecks.h"
 
-#include <wtf/NeverDestroyed.h>
-
 namespace WebCore {
 
 GStreamerRegistryScannerMSE& GStreamerRegistryScannerMSE::singleton()
@@ -32,6 +31,15 @@
     return sharedInstance;
 }
 
+void GStreamerRegistryScannerMSE::getSupportedDecodingTypes(HashSet<String, ASCIICaseInsensitiveHash>& types)
+{
+    if (isInWebProcess())
+        types = singleton().mimeTypeSet(GStreamerRegistryScanner::Configuration::Decoding);
+    else
+        types = GStreamerRegistryScannerMSE().mimeTypeSet(GStreamerRegistryScanner::Configuration::Decoding);
+}
+
+
 GStreamerRegistryScannerMSE::GStreamerRegistryScannerMSE()
     : GStreamerRegistryScanner::GStreamerRegistryScanner(true)
 {

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/mse/GStreamerRegistryScannerMSE.h (271352 => 271353)


--- trunk/Source/WebCore/platform/graphics/gstreamer/mse/GStreamerRegistryScannerMSE.h	2021-01-11 05:40:00 UTC (rev 271352)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/mse/GStreamerRegistryScannerMSE.h	2021-01-11 08:35:41 UTC (rev 271353)
@@ -28,10 +28,9 @@
 namespace WebCore {
 
 class GStreamerRegistryScannerMSE : public GStreamerRegistryScanner {
-    friend NeverDestroyed<GStreamerRegistryScannerMSE>;
 public:
     static GStreamerRegistryScannerMSE& singleton();
-protected:
+    static void getSupportedDecodingTypes(HashSet<String, ASCIICaseInsensitiveHash>&);
     GStreamerRegistryScannerMSE();
 };
 

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp (271352 => 271353)


--- trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp	2021-01-11 05:40:00 UTC (rev 271352)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp	2021-01-11 08:35:41 UTC (rev 271353)
@@ -732,8 +732,7 @@
 
 void MediaPlayerPrivateGStreamerMSE::getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>& types)
 {
-    auto& gstRegistryScanner = GStreamerRegistryScannerMSE::singleton();
-    types = gstRegistryScanner.mimeTypeSet(GStreamerRegistryScanner::Configuration::Decoding);
+    GStreamerRegistryScannerMSE::getSupportedDecodingTypes(types);
 }
 
 MediaPlayer::SupportsType MediaPlayerPrivateGStreamerMSE::supportsType(const MediaEngineSupportParameters& parameters)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to