Skip to content

Commit

Permalink
[scheduler] Yield many times per frame, no rAF (#16214)
Browse files Browse the repository at this point in the history
Adds experimental flag to yield many times per frame using a message
event loop, instead of the current approach of guessing the next vsync
and yielding at the end of the frame.

This new approach forgoes a `requestAnimationFrame` entirely. It posts a
message event and performs a small amount of work (5ms) before yielding
to the browser, regardless of where it might be in the vsync cycle. At
the end of the event, if there's work left over, it posts another
message event.

This should keep the main thread responsive even for really high frame
rates. It also shouldn't matter if the hardware frame rate changes after
page load (our current heuristic only detects if the frame rate
increases, not decreases).

The main risk is that yielding more often will exacerbate main thread
contention with other browser tasks.

Let's try it and see.
  • Loading branch information
acdlite committed Jul 26, 2019
1 parent 0d7141d commit 75ab53b
Show file tree
Hide file tree
Showing 5 changed files with 538 additions and 414 deletions.
1 change: 1 addition & 0 deletions packages/scheduler/src/SchedulerFeatureFlags.js
Expand Up @@ -10,3 +10,4 @@ export const enableSchedulerDebugging = false;
export const enableIsInputPending = false;
export const requestIdleCallbackBeforeFirstFrame = false;
export const requestTimerEventBeforeFirstFrame = false;
export const enableMessageLoopImplementation = false;

0 comments on commit 75ab53b

Please sign in to comment.