Bug 283443
| Summary: | VideoMediaSampleRenderer can resolve its `WhenHasAvailableVideoFrame` callback with a flushed frame. | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Jean-Yves Avenard [:jya] <jean-yves.avenard> |
| Component: | Media | Assignee: | 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 | ||
Jean-Yves Avenard [:jya]
Noticed when I was trying to understand why a test intermittently timed out.
When we do:
```
let v = document.getElementsByTagName('video')[0];
v.src = "content/test-vp8-hiddenframes.webm";
await waitFor(v, 'loadedmetadata', true);
// duration of the last frame.
v.currentTime = v.duration - 0.038;
let p1 = new Promise(resolve => v.requestVideoFrameCallback(resolve));
let p2 = waitFor(v, 'seeked', true);
await Promise.all([ p1, p2 ]);
```
the p1 promise here may not always be resolved.
The reason being is:
when the video is being loaded, we immediately start decoding video.
The MediaPlayerPrivate feeds the data to the VideoMediaSampleRenderer, set the WhenHasAvailableVideoFrame callback. Shortly after the VideoMediaSampleRenderer decode the frame, push it to the renderer and queue a task back to the main thread to call the WhenHasAvailableVideoFrame callback.
In between, the player is now seeking, it flushes the VideoMediaSampleRenderer, pushes the new frames to decode and set a new WhenHasAvailableVideoFrame callback.
Just at this time the pending WhenHasAvailableVideoFrame queued gets called, once called the callback gets cleared.
The MediaPlayerPrivate now believes that the seek is complete to the right frame when there's now no frame displayed has the seek started and all decoded frames got flushed.
The new decoded frame pushed for seeking now gets decoded and another WhenHasAvailableVideoFrame gets called, but by this time the callback is cleared (see above).
We never call the requestVideoFrameCallback's callback
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Radar WebKit Bug Importer
<rdar://problem/140301261>
Jean-Yves Avenard [:jya]
Pull request: https://github.com/WebKit/WebKit/pull/36924
EWS
Committed 286949@main (284f68f80bbb): <https://commits.webkit.org/286949@main>
Reviewed commits have been landed. Closing PR #36924 and removing active labels.