Bug 254136

Summary: [MSE] readyState may not move from HAVE_METADATA following a seek.
Product: WebKit Reporter: Jean-Yves Avenard [:jya] <jean-yves.avenard>
Component: MediaAssignee: Jean-Yves Avenard [:jya] <jean-yves.avenard>
Status: RESOLVED FIXED    
Severity: Normal CC: webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=254199
https://bugs.webkit.org/show_bug.cgi?id=254198

Description Jean-Yves Avenard [:jya] 2023-03-19 07:42:42 PDT
Seen with LayoutTests/media/media-source/media-source-end-of-stream-buffered.html when running in the GPU process.

When we seek to the end of the video while the MediaSource is still in open state, the readyState move to HAVE_METADATA [1] as we have the new playback position not in any TimeRanges of HTMLMediaElement.buffered.

Once MediaSource.endOfStream() was called the readyState should be moved to HAVE_CURRENT_DATA as currentTime is now at the end of the video [2]
However, we do not update the readyState under those circumstances and we stay in HAVE_METADATA

As such if play() is called, playback wouldn't start (for the video to then end end the ended event should be fired) and the waiting event would fire instead.

[1] https://w3c.github.io/media-source/#mediasource-seeking
[2] https://html.spec.whatwg.org/multipage/media.html#dom-media-have_current_data
Comment 1 Radar WebKit Bug Importer 2023-03-19 07:43:06 PDT
<rdar://problem/106914173>
Comment 2 Jean-Yves Avenard [:jya] 2023-03-19 17:35:35 PDT
Pull request: https://github.com/WebKit/WebKit/pull/11699
Comment 3 EWS 2023-03-22 02:06:54 PDT
Committed 261949@main (e1d76fd08756): <https://commits.webkit.org/261949@main>

Reviewed commits have been landed. Closing PR #11699 and removing active labels.