-
Notifications
You must be signed in to change notification settings - Fork 56
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
scheduler.postTask() API #338
Comments
After a first read-through, this seems like useful stuff. Some of this (particularly the comment in the explainer about misuse of
|
The link to the filled-out Self-Review Questionnare on Security and Privacy doesn't seem to resolve. Can someone post it here? |
Taken up during the Tokyo F2F. @hober @travisleithead @kenchris @dbaron @cynthia discussed this at length. Interesting problem! Thanks for bringing this to our attention. This is absolutely worth exploring. That said, we do have concerns about the limited audience that will immediately benefit from this. Additionally, we are a bit curious what is supposed to go on this task queue, and how are they expected to behave. We think a solution in this space will need to account for how legacy scheduling APIs interact as not all authors will be expected to switch to the new model for scheduling (as long as the old model is still around). We'd love to see this advance further, and would like to see some strawman proposals when you have any. |
Would love to hear your ideas.
the builtin API certainly aims to make this better with "semantic priority", however we have to really pick appropriate names here (work-in-progress): |
This is not a specification yet and there will be separate specifications and TAG requests for each API.
Could you elaborate on the concern of limited audience, why do you think it is limited?
I will link the explainer for this proposal when ready (soon!). |
We've made some progress on the API shape here, and are moving ahead with two APIs—scheduler.postTask() and scheduler.yield(). They are closely related (both part of window.scheduler, and tied together by priority), but are useful on their own and can ship independently. The explainer has been updated: We also have a design doc which covers both APIs. |
The proposal assumes that everything at a given priority is in fact linearized into a single FIFO queue, and that the set of priorities is the fixed one in the proposal. This is at odds with the way the HTML spec defines independent unordered task sources and with browser ability to reorder those wrt each other, as far as I can tell. |
@bzbarsky Thanks for raising this concern. Integrating the proposed prioritized task queues with the existing unprioritized task queues is certainly a challenge and is an open question at this point. It is not our goal to remove the ability for UAs to reorder independent task sources, but there is an open question around how prioritized task queues should fit in. There are a few questions to consider here:
We’d be happy to hear any further thoughts you have on this. |
It feels like the main use case given in the overview for the prioritized post task API is about coordination within a single site -- although this does include third party context in nested browsing contexts. I agree with @bzbarsky that it's valuable to allow browser flexibility to schedule differently across third-party boundaries; such boundaries are quite opaque to begin with and it feels like heavily constraining the relative priorities between origins could interfere with useful things that browsers could do to help users. Whereas within a single site, where there's already much closer interaction, it feels more like there's value in having things clearly-specified -- as the HTML spec currently does, since there's only a single task source. So specifying these priorities as being something meaningful within a single task source, but not across task sources, feels like a good approach to me. And given the comments in the explainer it sounds like this is the approach currently being taken. |
Generally, I think it is great to see work done in this area, but I am also a bit worried that this will make the average developer's life more complicated. Especially, it might be hard to understand what priority to use (high, low, default) so it is important that frameworks and libraries don't force people to make that decision when not needed. Also, today people use a ton of libraries and all of these might use this API internally and set their own prioritization that might conflict with what I am trying to do. So it needs to be very easy to see what a library is doing and change the priority. If every library ends up creating their own APIs for doing so, it might turn into a mess. I also find the name "immediate" confusing as it doesn't run immediately, as it runs after microtasks. Should it be possible to access something like the micro task queue using this API? |
Next steps:
|
@dbaron There is not a single task source for a single "site". There are a bunch of different task sources, which per HTML spec are unordered with each other. For example, My comments were explicitly about the single-site situation, not the different-site situation; in the different-site case there are no observable ordering guarantees between the two sites apart from ordering within communication channels like |
Ah, ok -- I'm curious how much flexibility browsers really have for some of these things -- it feels like some of that might be pretty constrained by web compatibility. |
Hi folks, an update on the postTask API proposal:
|
Hi there What are your current priorities? postTask? Where can be we (TAG) most helpful. Maybe it makes sense to have separate issues for each of these APIs so that we better know what to focus on and better can track the progress? |
Also worth noting that #415 has some discussion that's probably relevant to |
Yes, postTask is our current priority, and a TAG review of postTask would be most helpful.
Sorry for the confusion, yes separate issues sounds like the right approach. Should we repurpose this for postTask, or file a new issue? Much of the content of this thread is already related to postTask. |
What happens in this case? const controller = new TaskController('user-blocking');
scheduler.postTask(doWork, { signal, priority: 'background' }); |
A use case we had in mind is if devs want to post independent low priority subtasks that should still be canceled with the parent task. One example of this might be logging or cleanup tasks. Note: I'm working on a separate explainer/issue to explore implementing TaskSignal this way (as an extension of AbortSignal) vs. having/supporting separable signals (e.g. PrioritySignal), and potentially making TaskSignal a composite. Where I think things get complicated is if/when more signals get added to the platform and how they interact with the various APIs. I'm planning to loop TAG folks and others in on that as well once it's written. |
But what priority is it going to get? |
Oh sorry, 'background'. |
So priority wins over the priority from the TaskController. But I assume that if I change the priority of the TaskController then that wins? Could you add that example and explanation? |
Yes, the priority option acts as an override and wins over the priority from the signal, but the priority remains fixed at that priority, meaning controller.setPriority() won't change the priority for that task. In this example, that means the priority of that task will always be background. The invariant here is that specifying a fixed priority, whether or not a signal is provided, will cause that task to always remain at that priority. That's what I meant by the signal is downcast to an This is mentioned in the design doc, but looks like it didn't make it into the explainer; I'll add this information and an example. There are other options here, e.g. ignoring the priority option, throwing an error. The current approach seemed to enable additional use cases which is why we selected it, but we're open to suggestions/feedback. |
Clarification looks good but I found a nit Should be |
I think we're pretty happy with the direction this proposal is taking, so we propose to close this for now. If there is a formal spec that needs to be reviewed later on, we'd be happy to revisit this. |
こんにちはTAG!
I'm requesting a TAG review of:
Further details (optional):
You should also know that...
This is a very early proposal and we are seeking broad feedback.
We'd prefer the TAG provide feedback as (please select one):
The text was updated successfully, but these errors were encountered: