[whatwg] Timeouts and monotonic vs clock time

On Thu, 4 Nov 2010, 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.
>
> [snip useful but long description of browser behaviours -- thanks]
> 
> Can it be confirmed that the delay-based behaviour is what is intended
> and should be implemented by browsers?

Yes, the specced behaviour is intentional.


On Wed, 3 Nov 2010, Simon Fraser wrote:
> 
> 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.

The spec seems to handle this case (the timers aren't stopped by the 
system being suspended, but e.g. setInterval won't fire more than once).

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

Received on Friday, 7 January 2011 14:17:57 UTC