w3c / requestidlecallback

Cooperative Scheduling of Background Tasks
https://w3c.github.io/requestidlecallback/
Other
50 stars 19 forks source link

associate rIC callbacks with Window #38

Closed igrigorik closed 8 years ago

igrigorik commented 8 years ago

Took another run at it. Not 100% clear if I'm heading in the right direction though...

Preview: https://cdn.rawgit.com/w3c/requestidlecallback/window/index.html

Thoughts / comments?

domenic commented 8 years ago

If you move the runnable queue you'll probably want to clear it on every navigation. Otherwise enqueued idle callbacks will run even after the page that enqueued them has been navigated away from.

igrigorik commented 8 years ago

On a second pass, I think I'm over complicating this.. I'll tackle #29 as a separate issue.

@domenic @rmcilroy I've updated the pull to focus on document -> window fix. Please take another look, I think it should be ready to go.

rmcilroy commented 8 years ago

LGTM, thanks!

igrigorik commented 8 years ago

Great! @domenic any comments or objections before I merge this?

igrigorik commented 8 years ago

@bzbarsky @domenic thanks for the corrections, looks like I thoroughly confused myself there. Updated, please take another pass.

domenic commented 8 years ago

Looks good with an editorial concern.

domenic commented 8 years ago

Just as a sanity check: I assume this is actually implemented in Chrome via a map stored on the window object? Not, e.g., stored on the event loop or similar?

bzbarsky commented 8 years ago

Yes, that looks much better.

rmcilroy commented 8 years ago

Re Domanic's comment - on Chrome it is stored in a HashMap which lives (via a ScriptedIdleTaskController, then a Document object) on a LocalDOMWindow object.

igrigorik commented 8 years ago

Thanks everyone. Updated, squashed, merging.