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

Behavior of repeating timers is under-specified #15690

Closed
rmacnak-google opened this issue Dec 18, 2013 · 2 comments
Closed

Behavior of repeating timers is under-specified #15690

rmacnak-google opened this issue Dec 18, 2013 · 2 comments
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-async

Comments

@rmacnak-google
Copy link
Contributor

Imagine the callback is slow. Does the interval between callbacks measure between the beginnings of two callbacks, or from the end of one callback to the beginning of another?

Does the first callback happen as soon as possible or after one occurrence of the interval?

Or do we not make promises either way because the browsers timers do not? Either way, the behavior should be documented.

@lrhn
Copy link
Member

lrhn commented Dec 18, 2013

We really can't promise much when we use the window.setInterval in JavaScript.
The WhatWG specification of timers says that the timer will restart after running the callback code, and after the current document has been "fully active" for 'timeout' milliseconds. That's too vague to make promises from.
The current VM timer actually schedules the timer at regular intervals (start, start+timeout, start+2*timeout, etc.) and fires as soon as possible after each.
That can mean that there are less than 'timeout' milliseconds between two events.

We can promise that the timer repeats, and that it repeats no more than n times in n*timeout milliseconds, but apart from that, no promises.

I'll see if I can document this somewhere.

@lrhn
Copy link
Member

lrhn commented Oct 6, 2014

Documentation added.

The VM and the WhatWG spec differ on how to handle repeating timers, so this is as precise as we can get.

We might want to consider changing the VM to use the same behavior as the browser, but that's another issue.


Added Fixed label.

@rmacnak-google rmacnak-google added Type-Defect area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-async labels Oct 6, 2014
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-async
Projects
None yet
Development

No branches or pull requests

3 participants