Title: [285586] trunk
Revision
285586
Author
[email protected]
Date
2021-11-10 09:42:35 -0800 (Wed, 10 Nov 2021)

Log Message

[GTK] Layout Test media/video-seek-with-negative-playback.html timeouts on the release bot.
https://bugs.webkit.org/show_bug.cgi?id=135086

Reviewed by Xabier Rodriguez-Calvar.

Source/WebCore:

In some specific cases, an EOS GstEvent can happen right before a seek. The event is translated
by playbin as an EOS GstMessage and posted to the bus, waiting to be forwarded to the main thread.
The EOS message (now irrelevant after the seek) is received and processed right after the seek,
causing the termination of the media at the player private and upper levels. This can even happen
after the seek has completed (m_isSeeking already false).

This patch detects that condition by ensuring that the playback is coherent with the EOS message,
that is, if we're still playing somewhere inside the playable ranges, there should be no EOS at
all. If that's the case, it's considered to be one of those spureous EOS and is ignored.

Live streams (infinite duration) are special and we still have to detect legitimate EOS there, so
this message bailout isn't done in those cases.

Also refactored the code that queries the position to the sinks.

* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp: Ignore EOS message if the playback position is inside the playback limits when they're finite. Refactored sink position query code as gstreamerPositionFromSinks().
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h: Added gstreamerPositionFromSinks().

LayoutTests:

* platform/glib/TestExpectations: Unskipped test.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (285585 => 285586)


--- trunk/LayoutTests/ChangeLog	2021-11-10 17:41:49 UTC (rev 285585)
+++ trunk/LayoutTests/ChangeLog	2021-11-10 17:42:35 UTC (rev 285586)
@@ -1,3 +1,12 @@
+2021-11-10  Enrique Ocaña González  <[email protected]>
+
+        [GTK] Layout Test media/video-seek-with-negative-playback.html timeouts on the release bot.
+        https://bugs.webkit.org/show_bug.cgi?id=135086
+
+        Reviewed by Xabier Rodriguez-Calvar.
+
+        * platform/glib/TestExpectations: Unskipped test.
+
 2021-11-10  Rob Buis  <[email protected]>
 
         [css-contain] Support contain:paint

Modified: trunk/LayoutTests/platform/glib/TestExpectations (285585 => 285586)


--- trunk/LayoutTests/platform/glib/TestExpectations	2021-11-10 17:41:49 UTC (rev 285585)
+++ trunk/LayoutTests/platform/glib/TestExpectations	2021-11-10 17:42:35 UTC (rev 285586)
@@ -2341,7 +2341,6 @@
 
 webkit.org/b/108925 http/tests/media/video-play-stall.html [ Failure Timeout ]
 
-webkit.org/b/135086 media/video-seek-with-negative-playback.html [ Timeout Pass ]
 webkit.org/b/137698 media/video-controls-drag.html [ Timeout ]
 webkit.org/b/141959 http/tests/media/clearkey/clear-key-hls-aes128.html [ Crash Timeout ]
 webkit.org/b/142489 http/tests/media/video-play-waiting.html [ Timeout ]

Modified: trunk/Source/WebCore/ChangeLog (285585 => 285586)


--- trunk/Source/WebCore/ChangeLog	2021-11-10 17:41:49 UTC (rev 285585)
+++ trunk/Source/WebCore/ChangeLog	2021-11-10 17:42:35 UTC (rev 285586)
@@ -1,3 +1,28 @@
+2021-11-10  Enrique Ocaña González  <[email protected]>
+
+        [GTK] Layout Test media/video-seek-with-negative-playback.html timeouts on the release bot.
+        https://bugs.webkit.org/show_bug.cgi?id=135086
+
+        Reviewed by Xabier Rodriguez-Calvar.
+
+        In some specific cases, an EOS GstEvent can happen right before a seek. The event is translated
+        by playbin as an EOS GstMessage and posted to the bus, waiting to be forwarded to the main thread.
+        The EOS message (now irrelevant after the seek) is received and processed right after the seek,
+        causing the termination of the media at the player private and upper levels. This can even happen
+        after the seek has completed (m_isSeeking already false).
+
+        This patch detects that condition by ensuring that the playback is coherent with the EOS message,
+        that is, if we're still playing somewhere inside the playable ranges, there should be no EOS at
+        all. If that's the case, it's considered to be one of those spureous EOS and is ignored.
+
+        Live streams (infinite duration) are special and we still have to detect legitimate EOS there, so
+        this message bailout isn't done in those cases.
+
+        Also refactored the code that queries the position to the sinks.
+
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp: Ignore EOS message if the playback position is inside the playback limits when they're finite. Refactored sink position query code as gstreamerPositionFromSinks().
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h: Added gstreamerPositionFromSinks().
+
 2021-11-10  Jer Noble  <[email protected]>
 
         [iOS] Adopt -[AVAudioSession setAuditTokensForProcessAssertion:]

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp (285585 => 285586)


--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp	2021-11-10 17:41:49 UTC (rev 285585)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp	2021-11-10 17:42:35 UTC (rev 285586)
@@ -1276,6 +1276,31 @@
     return sink;
 }
 
+GstClockTime MediaPlayerPrivateGStreamer::gstreamerPositionFromSinks() const
+{
+    gint64 gstreamerPosition = GST_CLOCK_TIME_NONE;
+    // Asking directly to the sinks and choosing the highest value is faster than asking to the pipeline.
+    GRefPtr<GstQuery> query = adoptGRef(gst_query_new_position(GST_FORMAT_TIME));
+    if (m_audioSink && gst_element_query(m_audioSink.get(), query.get())) {
+        gint64 audioPosition = GST_CLOCK_TIME_NONE;
+        gst_query_parse_position(query.get(), 0, &audioPosition);
+        if (GST_CLOCK_TIME_IS_VALID(audioPosition))
+            gstreamerPosition = audioPosition;
+        GST_TRACE_OBJECT(pipeline(), "Audio position %" GST_TIME_FORMAT, GST_TIME_ARGS(audioPosition));
+        query = adoptGRef(gst_query_new_position(GST_FORMAT_TIME));
+    }
+    if (m_videoSink && gst_element_query(m_videoSink.get(), query.get())) {
+        gint64 videoPosition = GST_CLOCK_TIME_NONE;
+        gst_query_parse_position(query.get(), 0, &videoPosition);
+        GST_TRACE_OBJECT(pipeline(), "Video position %" GST_TIME_FORMAT, GST_TIME_ARGS(videoPosition));
+        if (GST_CLOCK_TIME_IS_VALID(videoPosition) && (!GST_CLOCK_TIME_IS_VALID(gstreamerPosition)
+            || (m_playbackRate >= 0 && videoPosition > gstreamerPosition)
+            || (m_playbackRate < 0 && videoPosition < gstreamerPosition)))
+            gstreamerPosition = videoPosition;
+    }
+    return static_cast<GstClockTime>(gstreamerPosition);
+}
+
 MediaTime MediaPlayerPrivateGStreamer::playbackPosition() const
 {
     GST_TRACE_OBJECT(pipeline(), "isEndReached: %s, seeking: %s, seekTime: %s", boolForPrinting(m_isEndReached), boolForPrinting(m_isSeeking), m_seekTime.toString().utf8().data());
@@ -1295,28 +1320,7 @@
         return m_cachedPosition.value();
     }
 
-    // Position is only available if no async state change is going on and the state is either paused or playing.
-    gint64 position = GST_CLOCK_TIME_NONE;
-
-    // Asking directly to the sinks and choosing the highest value is faster than asking to the pipeline.
-    GRefPtr<GstQuery> query = adoptGRef(gst_query_new_position(GST_FORMAT_TIME));
-    if (m_audioSink && gst_element_query(m_audioSink.get(), query.get())) {
-        gint64 audioPosition = GST_CLOCK_TIME_NONE;
-        gst_query_parse_position(query.get(), 0, &audioPosition);
-        if (GST_CLOCK_TIME_IS_VALID(audioPosition))
-            position = audioPosition;
-        query = adoptGRef(gst_query_new_position(GST_FORMAT_TIME));
-    }
-    if (m_videoSink && gst_element_query(m_videoSink.get(), query.get())) {
-        gint64 videoPosition = GST_CLOCK_TIME_NONE;
-        gst_query_parse_position(query.get(), 0, &videoPosition);
-        if (GST_CLOCK_TIME_IS_VALID(videoPosition) && (!GST_CLOCK_TIME_IS_VALID(position)
-            || (m_playbackRate >= 0 && videoPosition > position)
-            || (m_playbackRate < 0 && videoPosition < position)))
-            position = videoPosition;
-    }
-
-    GstClockTime gstreamerPosition = static_cast<GstClockTime>(position);
+    GstClockTime gstreamerPosition = gstreamerPositionFromSinks();
     GST_TRACE_OBJECT(pipeline(), "Position %" GST_TIME_FORMAT ", canFallBackToLastFinishedSeekPosition: %s", GST_TIME_ARGS(gstreamerPosition), boolForPrinting(m_canFallBackToLastFinishedSeekPosition));
 
     MediaTime playbackPosition = MediaTime::zeroTime();
@@ -1762,9 +1766,32 @@
             }
         }
         break;
-    case GST_MESSAGE_EOS:
+    case GST_MESSAGE_EOS: {
+        // In some specific cases, an EOS GstEvent can happen right before a seek. The event is translated
+        // by playbin as an EOS GstMessage and posted to the bus, waiting to be forwarded to the main thread.
+        // The EOS message (now irrelevant after the seek) is received and processed right after the seek,
+        // causing the termination of the media at the player private and upper levels. This can even happen
+        // after the seek has completed (m_isSeeking already false).
+        // The code below detects that condition by ensuring that the playback is coherent with the EOS message,
+        // that is, if we're still playing somewhere inside the playable ranges, there should be no EOS at
+        // all. If that's the case, it's considered to be one of those spureous EOS and is ignored.
+        // Live streams (infinite duration) are special and we still have to detect legitimate EOS there, so
+        // this message bailout isn't done in those cases.
+        MediaTime playbackPosition = MediaTime::invalidTime();
+        MediaTime duration = durationMediaTime();
+        GstClockTime gstreamerPosition = gstreamerPositionFromSinks();
+        if (GST_CLOCK_TIME_IS_VALID(gstreamerPosition))
+            playbackPosition = MediaTime(gstreamerPosition, GST_SECOND);
+        if (playbackPosition.isValid() && duration.isValid()
+            && ((m_playbackRate >= 0 && playbackPosition < duration && duration.isFinite())
+            || (m_playbackRate < 0 && playbackPosition > MediaTime::zeroTime()))) {
+            GST_DEBUG_OBJECT(pipeline(), "EOS received but position %s is still in the finite playable limits [%s, %s], ignoring it",
+                playbackPosition.toString().utf8().data(), MediaTime::zeroTime().toString().utf8().data(), duration.toString().utf8().data());
+            break;
+        }
         didEnd();
         break;
+    }
     case GST_MESSAGE_ASYNC_DONE:
         if (!messageSourceIsPlaybin || m_isDelayingLoad)
             break;

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h (285585 => 285586)


--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h	2021-11-10 17:41:49 UTC (rev 285585)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h	2021-11-10 17:42:35 UTC (rev 285586)
@@ -438,6 +438,7 @@
 
     void syncOnClock(bool sync);
 
+    GstClockTime gstreamerPositionFromSinks() const;
     MediaTime playbackPosition() const;
 
     virtual void updateStates();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to