[whatwg] Timeouts and monotonic vs clock time

Simon Fraser smfr at me.com
Wed Nov 3 20:08:23 PDT 2010


On Nov 3, 2010, at 8:01 PM, and-py wrote:

> Here's a curious little issue.
> 
> When you use `setTimeout` or `setInterval`, the HTML5 spec seems to say
> that the callback should occur after a certain amount of actual time has
> elapsed.
> 
> But what browsers might do is take the system clock, add the given
> number of milliseconds and call back when that system clock time is
> reached. The firing time will differ from the actual-elapsed-time, if
> the system clock is changed in between the setting and the calling of
> the callback.

Another issue to consider here is what happens when the machine goes to sleep,
and then wakes up. This is a much more common scenario than the user
changing the system clock.

Simon




More information about the whatwg mailing list