w3c / w3c/long-animation-frames
[LoAF] Should be a way to switch script "Entry Point" without yielding.
Nobody has claimed this yet.
- Dominant language
- Bikeshed
- Stars
- 23
- Forks
- 5
- Avg merge
- 10h 16m
- Merged PRs (30d)
- 1
Description
This is related to w3c/long-animation-frames#3, but enough different that I wanted to fork.
Rather than asking for arbitrary annotations, I think it would be worthwhile to just have a mechanism for explicitly switching script "entry points" -- and let LoAF work as normal beyond that -- but without needing to turn to macrotask scheduling.
For example, perhaps queueMicrotask could be seen as an explicit scheduling call, and could have a distinct Entry Point. That is just a strawman idea.
I just tried a few experiments locally. At a high level, what we would like is for a script to be able to move some continuation into a new "loaf entrypoint", such that loaf can "switch script attribution" to it.
The easiest working example is to just setTimeout(callback, 0) or scheduler.postTask(callback) (provided that callback was actually created by the script you want to change attribution to). But this requires a macrotask hop with FIFO scheduling, which may not be desirable.
I also tried to use scheduler.yield() which has LIFO scheduling, but it did not work as expected:
scheduler.yield().then(callback);
I would have expected that to be a "resolve-promise" entrypoint. I wonder if this is just a bug in LoAF, or expected? (also, while the sourceLocation didn't change scripts, the character offset is 0, so something is funky)
I also tried to find some hacky existing mechanism to switch entry points but stay within the same macrotask. I tried to create EventTarget or <button> and then use addEventListener + dispatchEvent, or various Observers etc, but none of those worked.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the LoAF entry-point and script-attribution behavior described here, along with the linked w3c/long-animation-frames#3 discussion. Compare queueMicrotask, scheduler.yield(), setTimeout, scheduler.postTask, and event-dispatch experiments; done requires an agreed mechanism for switching attribution without a macrotask hop and clarified scheduler.yield() behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- performance
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100