Fix crash in webkit_media_stream_src_class_init()
authorPhilippe Normand <philn@igalia.com>
Tue, 21 Mar 2023 17:11:48 +0000 (17:11 +0000)
committerAlberto Garcia <berto@igalia.com>
Tue, 21 Mar 2023 17:11:48 +0000 (17:11 +0000)
Bug: https://bugs.webkit.org/show_bug.cgi?id=254025
Origin: https://github.com/WebKit/WebKit/commit/358ce3a4bd7353c8edaa5720c949301f31c9a5e9

===================================================================

Gbp-Pq: Name fix-gst-crash.patch

Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp
Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp

index 0ff9f8687379fae93ecc8cb3d63f2f78f2c34b54..101f3c30bfae565b47fd72b7f2d77dd5f598430b 100644 (file)
@@ -2647,6 +2647,9 @@ MediaPlayer::SupportsType MediaPlayerPrivateGStreamer::supportsType(const MediaE
 #endif
     }
 
+    if (!ensureGStreamerInitialized())
+        return result;
+
     GST_DEBUG("Checking mime-type \"%s\"", parameters.type.raw().utf8().data());
     if (parameters.type.isEmpty())
         return result;
index 520723538885cabb4150168bdb021996e55311b9..97046ce2fb4c397c34935e0220b8ec4020ed544d 100644 (file)
@@ -439,22 +439,13 @@ void MediaPlayerPrivateGStreamerMSE::getSupportedTypes(HashSet<String, ASCIICase
 
 MediaPlayer::SupportsType MediaPlayerPrivateGStreamerMSE::supportsType(const MediaEngineSupportParameters& parameters)
 {
-    static std::optional<VideoDecodingLimits> videoDecodingLimits;
-#ifdef VIDEO_DECODING_LIMIT
-    static std::once_flag onceFlag;
-    std::call_once(onceFlag, [] {
-        videoDecodingLimits = videoDecoderLimitsDefaults();
-        if (!videoDecodingLimits) {
-            GST_WARNING("Parsing VIDEO_DECODING_LIMIT failed");
-            ASSERT_NOT_REACHED();
-        }
-    });
-#endif
-
     MediaPlayer::SupportsType result = MediaPlayer::SupportsType::IsNotSupported;
     if (!parameters.isMediaSource)
         return result;
 
+    if (!ensureGStreamerInitialized())
+        return result;
+
     auto containerType = parameters.type.containerType();
 
     // YouTube TV provides empty types for some videos and we want to be selected as best media engine for them.
@@ -476,6 +467,16 @@ MediaPlayer::SupportsType MediaPlayerPrivateGStreamerMSE::supportsType(const Med
     if (!ok)
         height = 0;
 
+    static std::optional<VideoDecodingLimits> videoDecodingLimits;
+#ifdef VIDEO_DECODING_LIMIT
+    static std::once_flag onceFlag;
+    std::call_once(onceFlag, [] {
+        videoDecodingLimits = videoDecoderLimitsDefaults();
+        if (!videoDecodingLimits)
+            GST_WARNING("Parsing VIDEO_DECODING_LIMIT failed");
+    });
+#endif
+
     if (videoDecodingLimits && (width > videoDecodingLimits->mediaMaxWidth || height > videoDecodingLimits->mediaMaxHeight))
         return result;