w3c / requestidlecallback

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

Rely on HTML spec for deadline computation #95

Closed noamr closed 2 years ago

noamr commented 2 years ago

In conjunction with https://github.com/whatwg/html/pull/7166

Instead of defining the idle period deadline in prose, rely on the event model processing in the HTML spec to provide a more precise computation of the current idle period deadline.

This is accomplished by passing a getDeadline algorithm from the HTML spec to this spec when starting an idle period, and re-computing that deadline between idle callbacks, or when timeRemaining() is called.

This ensures (more formally) that adding timeouts that expire before the end of the idle period, or requestAnimationFrame calls from within the idle period, which currently are specified to fire before the next idle tasks due to event loop priorities, will also be reflected when calling timeRemaining.

Closes #71


Preview | Diff

noamr commented 2 years ago

I only gave this a "respec review", as I'm not very familiar with requestidlecallback... however, if you want a proper review, I can dive a little deeper in requestidlecallback.

Not necessary, we will discuss it in TPAC and people more familiar with it can review together with the corresponding HTML-spec changes. Thanks for the editorial review!

noamr commented 2 years ago

@yoavweiss I think this is ready for an actual review, now that the corresponding HTML PR has landed.

noamr commented 2 years ago

@marcoscaceres any changes still requested?

marcoscaceres commented 2 years ago

No, apologies for the delay.