[webkit-dev] Proposed Timer API

Dmitry Titov dimich at chromium.org
Thu Oct 2 01:53:35 PDT 2008

Since our systems are not real-time, saying 'hi-res timer' and 'event
dispatching' together may need some clarification.
Lets say we set delay=0.001 - but not every system can guarantee that the
timer event will fire at precise 1 ms interval. So it can "skip a bit" or
fire at longer delay, then continue at 1 and so on. Some systems may skip
more then a bit :-) That's why popular way to implement animations is to
request high frequency callback and query hi-res timer from the handler for
actual advance calculation...
The spec could explicitly point that out ('delay' -> 'delayAtLeast' ?), and
perhaps recommend to use Date() in the event handler to see what is the
actual time of firing, or have an 'eventTime' property on an Event object.

On a separate note, it almost feels that just adding
invokeAsSoonAsPossible(handler) that is equivalent to unclamped
setTimeout(..., 0) could be all that's needed.


On Wed, Oct 1, 2008 at 9:59 AM, Justin Haygood <jhaygood at reaktix.com> wrote:

> -----Original Message-----
> From: webkit-dev-bounces at lists.webkit.org
> [mailto:webkit-dev-bounces at lists.webkit.org] On Behalf Of Maciej
> Stachowiak
> Sent: Wednesday, October 01, 2008 1:02 PM
> To: Darin Adler
> Cc: WebKit Development
> Subject: Re: [webkit-dev] Proposed Timer API
> On Oct 1, 2008, at 9:58 AM, Darin Adler wrote:
> > On Oct 1, 2008, at 9:16 AM, Mike Belshe wrote:
> >
> >> If you're going to propose a new API designed for hi-res timers, it
> >> ought to use units of microseconds instead of milliseconds.
> >
> > Or units of seconds, perhaps? Since JavaScript numbers are already
> > floating point.
> That's what I would propose. Then browsers can offer greater precision
> in the future without having to redesign the API.
> ---
> Updating now. Units of seconds. Precisision is browser defined, but will be
> higher precision (or same precision) as setInterval/setTimeout.
> _______________________________________________
> webkit-dev mailing list
> webkit-dev at lists.webkit.org
> http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.webkit.org/pipermail/webkit-dev/attachments/20081002/b3cd2b92/attachment.html 

More information about the webkit-dev mailing list