Title: [275934] trunk
Revision
275934
Author
[email protected]
Date
2021-04-13 23:24:06 -0700 (Tue, 13 Apr 2021)

Log Message

[GPUP] MediaSource.addSourceBuffer() will throw if given the same parameter as a previous call to HTMLMediaElement.canPlayType()
https://bugs.webkit.org/show_bug.cgi?id=224273
<rdar://74805071>

Reviewed by Eric Carlson.

Source/WebKit:

Test: media/media-source/media-source-addsourcebuffer-after-canplaytype.html

RemoteMediaPlayerMIMETypeCache will receive requests to verify whether it can handle a MIME/codec combination,
as well as whether this indicates a MediaStream, MSE source, or neither. If a cache for the MSE back-end receives
a query for a MIME type, but the query parameters indicate this is not a MSE source, it will say no and cache the
response. However the cache is keyed solely on the MIME/codec, so when a subsequent call to create a SourceBuffer
hits the cache entry, it thinks it will be unable to handle the MIME and rejects.

Make the mime-type cache triple keyed: use both the raw ContentType (MIME & codecs) as well as the flags stating
whether the source is a MediaStream, MSE, or neither.

* WebProcess/GPU/media/RemoteMediaPlayerMIMETypeCache.cpp:
(WebKit::RemoteMediaPlayerMIMETypeCache::supportsTypeAndCodecs):
* WebProcess/GPU/media/RemoteMediaPlayerMIMETypeCache.h:

LayoutTests:

* media/media-source/media-source-addsourcebuffer-after-canplaytype-expected.txt: Added.
* media/media-source/media-source-addsourcebuffer-after-canplaytype.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (275933 => 275934)


--- trunk/LayoutTests/ChangeLog	2021-04-14 06:12:15 UTC (rev 275933)
+++ trunk/LayoutTests/ChangeLog	2021-04-14 06:24:06 UTC (rev 275934)
@@ -1,3 +1,14 @@
+2021-04-13  Jer Noble  <[email protected]>
+
+        [GPUP] MediaSource.addSourceBuffer() will throw if given the same parameter as a previous call to HTMLMediaElement.canPlayType()
+        https://bugs.webkit.org/show_bug.cgi?id=224273
+        <rdar://74805071>
+
+        Reviewed by Eric Carlson.
+
+        * media/media-source/media-source-addsourcebuffer-after-canplaytype-expected.txt: Added.
+        * media/media-source/media-source-addsourcebuffer-after-canplaytype.html: Added.
+
 2021-04-13  Diego Pino Garcia  <[email protected]>
 
         [GLIB] Unreviewed test gardening. Skip sframe tests added in r275656 and r275874.

Added: trunk/LayoutTests/media/media-source/media-source-addsourcebuffer-after-canplaytype-expected.txt (0 => 275934)


--- trunk/LayoutTests/media/media-source/media-source-addsourcebuffer-after-canplaytype-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/media/media-source/media-source-addsourcebuffer-after-canplaytype-expected.txt	2021-04-14 06:24:06 UTC (rev 275934)
@@ -0,0 +1,7 @@
+
+RUN(video.canPlayType('audio/mp4; codecs="mp4a.40.2"'))
+RUN(video.src = ""
+EVENT(sourceopen)
+RUN(source.addSourceBuffer('audio/mp4; codecs="mp4a.40.2"'))
+END OF TEST
+

Added: trunk/LayoutTests/media/media-source/media-source-addsourcebuffer-after-canplaytype.html (0 => 275934)


--- trunk/LayoutTests/media/media-source/media-source-addsourcebuffer-after-canplaytype.html	                        (rev 0)
+++ trunk/LayoutTests/media/media-source/media-source-addsourcebuffer-after-canplaytype.html	2021-04-14 06:24:06 UTC (rev 275934)
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <title>media-source-addsourcebuffer-after-canplaytype</title>
+    <script src=""
+    <script>
+    var source;
+    window.addEventListener('load', async event => {
+        findMediaElement();
+        run(`video.canPlayType('audio/mp4; codecs="mp4a.40.2"')`)
+        
+        source = new MediaSource();
+        run('video.src = ""
+        await waitFor(source, 'sourceopen');
+        run(`source.addSourceBuffer('audio/mp4; codecs="mp4a.40.2"')`);
+
+        endTest();
+    });
+    </script>
+</head>
+<body>
+<video></video>
+</body>
\ No newline at end of file

Modified: trunk/Source/WebKit/ChangeLog (275933 => 275934)


--- trunk/Source/WebKit/ChangeLog	2021-04-14 06:12:15 UTC (rev 275933)
+++ trunk/Source/WebKit/ChangeLog	2021-04-14 06:24:06 UTC (rev 275934)
@@ -1,3 +1,26 @@
+2021-04-13  Jer Noble  <[email protected]>
+
+        [GPUP] MediaSource.addSourceBuffer() will throw if given the same parameter as a previous call to HTMLMediaElement.canPlayType()
+        https://bugs.webkit.org/show_bug.cgi?id=224273
+        <rdar://74805071>
+
+        Reviewed by Eric Carlson.
+
+        Test: media/media-source/media-source-addsourcebuffer-after-canplaytype.html
+
+        RemoteMediaPlayerMIMETypeCache will receive requests to verify whether it can handle a MIME/codec combination,
+        as well as whether this indicates a MediaStream, MSE source, or neither. If a cache for the MSE back-end receives
+        a query for a MIME type, but the query parameters indicate this is not a MSE source, it will say no and cache the
+        response. However the cache is keyed solely on the MIME/codec, so when a subsequent call to create a SourceBuffer
+        hits the cache entry, it thinks it will be unable to handle the MIME and rejects.
+
+        Make the mime-type cache triple keyed: use both the raw ContentType (MIME & codecs) as well as the flags stating
+        whether the source is a MediaStream, MSE, or neither.
+
+        * WebProcess/GPU/media/RemoteMediaPlayerMIMETypeCache.cpp:
+        (WebKit::RemoteMediaPlayerMIMETypeCache::supportsTypeAndCodecs):
+        * WebProcess/GPU/media/RemoteMediaPlayerMIMETypeCache.h:
+
 2021-04-13  Ada Chan  <[email protected]>
 
         Implement PlatformXRSystem::xrCoordinator() for USE(APPLE_INTERNAL_SDK)

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


--- trunk/Source/WebKit/WebProcess/GPU/media/RemoteMediaPlayerMIMETypeCache.cpp	2021-04-14 06:12:15 UTC (rev 275933)
+++ trunk/Source/WebKit/WebProcess/GPU/media/RemoteMediaPlayerMIMETypeCache.cpp	2021-04-14 06:24:06 UTC (rev 275934)
@@ -72,18 +72,20 @@
     if (parameters.type.raw().isEmpty())
         return MediaPlayerEnums::SupportsType::MayBeSupported;
 
+    SupportedTypesAndCodecsKey searchKey { parameters.type.raw(), parameters.isMediaSource, parameters.isMediaStream };
+
     if (m_supportsTypeAndCodecsCache) {
-        auto it = m_supportsTypeAndCodecsCache->find(parameters.type.raw());
+        auto it = m_supportsTypeAndCodecsCache->find(searchKey);
         if (it != m_supportsTypeAndCodecsCache->end())
             return it->value;
     }
 
     if (!m_supportsTypeAndCodecsCache)
-        m_supportsTypeAndCodecsCache = HashMap<String, MediaPlayerEnums::SupportsType, ASCIICaseInsensitiveHash> { };
+        m_supportsTypeAndCodecsCache = HashMap<SupportedTypesAndCodecsKey, MediaPlayerEnums::SupportsType> { };
 
     MediaPlayerEnums::SupportsType result = MediaPlayerEnums::SupportsType::IsNotSupported;
     if (m_manager.gpuProcessConnection().connection().sendSync(Messages::RemoteMediaPlayerManagerProxy::SupportsTypeAndCodecs(m_engineIdentifier, parameters), Messages::RemoteMediaPlayerManagerProxy::SupportsTypeAndCodecs::Reply(result), 0))
-        m_supportsTypeAndCodecsCache->add(parameters.type.raw(), result);
+        m_supportsTypeAndCodecsCache->add(searchKey, result);
 
     return result;
 }

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


--- trunk/Source/WebKit/WebProcess/GPU/media/RemoteMediaPlayerMIMETypeCache.h	2021-04-14 06:12:15 UTC (rev 275933)
+++ trunk/Source/WebKit/WebProcess/GPU/media/RemoteMediaPlayerMIMETypeCache.h	2021-04-14 06:24:06 UTC (rev 275934)
@@ -55,7 +55,9 @@
 private:
     RemoteMediaPlayerManager& m_manager;
     WebCore::MediaPlayerEnums::MediaEngineIdentifier m_engineIdentifier;
-    Optional<HashMap<String, WebCore::MediaPlayerEnums::SupportsType, ASCIICaseInsensitiveHash>> m_supportsTypeAndCodecsCache;
+
+    using SupportedTypesAndCodecsKey = std::tuple<String, bool, bool>;
+    Optional<HashMap<SupportedTypesAndCodecsKey, WebCore::MediaPlayerEnums::SupportsType>> m_supportsTypeAndCodecsCache;
     Optional<HashSet<String, ASCIICaseInsensitiveHash>> m_supportedTypesCache;
 };
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to