Skip to content

Conversation

dgozman
Copy link
Contributor

@dgozman dgozman commented Oct 3, 2025

Since runTo is asynchronous, we might end up in a reentrant call, for example when updateRealTimeTimer timeout happens between two tasks in runTo. This yields to breaking all invariants and results in now being reset to some old value.

To prevent this, introduce a semaphore and only allow a single runTo at a time.
Additionally, update real time timer after runTo, otherwise it might be scheduled for some time in the past when fast-forwarding.

Drive-by:

  • debugDump() for debugging
  • ensure we never rewind time when running tests

Fixes #37635.

Since `runTo` is asynchronous, we might end up in a reentrant call,
for example when `updateRealTimeTimer` timeout happens between two
tasks in `runTo`. This yields to breaking all invariants and results
in `now` being reset to some old value.

To prevent this, introduce a semaphore and only allow a single `runTo`
at a time.

Additionally, ensure we never rewind time when running our tests.
Copy link
Contributor

github-actions bot commented Oct 3, 2025

Test results for "tests 1"

1 failed
❌ [playwright-test] › reporter-html.spec.ts:1078 › created › should use file-browser friendly extensions for buffer attachments based on contentType @macos-latest-node18-2

2 flaky ⚠️ [chromium-library] › library/popup.spec.ts:258 › should not throw when click closes popup `@chromium-ubuntu-22.04-node24`
⚠️ [firefox-library] › library/inspector/cli-codegen-1.spec.ts:1079 › cli codegen › should not throw csp directive violation errors `@firefox-ubuntu-22.04-node18`

46930 passed, 811 skipped


Merge workflow run.


type LogEntryType = 'fastForward' |'install' | 'pauseAt' | 'resume' | 'runFor' | 'setFixedTime' | 'setSystemTime';

class Semaphore {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
class Semaphore {
class Mutex {


private async _runTo(to: Ticks) {
to = Math.ceil(to) as Ticks;
private async _runTo(calculateTo: () => Ticks) {
Copy link
Member

Choose a reason for hiding this comment

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

to being a callback doubles the complexity of the code, I'd really like to avoid it...

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.

[Bug]: requestAnimationFrame does not execute callbacks after page.clock.fastForward() for the duration of time that was fast forwarded
2 participants