Title: [291762] trunk
Revision
291762
Author
jer.no...@apple.com
Date
2022-03-23 13:01:04 -0700 (Wed, 23 Mar 2022)

Log Message

[Cocoa] MSE-backed videos fail to play in Captive Portal mode
https://bugs.webkit.org/show_bug.cgi?id=237787
<rdar://89318047>

Reviewed by Eric Carlson.

Source/WebCore:

Updated test: media/media-source/media-source-allowed-codecs.html

When generating the "codecs" string for a given MSE track, we were previously casting
the FourCC code (a uint32) to a string, and passing that across the GPU process boundary,
and reconstituting the string on the WebContent process side. This caused the codec entry
to be "reversed", (e.g., 'aac ' turned into ' caa'), and fail codec validation.

Instead, use the FourCharCode class to properly create a string from the codec ID.

* platform/graphics/avfoundation/objc/SourceBufferParserAVFObjC.mm:

LayoutTests:

* media/media-source/media-source-allowed-codecs-expected.txt:
* media/media-source/media-source-allowed-codecs.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (291761 => 291762)


--- trunk/LayoutTests/ChangeLog	2022-03-23 19:24:00 UTC (rev 291761)
+++ trunk/LayoutTests/ChangeLog	2022-03-23 20:01:04 UTC (rev 291762)
@@ -1,5 +1,16 @@
 2022-03-23  Jer Noble  <jer.no...@apple.com>
 
+        [Cocoa] MSE-backed videos fail to play in Captive Portal mode
+        https://bugs.webkit.org/show_bug.cgi?id=237787
+        <rdar://89318047>
+
+        Reviewed by Eric Carlson.
+
+        * media/media-source/media-source-allowed-codecs-expected.txt:
+        * media/media-source/media-source-allowed-codecs.html:
+
+2022-03-23  Jer Noble  <jer.no...@apple.com>
+
         [iOS] WebKit app is sometimes not "Now Playing" during initial playback
         https://bugs.webkit.org/show_bug.cgi?id=236993
         <rdar://88827167>

Modified: trunk/LayoutTests/media/media-source/media-source-allowed-codecs-expected.txt (291761 => 291762)


--- trunk/LayoutTests/media/media-source/media-source-allowed-codecs-expected.txt	2022-03-23 19:24:00 UTC (rev 291761)
+++ trunk/LayoutTests/media/media-source/media-source-allowed-codecs-expected.txt	2022-03-23 20:01:04 UTC (rev 291762)
@@ -14,5 +14,19 @@
 RUN(internals.settings.setAllowedMediaCodecTypes("vp09,opus"))
 EXPECTED (MediaSource.isTypeSupported("video/mp4; codecs=avc1") == 'false') OK
 TEST(mediaSource.addSourceBuffer("video/mp4; codecs=avc1")) THROWS("NotSupportedError: The operation is not supported.") OK
+RUN(internals.settings.setAllowedMediaVideoCodecIDs("avc1"))
+RUN(internals.settings.setAllowedMediaAudioCodecIDs("aac "))
+RUN(internals.settings.setAllowedMediaCodecTypes("avc1,mp4a.40"))
+RUN(mediaSource.removeSourceBuffer(sourceBuffer))
+RUN(mediaSource.duration = loader.duration())
+RUN(sourceBuffer = mediaSource.addSourceBuffer(loader.type()))
+RUN(sourceBuffer.appendBuffer(loader.initSegment()))
+EVENT(update)
+Append a media segment.
+RUN(sourceBuffer.appendBuffer(loader.mediaSegment(0)))
+EVENT(update)
+RUN(video.playbackRate = 0.01)
+RUN(video.play())
+EVENT(playing)
 END OF TEST
 

Modified: trunk/LayoutTests/media/media-source/media-source-allowed-codecs.html (291761 => 291762)


--- trunk/LayoutTests/media/media-source/media-source-allowed-codecs.html	2022-03-23 19:24:00 UTC (rev 291761)
+++ trunk/LayoutTests/media/media-source/media-source-allowed-codecs.html	2022-03-23 20:01:04 UTC (rev 291762)
@@ -1,9 +1,17 @@
 <!DOCTYPE html>
 <html>
 <head>
-    <title>media-source-allowed-containers</title>
+    <title>media-source-allowed-codecs</title>
     <script src=""
+    <script src=""
     <script>
+    function loaderPromise(loader) {
+        return new Promise((resolve, reject) => {
+            loader._onload_ = resolve;
+            loader._onerror_ = reject;
+        });
+    }
+
     window.addEventListener('load', async event => {
         if (!window.internals) {
             failTest('Requires window.internals');
@@ -38,6 +46,29 @@
 
         testException('mediaSource.addSourceBuffer("video/mp4; codecs=avc1")', '"NotSupportedError: The operation is not supported."');
 
+        run('internals.settings.setAllowedMediaVideoCodecIDs("avc1")');
+        run('internals.settings.setAllowedMediaAudioCodecIDs("aac ")');
+        run('internals.settings.setAllowedMediaCodecTypes("avc1,mp4a.40")');
+
+        loader = new MediaSourceLoader('content/test-fragmented-manifest.json');
+        await loaderPromise(loader);
+
+        waitForEventAndFail('error');
+
+        run('mediaSource.removeSourceBuffer(sourceBuffer)')
+        run('mediaSource.duration = loader.duration()');
+        run('sourceBuffer = mediaSource.addSourceBuffer(loader.type())');
+        run('sourceBuffer.appendBuffer(loader.initSegment())');
+        await waitFor(sourceBuffer, 'update');
+
+        consoleWrite('Append a media segment.')
+        run('sourceBuffer.appendBuffer(loader.mediaSegment(0))');
+        await waitFor(sourceBuffer, 'update');
+
+        run('video.playbackRate = 0.01');
+        run('video.play()');
+        await waitFor(video, 'playing');
+
         endTest();
     });
     </script>

Modified: trunk/LayoutTests/platform/gtk/TestExpectations (291761 => 291762)


--- trunk/LayoutTests/platform/gtk/TestExpectations	2022-03-23 19:24:00 UTC (rev 291761)
+++ trunk/LayoutTests/platform/gtk/TestExpectations	2022-03-23 20:01:04 UTC (rev 291762)
@@ -1860,6 +1860,7 @@
 # These tests require platform support.
 media/media-allowed-codecs.html
 media/media-allowed-containers.html
+media/media-source/media-source-allowed-codecs.html
 
 # These failures occur on GTK only (moved from LayoutTests/TestExpectations)
 webkit.org/b/200208 imported/w3c/web-platform-tests/css/css-images/gradients-with-transparent.html [ ImageOnlyFailure ]

Modified: trunk/Source/WebCore/ChangeLog (291761 => 291762)


--- trunk/Source/WebCore/ChangeLog	2022-03-23 19:24:00 UTC (rev 291761)
+++ trunk/Source/WebCore/ChangeLog	2022-03-23 20:01:04 UTC (rev 291762)
@@ -1,5 +1,24 @@
 2022-03-23  Jer Noble  <jer.no...@apple.com>
 
+        [Cocoa] MSE-backed videos fail to play in Captive Portal mode
+        https://bugs.webkit.org/show_bug.cgi?id=237787
+        <rdar://89318047>
+
+        Reviewed by Eric Carlson.
+
+        Updated test: media/media-source/media-source-allowed-codecs.html
+
+        When generating the "codecs" string for a given MSE track, we were previously casting
+        the FourCC code (a uint32) to a string, and passing that across the GPU process boundary,
+        and reconstituting the string on the WebContent process side. This caused the codec entry
+        to be "reversed", (e.g., 'aac ' turned into ' caa'), and fail codec validation.
+
+        Instead, use the FourCharCode class to properly create a string from the codec ID.
+
+        * platform/graphics/avfoundation/objc/SourceBufferParserAVFObjC.mm:
+
+2022-03-23  Jer Noble  <jer.no...@apple.com>
+
         [iOS] WebKit app is sometimes not "Now Playing" during initial playback
         https://bugs.webkit.org/show_bug.cgi?id=236993
         <rdar://88827167>

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferParserAVFObjC.mm (291761 => 291762)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferParserAVFObjC.mm	2022-03-23 19:24:00 UTC (rev 291761)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferParserAVFObjC.mm	2022-03-23 20:01:04 UTC (rev 291762)
@@ -177,7 +177,7 @@
         // which is presumably on the main thread.
         ASSERT(isMainThread());
         if (!m_codec)
-            m_codec = AtomString(reinterpret_cast<const LChar*>(&m_originalCodec), 4);
+            m_codec = AtomString(m_originalCodec.string().data());
         return *m_codec;
     }
 
@@ -193,11 +193,11 @@
             m_originalCodec = PAL::softLink_CoreMedia_CMFormatDescriptionGetMediaSubType(description);
             CFStringRef originalFormatKey = PAL::canLoad_CoreMedia_kCMFormatDescriptionExtension_ProtectedContentOriginalFormat() ? PAL::get_CoreMedia_kCMFormatDescriptionExtension_ProtectedContentOriginalFormat() : CFSTR("CommonEncryptionOriginalFormat");
             if (auto originalFormat = dynamic_cf_cast<CFNumberRef>(PAL::CMFormatDescriptionGetExtension(description, originalFormatKey)))
-                CFNumberGetValue(originalFormat, kCFNumberSInt32Type, &m_originalCodec);
+                CFNumberGetValue(originalFormat, kCFNumberSInt32Type, &m_originalCodec.value);
         }
     }
 
-    FourCharCode m_originalCodec;
+    FourCC m_originalCodec;
     mutable std::optional<AtomString> m_codec;
     bool m_isVideo;
     bool m_isAudio;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to