Issue metadata
Sign in to add a comment
|
setInterval running immediately when interval time is big
Reported by
m...@bnaya.net,
Feb 8 2017
|
||||||||||||||||||||||
Issue description
UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36
Steps to reproduce the problem:
Run this code on the console and see:
window.setInterval(() => {
debugger;
}, 1000);
window.setInterval(() => {
debugger;
}, 2592000000);
What is the expected behavior?
The second interval need to run every 2592000000 ms
What went wrong?
The second interval is running every 0 ms
Did this work before? Yes
Does this work in other browsers? N/A
Chrome version: 56.0.2924.87 Channel: stable
OS Version: OS X 10.12.3
Flash Version:
,
Feb 8 2017
On the other hand, I agree that conversion could be smarter and clamp the invalid values to the maximum value of 2147483647 and emit a warning in console.
,
Feb 8 2017
****Bulk Edit**** Setting as P1 for test team to prioritize in triaging.
,
Feb 9 2017
,
Feb 9 2017
Tested in chrome #56.0.2924.87 and Canary #58.0.3006.0 on Mac 10.12.2 and not able to reproduce the issue.Please find the screen shot for your reference. @reporter: Could you please let me know if i have missed anything and if possible, provide us with a sample steps of the issue which would help us to triage the issue further. Thanks in Advance.
,
Feb 13 2017
,
Feb 14 2017
It's not actually running every 0ms.
var t = window.performance.now();
var count = 0;
var id = window.setInterval(() => {
if (++count > 7) {
window.clearInterval(id);
}
t2 = window.performance.now();
console.log(t2 - t);
t = t2;
}, 2592000000);
This code produces:
1.3500000000349246
0.8449999999720603
1
1.0249999999650754
3.9700000000884756
4.009999999951106
4.039999999979045
3.995000000053551
That's approximately {1, 1, 1, 1, 4, 4, 4, 4}, which is what you would expect if you'd used an interval of <1 since it clamps to 1ms for the first iterations and then after 4 iterations it clamps to 4ms.
,
Feb 16 2017
The current behaviour is exactly what we would expect from the spec (and is also what we see in other browsers): https://html.spec.whatwg.org/multipage/webappapis.html#windoworworkerglobalscope-mixin:dom-setinterval The timeout is defined as a long, which is defined as an Int32. No clamping is specified so normal conversion is performed which truncates and then returns the value modulo 2^31. To introduce clamping we'd have to change the spec to add [Clamp] to the definition of setInterval (and setTimeout). I don't see the value since this would only affect someone who actually wanted an interval of 25+ days, who presumably would want the timeout to be exact rather than arbitrarily clamped.
,
Feb 16 2017
|
|||||||||||||||||||||||
►
Sign in to add a comment |
|||||||||||||||||||||||
Comment 1 by woxxom@gmail.com
, Feb 8 2017