Bug 1677880 - waiting 'timeupdate' to ensure video is still playing after resuming decoding. r=bryce

In D96896, we chose to suspend video decoding before starting video in order to avoid the race where the video decode is completed by the time it should be suspended.

However, it causes another issue which is affecting the play promise, because we would only resolve the play promise when we have enough data that is related with decoding.

Therefore, in this patch, I choose not to wait until video reaches to the end, instead to wait `timeupdate` to ensure that the video is still playing after resuming video decoding.

If we don't rely on looping to the end, then we don't need to start video from `3` second which is used to shorten the time before video reaches to the end. That gives us more time to reach the completed state (6s, the video's duration) which should prevent us hitting the race again.

Differential Revision: https://phabricator.services.mozilla.com/D97800
This commit is contained in:
alwu 2020-12-10 14:58:46 +00:00
Родитель 56e1cf83ea
Коммит 9d7be35d14
1 изменённых файлов: 6 добавлений и 16 удалений

Просмотреть файл

@ -16,14 +16,10 @@
*/
async function startTest() {
const video = await createVisibleVideo();
// Start and immediately suspend the video to avoid races where the video
// decode is complete by the time it should be suspended.
await Promise.all([
suspendVideoDecoding(video),
startVideo(video),
]);
await startVideo(video);
await suspendVideoDecoding(video);
await resumeVideoDecoding(video);
await waitUntilVideoLoopAgain(video);
await checkIfVideoIsStillPlaying(video);
endTestAndClearVideo(video);
}
@ -44,9 +40,6 @@ async function createVisibleVideo() {
video.src = "gizmo-noaudio.webm";
video.controls = true;
video.loop = true;
// In order to reduce the test running time, because we don't need to acutally
// go through the whole video.
video.currentTime = 3;
document.body.appendChild(video);
info(`ensure video becomes visible`);
await waitUntilVisible(video);
@ -73,12 +66,9 @@ async function resumeVideoDecoding(video) {
info(`resumed video decoding`);
}
async function waitUntilVideoLoopAgain(video) {
info(`ensure video is still playing after resuming video decoding.`);
await once(video, "seeking");
info(`got 'seeking' event.`);
await once(video, "seeked");
ok(!video.paused, "video is still playing and looping again.")
async function checkIfVideoIsStillPlaying(video) {
await once(video, "timeupdate");
ok(!video.paused, "video is still playing after resuming video decoding.")
}
function endTestAndClearVideo(video) {