[webkit-dev] setTimeout as browser speed throttle

Maciej Stachowiak mjs at apple.com
Tue Sep 30 15:13:23 PDT 2008


On Sep 30, 2008, at 12:58 PM, Geoffrey Garen wrote:

>> Or there is option 3:
>>
>> 3) Restore the clamp for setTimeout and setInterval to 10ms for  
>> compatibility, and add a new setHighResTimer API that does not have  
>> any lower bound.
>
> I'd like to tweak this suggestion a bit:
>
> Let's make this new timer API object-oriented, so it can be both  
> less slow and less crazy than setTimeout / setInterval. There are  
> many "Timer" APIs in open source JavaScript libraries on which we  
> could base a new API.
>
> Perhaps a Timer object would always be high resolution, or perhaps  
> it would have an "isHighResolution" bit.

Yes, I was imagining something that would return a Timer object rather  
than an integer:

Timer createTimer(double timeInSeconds, repeating, TimerCallback);

(timeInSeconds could have microsend or even nanosecond precision;  
using floating point makes the feasible precision floor very low)

interface Timer {
     stop();
}

Open question whether Timer should have pause/resume, the ability to  
introspect time timeout and time remaining, or ability to change the  
timing parameters.

Your suggestion of looking at JS library APIs is a good one.

Regards,
Maciej



More information about the webkit-dev mailing list