[Webkit-unassigned] [Bug 164193] Implement requestIdleCallback

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Mar 14 09:05:15 PDT 2023


https://bugs.webkit.org/show_bug.cgi?id=164193

--- Comment #12 from Michael Catanzaro <mcatanzaro at gnome.org> ---
So assuming we add idle-priority execution to RunLoop, then the cross-platform implementation would be:

 * If no timeout is specified, attach a RunLoop task at idle priority
 * If a timeout is specified, then attach two RunLoop tasks: one at idle priority and one using Timer.startOneShot(). Whichever task executes first should cancel the other.

That would be needed in DOMWindow, where Ms2ger's patch provides us with empty stubs.

All this assumes that "run task at idle priority" is actually a valid way to decide when the browser is idle, but I think it probably is. The browser might be doing more stuff on secondary threads, but the main thread is definitely idle. Only problem could be if a secondary thread is doing something that will imminently cause a task to post to the main thread. WebKit developers might know that something important might be about to happen, but the RunLoop isn't smart enough to avoid this. So perhaps we might theoretically want to have "blackout" times when idle callbacks are not dispatched. But that adds extra complexity and I don't know when those times would be, so this is probably not part of the minimal viable solution.

(Honestly, the minimal viable solution would be to implement it equivalent to setTimeout(0), but it's not hard to do better.)

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20230314/9c3a4ebe/attachment.htm>


More information about the webkit-unassigned mailing list