[MSE] Seeks to currentTime=0 will fail if currentTime is already 0.
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 5 Apr 2017 19:09:28 +0000 (19:09 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 5 Apr 2017 19:09:28 +0000 (19:09 +0000)
https://bugs.webkit.org/show_bug.cgi?id=170510
Source/WebCore:

<rdar://problem/30988403>

Reviewed by Eric Carlson.

Test: media/media-source/media-source-unnecessary-seek-seeked.html

The AVSampleBufferRenderSynchronizer won't fire a time jumped notification if no seek is actully
necessary. So short circuit the seek logic if the seek time is identical to the current synchronizer
time.

* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::seekInternal):

LayoutTests:

Reviewed by Eric Carlson.

* media/media-source/media-source-unnecessary-seek-seeked-expected.txt: Added.
* media/media-source/media-source-unnecessary-seek-seeked.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@214959 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/media/media-source/media-source-unnecessary-seek-seeked-expected.txt [new file with mode: 0644]
LayoutTests/media/media-source/media-source-unnecessary-seek-seeked.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm

index e327608..4821494 100644 (file)
@@ -1,3 +1,13 @@
+2017-04-05  Jer Noble  <jer.noble@apple.com>
+
+        [MSE] Seeks to currentTime=0 will fail if currentTime is already 0.
+        https://bugs.webkit.org/show_bug.cgi?id=170510
+
+        Reviewed by Eric Carlson.
+
+        * media/media-source/media-source-unnecessary-seek-seeked-expected.txt: Added.
+        * media/media-source/media-source-unnecessary-seek-seeked.html: Added.
+
 2017-04-05  Matt Baker  <mattbaker@apple.com>
 
         Web Inspector: XHR breakpoints should be global
diff --git a/LayoutTests/media/media-source/media-source-unnecessary-seek-seeked-expected.txt b/LayoutTests/media/media-source/media-source-unnecessary-seek-seeked-expected.txt
new file mode 100644 (file)
index 0000000..8aae529
--- /dev/null
@@ -0,0 +1,14 @@
+
+RUN(video.src = URL.createObjectURL(source))
+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(update)
+EVENT(seeking)
+EVENT(seeked)
+END OF TEST
+
diff --git a/LayoutTests/media/media-source/media-source-unnecessary-seek-seeked.html b/LayoutTests/media/media-source/media-source-unnecessary-seek-seeked.html
new file mode 100644 (file)
index 0000000..236b942
--- /dev/null
@@ -0,0 +1,54 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <title>media-source-abort-resets-parser</title>
+    <script src="media-source-loader.js"></script>
+    <script src="../video-test.js"></script>
+    <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);
+        run('video.src = URL.createObjectURL(source)');
+    }
+
+    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() {
+        consoleWrite('Append a media segment.')
+        waitForEventOn(sourceBuffer, 'update', mediaSegmentAppended, false, true);
+        run('sourceBuffer.appendBuffer(loader.mediaSegment(0))');
+    }
+
+    function mediaSegmentAppended() {
+        waitForEvent('seeking');
+        waitForEventAndEnd('seeked');
+        video.currentTime = video.currentTime;
+        failTestIn(1000);
+    }
+    </script>
+</head>
+<body onload="runTest()">
+    <video controls></video>
+</body>
+</html>
\ No newline at end of file
index 91358e9..80bc5b8 100644 (file)
@@ -1,3 +1,20 @@
+2017-04-05  Jer Noble  <jer.noble@apple.com>
+
+        [MSE] Seeks to currentTime=0 will fail if currentTime is already 0.
+        https://bugs.webkit.org/show_bug.cgi?id=170510
+        <rdar://problem/30988403>
+
+        Reviewed by Eric Carlson.
+
+        Test: media/media-source/media-source-unnecessary-seek-seeked.html
+
+        The AVSampleBufferRenderSynchronizer won't fire a time jumped notification if no seek is actully
+        necessary. So short circuit the seek logic if the seek time is identical to the current synchronizer
+        time.
+
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::seekInternal):
+
 2017-04-05  Chris Dumez  <cdumez@apple.com>
 
         <input type="range"> changing to disabled while active breaks all pointer events
index ac55d6d..9015551 100644 (file)
@@ -411,9 +411,24 @@ void MediaPlayerPrivateMediaSourceAVFObjC::seekInternal()
 
     LOG(MediaSource, "MediaPlayerPrivateMediaSourceAVFObjC::seekInternal(%p) - seekTime(%s)", this, toString(m_lastSeekTime).utf8().data());
 
+    MediaTime synchronizerTime = toMediaTime(CMTimebaseGetTime([m_synchronizer timebase]));
+    bool doesNotRequireSeek = synchronizerTime == m_lastSeekTime;
+
     m_mediaSourcePrivate->willSeek();
     [m_synchronizer setRate:0 time:toCMTime(m_lastSeekTime)];
     m_mediaSourcePrivate->seekToTime(m_lastSeekTime);
+
+    // In cases where the destination seek time precisely matches the synchronizer's existing time
+    // no time jumped notification will be issued. In this case, just notify the MediaPlayer that
+    // the seek completed successfully.
+    if (doesNotRequireSeek) {
+        m_seeking = false;
+
+        if (shouldBePlaying())
+            [m_synchronizer setRate:m_rate];
+        if (!seeking() && m_seekCompleted)
+            m_player->timeChanged();
+    }
 }
 
 void MediaPlayerPrivateMediaSourceAVFObjC::waitForSeekCompleted()