Bug 229605 - [Media] Make currentTime compliant with the spec when readyState is HAVE_NOTHING
Summary: [Media] Make currentTime compliant with the spec when readyState is HAVE_NOTHING
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Media (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Enrique Ocaña
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-08-27 02:50 PDT by Enrique Ocaña
Modified: 2021-11-10 03:36 PST (History)
13 users (show)

See Also:


Attachments
Patch (7.47 KB, patch)
2021-08-27 08:33 PDT, Enrique Ocaña
no flags Details | Formatted Diff | Diff
Patch (8.14 KB, patch)
2021-08-30 08:18 PDT, Enrique Ocaña
no flags Details | Formatted Diff | Diff
Patch (8.28 KB, patch)
2021-08-31 03:22 PDT, Enrique Ocaña
no flags Details | Formatted Diff | Diff
Patch (8.15 KB, patch)
2021-08-31 10:17 PDT, Enrique Ocaña
no flags Details | Formatted Diff | Diff
Patch (8.22 KB, patch)
2021-09-02 09:47 PDT, Enrique Ocaña
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Enrique Ocaña 2021-08-27 02:50:31 PDT
(From https://github.com/WebPlatformForEmbedded/WPEWebKit/issues/722)

Setting the media element currentTime property when its readyState is HAVE_NOTHING, returns early with no action.

According to the specification this should get/set an internal default playback position which should be used when the media is not in a ready state.

From [https://html.spec.whatwg.org/#current-playback-position]

> The currentTime attribute must, on getting, return the media element's default playback start position,
> unless that is zero, in which case it must return the element's official playback position. The returned
> value must be expressed in seconds. On setting, if the media element's readyState is HAVE_NOTHING, then
> it must set the media element's default playback start position to the new value; otherwise, it must set
> the official playback position to the new value and then seek to the new value. The new value must be
> interpreted as being in seconds.

The concept of "default playback position" has been around in the spec since October 2011 (https://web.archive.org/web/20111006043825/http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#default-playback-start-position), but the WebKit implementation isn't aware of it and just resorts to regular seeks in those cases.
Comment 1 Enrique Ocaña 2021-08-27 08:33:47 PDT
Created attachment 436629 [details]
Patch
Comment 2 Eric Carlson 2021-08-27 09:49:16 PDT
Comment on attachment 436629 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=436629&action=review

> LayoutTests/media/video-seek-have-nothing.html:25
> +                testExpected('video.currentTime', 2);
> +

It would be useful to check the time after playback starts as well, to test the changes to `HTMLMediaElement::setReadyState`

> LayoutTests/media/video-seek-have-nothing.html:29
> +                }, 1500);

1500ms is probably short enough that we will have false-positives on a heavily loaded bot, so I'd use something much larger (6000?)
Comment 3 Enrique Ocaña 2021-08-30 08:18:55 PDT
Created attachment 436774 [details]
Patch
Comment 4 Enrique Ocaña 2021-08-31 03:22:40 PDT
Created attachment 436868 [details]
Patch
Comment 5 Enrique Ocaña 2021-08-31 10:17:21 PDT
Created attachment 436902 [details]
Patch
Comment 6 Enrique Ocaña 2021-09-01 10:17:35 PDT
Now only the Mac stress test bot fails.

CurrentTime "goes back" to 0 after the seeked event. I guess it's because we reset defaultPlaybackStartPosition (so the "actual" 0 position is now into effect for currentTime), but the seekTask() enqueued internally by seekWithTolerance() takes time to run, so that temporary 0 is visible. However, the "seeked" event is only triggered after the seek has been completed, so I don't know why the seek target time isn't returned.
Comment 7 Enrique Ocaña 2021-09-02 09:47:16 PDT
Created attachment 437161 [details]
Patch
Comment 8 Radar WebKit Bug Importer 2021-09-03 02:51:15 PDT
<rdar://problem/82715905>
Comment 9 EWS 2021-11-10 03:36:12 PST
Committed r285571 (244079@main): <https://commits.webkit.org/244079@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 437161 [details].