w3c / requestidlecallback

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

Improve the specification of how requestIdleCallback events are ordered #41

Closed toddreifsteck closed 7 years ago

toddreifsteck commented 8 years ago

@plehegar @digitec and myself reviewed this in Redmond last week.

One issue we observed was that it wasn't instantly obvious the exact scheduling order for callbacks.

We came up with 2 options from reading the spec, but had to reread a couple of times. Is a the correct summary? a. OUR BELIEF-- A callback with a timeout is injected into a queue AND into a timeout system similar to the one used for setTimeout. The first one to execute will cause the other one not to execute when it is scheduled. b. ANOTHER OPTION THAT COULD BE POSSIBLE-- If a callback has a timeout, it is queued ahead of callbacks without timeouts. (The timeout is used as an "importance" hint.)

It may be possible to improve the spec to make this clearer on first read, but I need to read it again to give a specific suggestion.

rmcilroy commented 8 years ago

The intention (and implementation in Chrome) is option A - the callback is queued on both a rIC queue and a setTineout queue and whichever is run first cancels the other one.

Happy to take suggestions on which part of the spec could be improved to make this more obvious.

igrigorik commented 7 years ago

@toddreifsteck re-reading the steps a few times on this end.. I think my best suggestion would be to add a non-normative note between steps 5 and 6 clarifying the intent (option A). Something like:

The following steps run in parallel and queue a timer similar to setTimeout. When the timeout is specified, the first callback to execute cancels the other - e.g. if the callback is scheduled into an idle block before the timeout fires, then the timeout callback is cancelled, and vice versa.

WDYT?