Intent to Prototype: scheduler.yield()

505 views
Skip to first unread message

Scott Haseley

unread,
Oct 28, 2022, 5:57:26 PM10/28/22
to blink-dev

Contact emails

shas...@chromium.org

Explainer

https://github.com/WICG/scheduling-apis/blob/main/explainers/yield-and-continuation.md

Specification



Summary

Provides a method for yielding control to the browser, which can be used to break up long tasks. Awaiting the promise returned by scheduler.yield() causes the current task to yield, continuing in a new browser task. This can be used to improve responsiveness issues caused by long tasks. Continuations are prioritized to mitigate performance problems of existing alternatives.



Blink component

Blink>Scheduling>APIs

Motivation

Long tasks (JavaScript) can lead to poor responsiveness by blocking the main thread from handling inputs or delaying the resulting UI update. Developers can mitigate this by decreasing task lengths, either by doing less work or by breaking up long tasks. Scheduling a continuation using current APIs typically has poor ergonomics because intuitively one wants to pause/resume the current task, not schedule a new task. It can also incur a performance penalty if arbitrary JavaScript runs between yield and continuation. scheduler.yield() is an ergonomic API for breaking up long tasks that mitigates performance issues of existing methods. Developers can await scheduler.yield() to break up long tasks, giving the UA an opportunity to run higher priority work, e.g. input. scheduler.yield() continuations are prioritized over tasks of the same priority or similar task sources, which helps mitigate the performance penalty of yielding.



Initial public proposal



TAG review



TAG review status

Pending

Risks



Interoperability and Compatibility



Gecko: No signal

WebKit: No signal

Web developers: No signals

Other signals:

WebView application risks

Does this intent deprecate or change behavior of existing APIs, such that it has potentially high risk for Android WebView-based applications?



Debuggability



Is this feature fully tested by web-platform-tests?

No

Flag name



Requires code in //chrome?

False

Tracking bug

https://bugs.chromium.org/p/chromium/issues/detail?id=979020

Estimated milestones

No milestones specified



Link to entry on the Chrome Platform Status

https://chromestatus.com/feature/6266249336586240

This intent message was generated by Chrome Platform Status.

Rick Byers

unread,
Nov 4, 2022, 11:49:53 AM11/4/22
to Scott Haseley, blink-dev
Thanks Scott! I'm excited to see this moving forward and hopeful that providing more modern scheduling primitives to sophisticated websites and frameworks will help some of them create a more consistently good user experience. 

Rick

--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CAKXGoJ1SBQP-ABM3%2BsDtKzUZiPoSCWqW2mLOjMrUfFBx4TomSw%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages