Skip to content

Commit

Permalink
Lower Suspense throttling heuristic to 300ms (facebook#26803)
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 succession, but not large enough to make the UI feel
sluggish. There's no perfect number, it's just a heuristic.
  • Loading branch information
acdlite authored and AndyPengc12 committed Apr 15, 2024
1 parent 85ceebb commit f54a3aa
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 f54a3aa

Please sign in to comment.