Skip to content

Commit

Permalink
Lower Suspense throttling heuristic to 300ms
Browse files Browse the repository at this point in the history
Now that the throttling mechanism applies more often, we've decided to
lower this a tad to ensure it's not noticeable. The idea is it should be
just large enough to prevent jank when lots of different parts of the UI
load in rapid sucesssion, but not large enough to make the UI feel
sluggish. There's no perfect number, it's just a heuristic.
  • Loading branch information
acdlite committed May 16, 2023
1 parent 4bfcd02 commit 8759469
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/react-reconciler/src/ReactFiberWorkLoop.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ let workInProgressRootRecoverableErrors: Array<CapturedValue<mixed>> | null =
// content as it streams in, to minimize jank.
// TODO: Think of a better name for this variable?
let globalMostRecentFallbackTime: number = 0;
const FALLBACK_THROTTLE_MS: number = 500;
const FALLBACK_THROTTLE_MS: number = 300;

// The absolute time for when we should start giving up on rendering
// more and prefer CPU suspense heuristics instead.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1863,8 +1863,8 @@ describe('ReactSuspenseWithNoopRenderer', () => {
// Advance by a small amount of time. For testing purposes, this is meant
// to be just under the throttling interval. It's a heurstic, though, so
// if we adjust the heuristic we might have to update this test, too.
Scheduler.unstable_advanceTime(400);
jest.advanceTimersByTime(400);
Scheduler.unstable_advanceTime(200);
jest.advanceTimersByTime(200);

// Now resolve B.
await act(async () => {
Expand Down

0 comments on commit 8759469

Please sign in to comment.