-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Add self.queueMicrotask() #2789
Conversation
1e48bc3
to
e15f47c
Compare
@@ -89383,7 +89394,7 @@ dictionary <dfn>PromiseRejectionEventInit</dfn> : <span>EventInit</span> { | |||
<p>To affect the world of observable JavaScript objects, then, you must <span>queue a task</span> | |||
to perform any such manipulations. This ensures your steps are properly interleaved with respect | |||
to other things happening on the <span>event loop</span>. Furthermore, you must choose a | |||
<span>task source</span> when <span data-x="queue a task">queueing a task</span>; this governs the | |||
<span>task source</span> when <span data-x="queue a task">queuing a task</span>; this governs the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both are correct so we should add this to the Style Guide.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -90402,6 +90413,9 @@ interface mixin <dfn>WindowOrWorkerGlobalScope</dfn> { | |||
long <span data-x="dom-setInterval">setInterval</span>(<span>TimerHandler</span> handler, optional long timeout = 0, any... arguments); | |||
void <span data-x="dom-clearInterval">clearInterval</span>(optional long handle = 0); | |||
|
|||
// microtask queuing | |||
void <span data-x="dom-queueMicrotask">queueMicrotask</span>(<span data-x="idl-Function">Function</span> <var>callback</var>); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't see a reason why they wouldn't have this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to explore that separately, if so. There is no shared mixin right now so doing so is not straightforward. And from what I understand not all worklets have event loops?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They all have an event loop I believe. They just don't queue new tasks, but that doesn't matter here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But also, wouldn't that mean we'd add a new mixin that encompasses all? Or would we solve it differently?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I don't know what the right solution is. I'd like to work on such an expansion in collaboration with the worklets editors, as a new feature, instead of holding up this (implementer consensus/tests ready/spec ready) feature on figuring out the details.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I'm okay with that, provided there's a follow-up issue. I do think it'll result in this method being moved to a new mixin, but so be it.
<h3>Microtask queuing</h3> | ||
|
||
<p>The <code data-x="dom-queueMicrotask">queueMicrotask()</code> method allows authors to schedule | ||
a callback on the <span>microtask queue</span>. This allows their code to run after the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically it's at the end of the task, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd call step 6 "after" step 3 in https://html.spec.whatwg.org/#event-loop-processing-model
source
Outdated
browser's <span>event loop</span>, as would be the case when using, for example, <code | ||
data-x="dom-setTimeout">setTimeout(<var>f</var>, 0)</code>.</p> | ||
|
||
<p>Authors should be aware that scheduling a lot of microtasks has the same performance downsides |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should -> ought to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
e15f47c
to
f2b6ae3
Compare
(This also still needs implementation bugs.) |
…stonly Automatic update from web-platform-testsAdd tests for self.queueMicrotask() Follows whatwg/html#2789. -- wpt-commits: 0c3bed38df6d9dcd1441873728fb5c1bb59c92df wpt-pr: 6334
…stonly Automatic update from web-platform-testsAdd tests for self.queueMicrotask() Follows whatwg/html#2789. -- wpt-commits: 0c3bed38df6d9dcd1441873728fb5c1bb59c92df wpt-pr: 6334
…stonly Automatic update from web-platform-testsAdd tests for self.queueMicrotask() Follows whatwg/html#2789. -- wpt-commits: 0c3bed38df6d9dcd1441873728fb5c1bb59c92df wpt-pr: 6334 UltraBlame original commit: 141be436c496b0715eac4f3a7c0c6a0c25392a59
…stonly Automatic update from web-platform-testsAdd tests for self.queueMicrotask() Follows whatwg/html#2789. -- wpt-commits: 0c3bed38df6d9dcd1441873728fb5c1bb59c92df wpt-pr: 6334 UltraBlame original commit: 141be436c496b0715eac4f3a7c0c6a0c25392a59
…stonly Automatic update from web-platform-testsAdd tests for self.queueMicrotask() Follows whatwg/html#2789. -- wpt-commits: 0c3bed38df6d9dcd1441873728fb5c1bb59c92df wpt-pr: 6334 UltraBlame original commit: 141be436c496b0715eac4f3a7c0c6a0c25392a59
Closes #512.
Tests: web-platform-tests/wpt#6334
Chrome is tentatively interested in implementing this, so I'm getting a spec and tests up for review. The actual spec is a one-liner that does what you expect, but I tried to capture some of the discussions from #512 about when this is and isn't appropriate.
Let's continue using #512 for discussion on the merits of this feature, instead of forking the discussion into this PR.
/comms.html ( diff )
/imagebitmap-and-animations.html ( diff )
/index.html ( diff )
/infrastructure.html ( diff )
/references.html ( diff )
/system-state.html ( diff )
/timers-and-user-prompts.html ( diff )
/webappapis.html ( diff )