Title: [207584] trunk
Revision
207584
Author
jer.no...@apple.com
Date
2016-10-19 20:10:12 -0700 (Wed, 19 Oct 2016)

Log Message

REGRESSION (r206025): All YouTube videos play with black bars on all four sides
https://bugs.webkit.org/show_bug.cgi?id=163308

Reviewed by Darin Adler.

Source/WebCore:

Test: media/media-source/media-source-resize.html

After r206025, we do not fire resize events when the size change notification happens equal-
to-or-before the current time, which can happen at the very beginning of a stream. Take care
of this case by checking that the target time isn't actually in the past inside of
sizeWillChangeAtTime(), and also always skip the boundary time observer when there was no
previous size (such as after a flush due to a seek).

* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::sizeWillChangeAtTime):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setNaturalSize):
* platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
(WebCore::SourceBufferPrivateAVFObjC::flushAndEnqueueNonDisplayingSamples):
(WebCore::SourceBufferPrivateAVFObjC::enqueueSample):

LayoutTests:

* media/media-source/media-source-resize-expected.txt: Added.
* media/media-source/media-source-resize.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (207583 => 207584)


--- trunk/LayoutTests/ChangeLog	2016-10-20 02:33:19 UTC (rev 207583)
+++ trunk/LayoutTests/ChangeLog	2016-10-20 03:10:12 UTC (rev 207584)
@@ -1,3 +1,13 @@
+2016-10-19  Jer Noble  <jer.no...@apple.com>
+
+        REGRESSION (r206025): All YouTube videos play with black bars on all four sides
+        https://bugs.webkit.org/show_bug.cgi?id=163308
+
+        Reviewed by Darin Adler.
+
+        * media/media-source/media-source-resize-expected.txt: Added.
+        * media/media-source/media-source-resize.html: Added.
+
 2016-10-19  Nan Wang  <n_w...@apple.com>
 
         AX: [Mac] Mark element AXAPI should comform to specs

Added: trunk/LayoutTests/media/media-source/media-source-resize-expected.txt (0 => 207584)


--- trunk/LayoutTests/media/media-source/media-source-resize-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/media/media-source/media-source-resize-expected.txt	2016-10-20 03:10:12 UTC (rev 207584)
@@ -0,0 +1,15 @@
+This tests the ability of the SourceBuffer to reset the parser after an abort(). A SourceBuffer in this state should be able to accept a new initialization segment or a new media segment.
+
+RUN(video.src = ""
+EVENT(sourceopen)
+RUN(source.duration = loader.duration())
+RUN(sourceBuffer = source.addSourceBuffer(loader.type()))
+RUN(sourceBuffer.appendBuffer(loader.initSegment()))
+EVENT(update)
+Append a media segment.
+RUN(sourceBuffer.appendBuffer(loader.mediaSegment(0)))
+EVENT(resize)
+EXPECTED (video.videoWidth == '640') OK
+EXPECTED (video.videoHeight == '480') OK
+END OF TEST
+

Added: trunk/LayoutTests/media/media-source/media-source-resize.html (0 => 207584)


--- trunk/LayoutTests/media/media-source/media-source-resize.html	                        (rev 0)
+++ trunk/LayoutTests/media/media-source/media-source-resize.html	2016-10-20 03:10:12 UTC (rev 207584)
@@ -0,0 +1,58 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <title>media-source-abort-resets-parser</title>
+    <script src=""
+    <script src=""
+    <script>
+    var loader;
+    var source;
+    var sourceBuffer;
+
+    function runTest() {
+        findMediaElement();
+
+        loader = new MediaSourceLoader('content/test-fragmented-manifest.json');
+        loader._onload_ = mediaDataLoaded;
+        loader._onerror_ = mediaDataLoadingFailed;
+    }
+
+    function mediaDataLoadingFailed() {
+        failTest('Media data loading failed');
+    }
+
+    function mediaDataLoaded() {
+        source = new MediaSource();
+        waitForEvent('sourceopen', sourceOpen, false, false, source);
+        waitForEventAndFail('error');
+        run('video.src = ""
+    }
+
+    function sourceOpen() {
+        run('source.duration = loader.duration()');
+        run('sourceBuffer = source.addSourceBuffer(loader.type())');
+        waitForEventOn(sourceBuffer, 'update', sourceInitialized, false, true);
+        run('sourceBuffer.appendBuffer(loader.initSegment())');
+    }
+
+    function sourceInitialized() {
+        waitForEventOnce('resize', resize);
+        consoleWrite('Append a media segment.')
+        run('sourceBuffer.appendBuffer(loader.mediaSegment(0))');
+    }
+
+    function resize() {
+        testExpected('video.videoWidth', 640);
+        testExpected('video.videoHeight', 480);
+        endTest();
+    }
+    </script>
+</head>
+<body _onload_="runTest()">
+    <div>
+        This tests the ability of the SourceBuffer to reset the parser after an abort(). A SourceBuffer in this state should be able to accept
+        a new initialization segment or a new media segment.
+    </div>
+    <video controls></video>
+</body>
+</html>
\ No newline at end of file

Modified: trunk/Source/WebCore/ChangeLog (207583 => 207584)


--- trunk/Source/WebCore/ChangeLog	2016-10-20 02:33:19 UTC (rev 207583)
+++ trunk/Source/WebCore/ChangeLog	2016-10-20 03:10:12 UTC (rev 207584)
@@ -1,3 +1,26 @@
+2016-10-19  Jer Noble  <jer.no...@apple.com>
+
+        REGRESSION (r206025): All YouTube videos play with black bars on all four sides
+        https://bugs.webkit.org/show_bug.cgi?id=163308
+
+        Reviewed by Darin Adler.
+
+        Test: media/media-source/media-source-resize.html
+
+        After r206025, we do not fire resize events when the size change notification happens equal-
+        to-or-before the current time, which can happen at the very beginning of a stream. Take care
+        of this case by checking that the target time isn't actually in the past inside of
+        sizeWillChangeAtTime(), and also always skip the boundary time observer when there was no
+        previous size (such as after a flush due to a seek).
+
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::sizeWillChangeAtTime):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setNaturalSize):
+        * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
+        (WebCore::SourceBufferPrivateAVFObjC::flushAndEnqueueNonDisplayingSamples):
+        (WebCore::SourceBufferPrivateAVFObjC::enqueueSample):
+
 2016-10-19  Nan Wang  <n_w...@apple.com>
 
         AX: [Mac] Mark element AXAPI should comform to specs

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h (207583 => 207584)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h	2016-10-20 02:33:19 UTC (rev 207583)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h	2016-10-20 03:10:12 UTC (rev 207584)
@@ -84,6 +84,7 @@
 
     void effectiveRateChanged();
     void sizeWillChangeAtTime(const MediaTime&, const FloatSize&);
+    void setNaturalSize(const FloatSize&);
     void flushPendingSizeChanges();
     void characteristicsChanged();
 

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm (207583 => 207584)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm	2016-10-20 02:33:19 UTC (rev 207583)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm	2016-10-20 03:10:12 UTC (rev 207584)
@@ -689,13 +689,24 @@
     RetainPtr<id> observer = [m_synchronizer addBoundaryTimeObserverForTimes:times queue:dispatch_get_main_queue() usingBlock:[weakThis, size] {
         if (!weakThis)
             return;
-        RetainPtr<id> observer = weakThis->m_sizeChangeObservers.takeFirst();
-        weakThis->m_naturalSize = size;
-        weakThis->m_player->sizeChanged();
+        weakThis->m_sizeChangeObservers.removeFirst();
+        weakThis->setNaturalSize(size);
     }];
     m_sizeChangeObservers.append(WTFMove(observer));
+
+    if (currentMediaTime() >= time)
+        setNaturalSize(size);
 }
 
+void MediaPlayerPrivateMediaSourceAVFObjC::setNaturalSize(const FloatSize& size)
+{
+    if (size == m_naturalSize)
+        return;
+
+    m_naturalSize = size;
+    m_player->sizeChanged();
+}
+
 void MediaPlayerPrivateMediaSourceAVFObjC::flushPendingSizeChanges()
 {
     while (!m_sizeChangeObservers.isEmpty()) {

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h (207583 => 207584)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h	2016-10-20 02:33:19 UTC (rev 207583)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h	2016-10-20 03:10:12 UTC (rev 207584)
@@ -157,7 +157,7 @@
     SourceBufferPrivateClient* m_client;
     CDMSessionMediaSourceAVFObjC* m_session { nullptr };
 
-    FloatSize m_cachedSize;
+    Optional<FloatSize> m_cachedSize;
     FloatSize m_currentSize;
     bool m_parsingSucceeded;
     bool m_parserStateWasReset { false };

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm (207583 => 207584)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm	2016-10-20 02:33:19 UTC (rev 207583)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm	2016-10-20 03:10:12 UTC (rev 207584)
@@ -962,6 +962,8 @@
         [layer enqueueSampleBuffer:sampleBuffer.get()];
     }
 
+    m_cachedSize = Nullopt;
+
     if (m_mediaSource) {
         m_mediaSource->player()->setHasAvailableVideoFrame(false);
         m_mediaSource->player()->flushPendingSizeChanges();
@@ -985,11 +987,16 @@
     if (trackID == m_enabledVideoTrackID) {
         CMFormatDescriptionRef formatDescription = CMSampleBufferGetFormatDescription(platformSample.sample.cmSampleBuffer);
         FloatSize formatSize = FloatSize(CMVideoFormatDescriptionGetPresentationDimensions(formatDescription, true, true));
-        if (formatSize != m_cachedSize) {
+        if (!m_cachedSize || formatSize != m_cachedSize.value()) {
             LOG(MediaSource, "SourceBufferPrivateAVFObjC::enqueueSample(%p) - size change detected: {width=%lf, height=%lf}", formatSize.width(), formatSize.height());
+            bool sizeWasNull = !m_cachedSize;
             m_cachedSize = formatSize;
-            if (m_mediaSource)
-                m_mediaSource->player()->sizeWillChangeAtTime(mediaSample->presentationTime(), formatSize);
+            if (m_mediaSource) {
+                if (sizeWasNull)
+                    m_mediaSource->player()->setNaturalSize(formatSize);
+                else
+                    m_mediaSource->player()->sizeWillChangeAtTime(mediaSample->presentationTime(), formatSize);
+            }
         }
 
         [m_displayLayer enqueueSampleBuffer:platformSample.sample.cmSampleBuffer];
@@ -1033,7 +1040,7 @@
 
 FloatSize SourceBufferPrivateAVFObjC::naturalSize()
 {
-    return m_cachedSize;
+    return m_cachedSize.valueOr(FloatSize());
 }
 
 void SourceBufferPrivateAVFObjC::didBecomeReadyForMoreSamples(int trackID)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to