Skip to content
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

How can microtasks run without a task? #7845

Closed
annevk opened this issue Apr 22, 2022 · 5 comments · Fixed by #9838
Closed

How can microtasks run without a task? #7845

annevk opened this issue Apr 22, 2022 · 5 comments · Fixed by #9838

Comments

@annevk
Copy link
Member

annevk commented Apr 22, 2022

I was looking at the final patch of #7768 and it struck me that it implies a microtask checkpoint can be performed when there are no tasks on the queue. However, that assumes a microtask can be enqueued without a corresponding task, right? I don't think that's something we mean to support.

Should what is now step 3 of https://html.spec.whatwg.org/#event-loop-processing-model be nested under step 2?

cc @smaug----

@smaug----
Copy link
Collaborator

Yeah, microtask's generic model is end-of-outermost script execution or end of task. So under 2 sounds reasonable.

@smaug----
Copy link
Collaborator

(Separately, I'm not quite sure step 7 follows what the browsers do. At least in Gecko 'Update the rendering' happens effectively inside a task)

@domenic
Copy link
Member

domenic commented Apr 22, 2022

However, that assumes a microtask can be enqueued without a corresponding task, right? I don't think that's something we mean to support.

I'm not sure. Basically saying that we don't support this means we don't support implementations enqueuing microtasks, unless they do so from inside a task.

I think there are at least some instances of this, e.g. all the calls to "await a stable state".

@annevk
Copy link
Member Author

annevk commented Apr 22, 2022

Hmm yeah, "await a stable state" looks like a bug, because that could interfere with the microtask queue of a currently running task, which seems bad? (This is a problem we have been trying to remove from specifications over the years, as many of them enqueued microtasks without a corresponding task.)

I guess there's a larger question as to whether the microtask queue could be owned by a task. That might avoid some of this.

@annevk
Copy link
Member Author

annevk commented Apr 25, 2022

This depends on #2882 to some extent I suppose. We could use an existing task source for "await a stable state", but that would not be particularly accurate either I think.

annevk added a commit that referenced this issue Oct 6, 2023
This further highlights the brokenness of "await a stable state". Tackling that fully is tracked by #2882.

Fixes #7845.
annevk added a commit that referenced this issue Oct 10, 2023
This further highlights the brokenness of "await a stable state". Tackling that fully is tracked by #2882.

Fixes #7845.
mfreed7 pushed a commit to mfreed7/html that referenced this issue Oct 11, 2023
This further highlights the brokenness of "await a stable state". Tackling that fully is tracked by whatwg#2882.

Fixes whatwg#7845.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

3 participants