-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing definition for "idle time" #70
Comments
@rmcilroy @domenic any thoughts on this one? We provide a non-normative explainer in https://w3c.github.io/requestidlecallback/#idle-periods. Is there a more formal definition that we could draft here? |
Could this be defined in terms of https://html.spec.whatwg.org/multipage/webappapis.html#event-loop-processing-model ? Something like:
We'd need to do some surgery to make this clean and not refer to steps by number, but that would be my first draft. |
TPAC 2017: |
Yes, I like @domenic's definition above, that sound about right. It would definitely be simpler if we could add an explicit entry into the HTML5 Event Loop after step 7 to hook into. Would someone be willing to add this hook? |
I can try to work on it, but if someone else has more time, that'd be ideal. I think the trickiest thing is writing the prose to keep track of all the things before and after step 7, so that the new step can confidently say "I am idle". |
I'll put up a patch today. However, I'm unsure how exactly to integrate. Right now the idling seems a bit implicit in "start an idle period": requestIdleCallback queues a task, that waits for the event loop to become idle (by spinning it until it's empty), and then queues another task to invoke callbacks. Probably the simplest integration would be if, when the HTML spec noticed it was idle, it called a single algorithm from this spec. Then you wouldn't do any spinning here. But I don't know what a good candidate for that algorithm would be now. Maybe something like "start an idle period" step 5 onward? Although I think it's weird that step 13 queues a task; we're already on the event loop, so that shouldn't be necessarily, unless you want to add opportunities for the UA to run other tasks that might have accumulated during step 5. |
This only slightly changes the processing model of requestIdleCallback, by explicitly ensuring that notifying about promise rejections or cleaning up IndexedDB transactions counts as being non-idle. Mostly, it makes it clearer what exactly is idle time (per the request at w3c/requestidlecallback#70), and it calls directly out to the "start an idle period" algorithm, instead of that algorithm needing to spin the event loop.
It tells you whether any cleanup work was performed or not. This helps with w3c/requestidlecallback#70 and whatwg/html#3570.
Thanks for looking into this @domenic! I think integrating into step 5 onwards would be the best bet. The main reason to queue another task in step 13 is for the following:
Happy to refactor if you see cleaner ways of meeting these goals though. [1] Taken from https://w3c.github.io/requestidlecallback/#idle-periods function doWork(deadline) {
if (deadline.timeRemaining() <= 5) {
// This will take more than 5ms so wait until we
// get called back with a long enough deadline.
requestIdleCallback(doWork);
return;
}
// do work...
} |
It tells you whether any cleanup work was performed or not. This helps with w3c/requestidlecallback#70 and whatwg/html#3570.
Not that I'm aware of. If someone were able to drive this to completion that would be great. |
Makes the "start an idle period" algorithm callable by the HTML event loop processing model, instead of having this spec spin the event loop. Addresses w3c#70
Makes the "start an idle period" algorithm callable by the HTML event loop processing model, instead of having this spec spin the event loop. Addresses w3c#70
This adds a hook to the event loop's processing model to define when the start of an idle period should begin. This deals with the issue in w3c/requestidlecallback#70 and calls directly into the "start an idle period" algorithm, instead of that algorithm having to having to spin the event loop. This change depends on the PR in w3c/requestidlecallback#75.
This adds a hook to the event loop's processing model to define when the start of an idle period should begin. This deals with the issue in w3c/requestidlecallback#70 and calls directly into the "start an idle period" algorithm, instead of that algorithm having to having to spin the event loop. This change depends on the PR in w3c/requestidlecallback#75.
I've uploaded #75 and whatwg/html#4104 which I think should be sufficient to hook rIC into the HTML spec. @domenic I've gone with a slightly different approach in the event model processing which I think is simpler - in essence instead of working out if we did an idle spin of the loop, instead work out if the next spin of the loop looks to be idle. PTAL, thanks. |
This adds a hook to the event loop's processing model to define when the start of an idle period should begin. This deals with the issue in w3c/requestidlecallback#70 and calls directly into the "start an idle period" algorithm, instead of that algorithm having to having to spin the event loop. Follows w3c/requestidlecallback#75. Closes #3570 by superceding it; this simpler version avoids needing to track notifying above rejected promises or cleaning up IDB transactions.
Should now be addressed, thanks all. |
This adds a hook to the event loop's processing model to define when the start of an idle period should begin. This deals with the issue in w3c/requestidlecallback#70 and calls directly into the "start an idle period" algorithm, instead of that algorithm having to having to spin the event loop. Follows w3c/requestidlecallback#75. Closes whatwg#3570 by superceding it; this simpler version avoids needing to track notifying above rejected promises or cleaning up IDB transactions.
This adds a hook to the event loop's processing model to define when the start of an idle period should begin. This deals with the issue in w3c/requestidlecallback#70 and calls directly into the "start an idle period" algorithm, instead of that algorithm having to having to spin the event loop. Follows w3c/requestidlecallback#75. Closes whatwg#3570 by superceding it; this simpler version avoids needing to track notifying above rejected promises or cleaning up IDB transactions.
It tells you whether any cleanup work was performed or not. This helps with w3c/requestidlecallback#70 and whatwg/html#3570.
pass on an AC Review comment:
... from @dwsinger
The text was updated successfully, but these errors were encountered: