Skip to content

[reftests] Use requestAnimationFrame instead of takeScreenshotDelayed #4482

@kainino0x

Description

@kainino0x

takeScreenshotDelayed(50) is a bad heuristic for making sure rendering is done before taking the screenshot:

takeScreenshotDelayed(50);

See discussion: https://github.com/gpuweb/cts/pull/4479/files#r2446286603

Instead we should replace it with something that uses requestAnimationFrame, which won't fire until (just before) rendering is actually happening, then take the screenshot. Something like this (or equivalent using async) would be theoretically tightest:

function requestPostAnimationFrame(fn) {
  requestAnimationFrame(() => timeout(fn, 0));
}
requestPostAnimationFrame(takeScreenshot);

EDIT: But see below, we need to do rAF(rAF(fn)) to be safe.

Also, might try to remove other usages of takeScreenshotDelayed so that it's private to runRefTest.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Open (no TODO)

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions