Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4801,14 +4801,15 @@ test.describe('page freeze', () => {
const box = page.locator('#box');
const watch = await watchAnimations(box);
const startedAt = Date.now();
await box.evaluate(el => {
el.animate(
// Over before the freeze, and read only after the thaw. The freeze waits
// for the run's own end. A run starts only at a frame, and a busy machine
// can draw no frame for longer than any fixed wait.
await box.evaluate(async el => {
await el.animate(
[{transform: 'translateX(0px)'}, {transform: 'translateX(100px)'}],
{duration: 200},
);
).finished;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Non-blocking: frozenAt (line 4806) is now read as soon as finished resolves. The recorder dates the finish at start + 200 ms, and in Chromium that is often exactly the finishing frame's time. So the check at line 4814 (finishedAt < frozenAt, with frozenAt a whole millisecond) passes by about 1 to 2 ms there. One more frame before returning keeps the ordering this change wants and adds a frame of margin whatever the load:

await el.animate(/* … */).finished;
await new Promise(requestAnimationFrame);

});
// Over before the freeze, and read only after the thaw.
await page.waitForTimeout(400);
const frozenAt = Date.now();
await freezePage(page);
await page.waitForTimeout(600);
Expand All @@ -4832,11 +4833,13 @@ test.describe('page freeze', () => {
{duration: 60_000, easing: 'linear'},
);
});
await page.waitForTimeout(100);
// Where the run started, on the page's clock, before any freeze.
const startedAt = await page.evaluate(() =>
Number((window as unknown as {run: Animation}).run.startTime),
);
// Where the run started, on the page's clock, before any freeze. It has
// a start time only once a frame starts it, so the read waits for that.
const startedAt = await page.evaluate(async () => {
const {run} = window as unknown as {run: Animation};
await run.ready;
return Number(run.startTime);
});
for (let cycle = 0; cycle < 10; cycle++) {
await freezePage(page);
await page.waitForTimeout(50);
Expand Down
Loading