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

Execution time of callback affects timer interval #26

Closed
magjac opened this issue Aug 3, 2017 · 3 comments
Closed

Execution time of callback affects timer interval #26

magjac opened this issue Aug 3, 2017 · 3 comments

Comments

@magjac
Copy link

magjac commented Aug 3, 2017

https://bl.ocks.org/magjac/073cbfc7c15c0b0aa56c684e1f5d69ff

See console output. Variations in the execution time of the callback affects the time interval. On my computer as much as 350 ms.

@mbostock
Copy link
Member

mbostock commented Aug 3, 2017

Sorry, but I don’t understand what the bug is supposed to be here. If you stall the execution of JavaScript with a tight loop or equivalent, you should expect that the next timer callback (or several callbacks) can be delayed. As long as you are not regularly stalling execution, it should return back to approximate integer multiples of the interval duration (so, elapsed = 4000, elapsed = 5000, elapsed = 6000, etc.).

@magjac
Copy link
Author

magjac commented Sep 5, 2017

For the record; This bug is fixed in d3-timer 1.0.7 (d3 v4.10.2). Compare the block above (which now works) with https://bl.ocks.org/magjac/4db111095c02d6922e03d6ffea04a253 (that uses d3 v4.10.1).

To clarify my expectations: If I stall the execution of JavaScript with a tight loop or equivalent for a time that is shorter than the time to the next timer callback, I expect that callback to fire on time. It now does, but before the bug was fixed, the next callback was delayed with the same amount of time that the stall lasted. However, provided that no more stalling was made, successive timer callbacks all fired on time.

@mbostock
Copy link
Member

mbostock commented Sep 5, 2017

Thanks for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants