[webkit-dev] setTimeout as browser speed throttle

Rob Burns robburns1 at mac.com
Fri Oct 3 10:43:25 PDT 2008


Hi Peter,

On Oct 3, 2008, at 4:08 PM, Peter Speck wrote:

> On 03/10/2008, at 14:16, Maciej Stachowiak wrote:
>
>>> [...] Other sites update their title on a timer in a way that is
>>> useful for a background tab. For example, GMail updates the unread
>>> count, which is quite useful on a background tab label. [...]
>
> Maybe the new Timer API should be extended with an option for:  should
> this timer be executed when the page is hidden in a background tab.
>

I think that's a great suggestion.

>
> Animation timers would then specify no, thereby reducing amount of  
> cpu/
> battery consumed.
>
> GMail could specify yes: low-overhead update of the unread count in
> background.

Looking forward, HTML5's 'event' element would be a better approach  
than using setTimeout, but obviously setTimeout would be needed for  
legacy support. I think we should be striving for a set of APIs and  
other standards that avoid this misuse of setTimeout for polling. If  
we have well-supported and well-designed standards (such as the  
'event' element, though it isn't really fleshed out yet) I think it  
becomes difficult to come up with examples that would need a  
background timer at all: though I'm all for providing it for edge  
cases. The only examples I can come up with are those web apps  
incorrectly using timers to resort to background polling (like gmail).

> It would make sense to have the default to be false, and to be the
> last parameter.

Sounds good to me.

Take care,
Rob


More information about the webkit-dev mailing list