Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

De-flake fromPixels test failure #6626

Merged
merged 2 commits into from
Aug 5, 2022
Merged

De-flake fromPixels test failure #6626

merged 2 commits into from
Aug 5, 2022

Conversation

hujiajie
Copy link
Contributor

@hujiajie hujiajie commented Jul 15, 2022

HTMLVideoElement.requestVideoFrameCallback() provides a realiable way to guarantee the readiness of a video frame, whereas the browser may not update the ready state until a few frames later. In such cases, false alarms will be raised by the validation in fromPixels().

Fixes #6577

To see the logs from the Cloud Build CI, please join either our discussion or announcement mailing list.


This change is Reviewable

@hujiajie
Copy link
Contributor Author

cc @nsthorat who initially authored this check, cc @gyagp who introduced rVFC in #6549

Copy link
Contributor

@qjia7 qjia7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@qjia7 qjia7 requested a review from gyagp July 15, 2022 06:23
@@ -56,6 +56,11 @@ describeWebGPU('fromPixels', () => {
if ('requestVideoFrameCallback' in video) {
// tslint:disable-next-line:no-any
await new Promise(go => (video as any).requestVideoFrameCallback(go));
} else {
// On mobile safari the ready state is ready immediately.
if (video.readyState < HTMLVideoElement.prototype.HAVE_CURRENT_DATA) {
Copy link

@gyagp gyagp Jul 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WebGPU uses video.currentTime for check: /~https://github.com/gpuweb/cts/blob/0dd7405d1bfa950a71572aeb77aa38aacef6653d/src/webgpu/web_platform/util.ts#L48.
WebGL uses a simpler solution as currently we have: /~https://github.com/KhronosGroup/WebGL/blob/main/sdk/tests/js/webgl-test-utils.js#L3182.

Do you like to keep sync with WebGPU solution?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Digging through the history of WebGL CTS, it seems awaiting video.play() + optional rVFC works fine across browsers and is preferred over video.currentTime, so I decided to drop the change here.

@hujiajie hujiajie marked this pull request as draft July 15, 2022 07:17
@hujiajie hujiajie marked this pull request as ready for review July 15, 2022 08:14
Copy link

@gyagp gyagp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@gyagp
Copy link

gyagp commented Jul 15, 2022

@pyu10055 @lina128 @Linchenn PTAL!

@gyagp gyagp requested review from pyu10055, Linchenn and lina128 July 22, 2022 02:16
Copy link
Collaborator

@pyu10055 pyu10055 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, does this change affects WebGL tests?

Reviewable status: :shipit: complete! 2 of 1 approvals obtained (waiting on @gyagp, @lina128, and @Linchenn)

Copy link
Collaborator

@lina128 lina128 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this new API is not supported by Firefox and older Chrome/Safari yet, can we have a fallback? https://web.dev/requestvideoframecallback-rvfc/

Reviewable status: :shipit: complete! 2 of 1 approvals obtained (waiting on @gyagp and @Linchenn)

Copy link
Contributor Author

@hujiajie hujiajie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently rVFC is only used in from_pixels_webgpu_test.ts, and the WebGPU backend is always incompatible with older Chrome/Safari. In this sense, rVFC is assumed to be supported by Chrome/Safari. It also sounds a fallback is redundant in Firefox because of its extra guarantee provided by await video.play() right above (KhronosGroup/WebGL#3319).

WebGL tests seem unaffected by this. All are passing and I didn't grep any relevant case under the backend.

Reviewable status: :shipit: complete! 2 of 1 approvals obtained (waiting on @gyagp and @Linchenn)

`HTMLVideoElement.requestVideoFrameCallback()` provides a realiable way
to guarantee the readiness of a video frame, whereas the browser may not
update the ready state until a few frames later. In such cases, false
alarms will be raised by the validation in `fromPixels()`.

Fixes tensorflow#6577
Copy link
Collaborator

@pyu10055 pyu10055 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 2 of 3 files at r1, 1 of 1 files at r2, all commit messages.
Reviewable status: :shipit: complete! 1 of 1 approvals obtained (waiting on @gyagp, @lina128, and @Linchenn)

Copy link

@gyagp gyagp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Collaborator

@Linchenn Linchenn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The myth of HTMLVideoElement.readyState and HTMLVideoElement.requestVideoFrameCallback
6 participants