Closed Bug 930520 Opened 11 years ago Closed 6 years ago

Offer a promise helping execute tasks on the main thread without causing UI jank

Categories

(Toolkit :: Async Tooling, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: florian, Unassigned)

References

(Depends on 1 open bug, Blocks 1 open bug)

Details

(Whiteboard: [fxperf])

When using Task.js to write JS code executing in chunks on the main thread, it would be useful to have a way to obtain a promise that would resolve immediately only if it's possible to do more work without visibly blocking the UI. This likely depends on bug 930517 as it's (AFAIK) currently impossible for JS code to know how much time was spent outside of the event loop. It may be possible to keep executing code for more than 15ms if the event queue is currently empty; not sure if there's an easy way to know that. If several different and independent pieces of JS code use this mechanism at the same time to do work in chunks, we will likely want to balance the time given to each of the tasks, to ensure we don't block other tasks until the first one is completed. Letting tasks specify a priority for the work they are performing may also be useful (eg. we may want to give more time to something that's user visible, and less time to something that's working in the background).
PerformanceStats.jsm, which has recently landed, should now provide all the data necessary to find out the current load of the system.
Whiteboard: [fxperf]
I wonder if requestIdleCallback sufficient for what florian had in mind here? rIC passes a deadline to its callback which allows callers to break their work up without, presumably, blocking the event loop for a problematic amount of time. I can't needinfo? florian until he's back, so I guess we'll leave this in the queue until he comes back.
(In reply to Mike Conley (:mconley) (:⚙️) (Catching up on needinfos / reviews) from comment #2) > I wonder if requestIdleCallback sufficient for what florian had in mind > here? rIC passes a deadline to its callback which allows callers to break > their work up without, presumably, blocking the event loop for a problematic > amount of time. Yes, that's enough. This bug was opened a long time ago ;-).
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.