Title: [282666] trunk
Revision
282666
Author
cdu...@apple.com
Date
2021-09-17 10:15:11 -0700 (Fri, 17 Sep 2021)

Log Message

Crash under RemoteMediaPlayerManager::getSupportedTypes()
https://bugs.webkit.org/show_bug.cgi?id=230410

Reviewed by Eric Carlson.

The code would do a null dereference of m_supportedTypesCache if the IPC to the GPUProcess
failed, which could happen in the event of the GPUProcess crash or jetsam.

* WebProcess/GPU/media/RemoteMediaPlayerMIMETypeCache.cpp:
(WebKit::RemoteMediaPlayerMIMETypeCache::addSupportedTypes):
(WebKit::RemoteMediaPlayerMIMETypeCache::isEmpty const):
(WebKit::RemoteMediaPlayerMIMETypeCache::supportedTypes):
* WebProcess/GPU/media/RemoteMediaPlayerMIMETypeCache.h:

Modified Paths

Diff

Modified: trunk/LayoutTests/platform/ios-wk2/TestExpectations (282665 => 282666)


--- trunk/LayoutTests/platform/ios-wk2/TestExpectations	2021-09-17 17:13:34 UTC (rev 282665)
+++ trunk/LayoutTests/platform/ios-wk2/TestExpectations	2021-09-17 17:15:11 UTC (rev 282666)
@@ -1153,8 +1153,6 @@
 webkit.org/b/161359 imported/w3c/web-platform-tests/html/browsers/browsing-the-web/scroll-to-fragid/scroll-to-top.html [ Pass Failure ]
 webkit.org/b/161631 imported/w3c/web-platform-tests/html/browsers/browsing-the-web/scroll-to-fragid/scroll-to-id-top.html [ Pass Failure ]
 
-webkit.org/b/230011 imported/w3c/web-platform-tests/html/cross-origin-opener-policy/resource-popup.https.html [ Pass Crash ]
-
 # Newly imported WPT tests that are timing out on iOS.
 imported/w3c/web-platform-tests/html/semantics/forms/the-button-element/button-activate-keyup-prevented.html [ Skip ]
 imported/w3c/web-platform-tests/uievents/click/auxclick_event.html [ Skip ]

Modified: trunk/Source/WebKit/ChangeLog (282665 => 282666)


--- trunk/Source/WebKit/ChangeLog	2021-09-17 17:13:34 UTC (rev 282665)
+++ trunk/Source/WebKit/ChangeLog	2021-09-17 17:15:11 UTC (rev 282666)
@@ -1,3 +1,19 @@
+2021-09-17  Chris Dumez  <cdu...@apple.com>
+
+        Crash under RemoteMediaPlayerManager::getSupportedTypes()
+        https://bugs.webkit.org/show_bug.cgi?id=230410
+
+        Reviewed by Eric Carlson.
+
+        The code would do a null dereference of m_supportedTypesCache if the IPC to the GPUProcess
+        failed, which could happen in the event of the GPUProcess crash or jetsam.
+
+        * WebProcess/GPU/media/RemoteMediaPlayerMIMETypeCache.cpp:
+        (WebKit::RemoteMediaPlayerMIMETypeCache::addSupportedTypes):
+        (WebKit::RemoteMediaPlayerMIMETypeCache::isEmpty const):
+        (WebKit::RemoteMediaPlayerMIMETypeCache::supportedTypes):
+        * WebProcess/GPU/media/RemoteMediaPlayerMIMETypeCache.h:
+
 2021-09-17  Carlos Garcia Campos  <cgar...@igalia.com>
 
         [GTK][a11y] Add a build option to enable ATSPI

Modified: trunk/Source/WebKit/WebProcess/GPU/media/RemoteMediaPlayerMIMETypeCache.cpp (282665 => 282666)


--- trunk/Source/WebKit/WebProcess/GPU/media/RemoteMediaPlayerMIMETypeCache.cpp	2021-09-17 17:13:34 UTC (rev 282665)
+++ trunk/Source/WebKit/WebProcess/GPU/media/RemoteMediaPlayerMIMETypeCache.cpp	2021-09-17 17:15:11 UTC (rev 282666)
@@ -28,6 +28,7 @@
 
 #if ENABLE(GPU_PROCESS)
 
+#include "Logging.h"
 #include "RemoteMediaPlayerManager.h"
 #include "RemoteMediaPlayerManagerProxyMessages.h"
 #include <wtf/Vector.h>
@@ -43,28 +44,26 @@
 
 void RemoteMediaPlayerMIMETypeCache::addSupportedTypes(const Vector<String>& newTypes)
 {
-    if (!m_supportedTypesCache)
-        m_supportedTypesCache = HashSet<String, ASCIICaseInsensitiveHash> { };
-
-    for (auto& type : newTypes)
-        m_supportedTypesCache->add(type);
+    m_supportedTypesCache.add(newTypes.begin(), newTypes.end());
 }
 
 bool RemoteMediaPlayerMIMETypeCache::isEmpty() const
 {
-    return m_supportedTypesCache && m_supportedTypesCache->isEmpty();
+    return m_hasPopulatedSupportedTypesCacheFromGPUProcess && m_supportedTypesCache.isEmpty();
 }
 
 HashSet<String, ASCIICaseInsensitiveHash>& RemoteMediaPlayerMIMETypeCache::supportedTypes()
 {
-    if (m_supportedTypesCache)
-        return *m_supportedTypesCache;
-
-    Vector<String> types;
-    if (m_manager.gpuProcessConnection().connection().sendSync(Messages::RemoteMediaPlayerManagerProxy::GetSupportedTypes(m_engineIdentifier), Messages::RemoteMediaPlayerManagerProxy::GetSupportedTypes::Reply(types), 0))
-        addSupportedTypes(types);
-
-    return *m_supportedTypesCache;
+    ASSERT(isMainRunLoop());
+    if (!m_hasPopulatedSupportedTypesCacheFromGPUProcess) {
+        Vector<String> types;
+        if (m_manager.gpuProcessConnection().connection().sendSync(Messages::RemoteMediaPlayerManagerProxy::GetSupportedTypes(m_engineIdentifier), Messages::RemoteMediaPlayerManagerProxy::GetSupportedTypes::Reply(types), 0)) {
+            addSupportedTypes(types);
+            m_hasPopulatedSupportedTypesCacheFromGPUProcess = true;
+        } else
+            RELEASE_LOG_ERROR(Media, "RemoteMediaPlayerMIMETypeCache::supportedTypes: Sync IPC to the GPUProcess failed.");
+    }
+    return m_supportedTypesCache;
 }
 
 MediaPlayerEnums::SupportsType RemoteMediaPlayerMIMETypeCache::supportsTypeAndCodecs(const MediaEngineSupportParameters& parameters)

Modified: trunk/Source/WebKit/WebProcess/GPU/media/RemoteMediaPlayerMIMETypeCache.h (282665 => 282666)


--- trunk/Source/WebKit/WebProcess/GPU/media/RemoteMediaPlayerMIMETypeCache.h	2021-09-17 17:13:34 UTC (rev 282665)
+++ trunk/Source/WebKit/WebProcess/GPU/media/RemoteMediaPlayerMIMETypeCache.h	2021-09-17 17:15:11 UTC (rev 282666)
@@ -57,7 +57,8 @@
 
     using SupportedTypesAndCodecsKey = std::tuple<String, bool, bool>;
     std::optional<HashMap<SupportedTypesAndCodecsKey, WebCore::MediaPlayerEnums::SupportsType>> m_supportsTypeAndCodecsCache;
-    std::optional<HashSet<String, ASCIICaseInsensitiveHash>> m_supportedTypesCache;
+    HashSet<String, ASCIICaseInsensitiveHash> m_supportedTypesCache;
+    bool m_hasPopulatedSupportedTypesCacheFromGPUProcess { false };
 };
 
 } // namespace WebKit
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to