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

Timer initialization steps for repeating timers does not match UA behavior #9402

Open
shaseley opened this issue Jun 9, 2023 · 2 comments
Open
Labels
compat Standard is not web compatible or proprietary feature needs standardizing topic: event loop

Comments

@shaseley
Copy link

shaseley commented Jun 9, 2023

For setInterval(), in the "timer initialization steps", "run steps after timeout" is invoked with the original timeout after the callback completes (step 9.5), but UAs schedule subsequent iterations such that next_start_time = previous_start_time + interval.

For example, if you have a setInterval(,50) where each iteration is 25ms, I observe there's ~50ms between iteration start times on FF, Safari, and Chrome (Chrome fires early sometimes, but that's a separate issue), whereas per spec I think this should output ~75ms between iterations (25ms callback + 50ms timeout).

My reading of the Gecko, WebKit, and Blink code matches what I'm seeing, and I think updating the spec to match the UA behavior would make sense. Happy to draft a PR assuming my reading is correct here and folks agree with the change.

@annevk
Copy link
Member

annevk commented Jun 9, 2023

That sounds reasonable to me, although I haven't checked the code. Presumably we do need to be a little careful when the code runs for longer than the interval, but that seems manageable.

cc @smaug----

@annevk annevk added compat Standard is not web compatible or proprietary feature needs standardizing topic: event loop labels Jun 9, 2023
@Kaiido
Copy link
Member

Kaiido commented Jun 9, 2023

I believe this is a duplicate of #3151 which also tried to have Chrome's "drift-free" implementation standardized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compat Standard is not web compatible or proprietary feature needs standardizing topic: event loop
Development

No branches or pull requests

3 participants