main-thread-scheduling
main-thread-scheduling copied to clipboard
Add more priorities
Currently, I have added only two priorities to the library — background
and user-visible
. I feel this won't be enough. However, I can't imagine all the use cases the library will be used in. This is why I am starting a discussion here, so together, we can find the right priorities.
Wild idea, but would is be possible to do something like extend the delay adaptively? RIC does this but it's often too fast.
I've used algorithms that are able to calculate current CPU pressure. I mainly do this so I can block third party tags by monkey patching document.createElement. Then based of CPU pressure I can suspend the unblock rates till CPU isn't under so much stress.
Another one that might be interesting to consider is suspending when the user interacts with the page, scrolling or clicking around - tho some of this might be covered by by requestAnimationFrame
Wild idea, but would is be possible to do something like extend the delay adaptively?
I like the idea. Maybe I can use it as a fallback when navigator.scheduling.isInputPending()
isn't available. Do you have examples of a code that tries to do that? I will be interested in learning from it.
Another one that might be interesting to consider is suspending when the user interacts with the page, scrolling or clicking around - tho some of this might be covered by requestAnimationFrame
This is covered by navigator.scheduling.isInputPending()
when available. When not available the library is a lot more conservative to do work without giving back control to userland.