Bug 145465

Summary: Consider throttling DOM timers in iframes outside the viewport
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: DOMAssignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: barraclough, commit-queue, esprehn+autocc, kangil.han, kling, koivisto, simon.fraser
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=98474
https://bugs.webkit.org/show_bug.cgi?id=144718
Bug Depends on: 146025    
Bug Blocks:    
Attachments:
Description Flags
Patch none

Description Chris Dumez 2015-05-29 13:16:01 PDT
Consider throttling DOM timers in iframe outside the viewport for performance and power reasons.

Radar: <rdar://problem/20768957>
Comment 1 Chris Dumez 2015-05-29 13:36:59 PDT
Created attachment 253910 [details]
Patch
Comment 2 Geoffrey Garen 2015-05-29 14:40:38 PDT
Comment on attachment 253910 [details]
Patch

What if the iframe has <audio> or is using the WebAudio API?
Comment 3 Chris Dumez 2015-05-29 15:13:13 PDT
(In reply to comment #2)
> Comment on attachment 253910 [details]
> Patch
> 
> What if the iframe has <audio> or is using the WebAudio API?

First of all, audio would only be a problem here is audio is somehow driven by timers.
I don't know if there is content doing this but it seems unlikely to me because there is no guarantee your timer will fire *when* you ask it to. It all depends on the load of the system / browser.

Also note that we already throttle timers in background pages and I use the same mechanism here for out-of-viewport iframes. So timer-driven audio would likely already be broken in the case of background pages.

If this turns out to be an issue, we could restrict the throttling to cross-origin iframes for example.
Comment 4 WebKit Commit Bot 2015-05-29 16:02:56 PDT
Comment on attachment 253910 [details]
Patch

Clearing flags on attachment: 253910

Committed r185012: <http://trac.webkit.org/changeset/185012>
Comment 5 WebKit Commit Bot 2015-05-29 16:03:04 PDT
All reviewed patches have been landed.  Closing bug.