@samitouri / QOS-React / commits / f8de255e94

Lower Suspense throttling heuristic to 300ms (#26803)

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.

Andrew Clark committed May 16, 2023 at 15:59 UTC f8de255e94540f9018d8196b3a34da500707c39b
2 files changed +3 -3
packages/react-reconciler/src/ReactFiberWorkLoop.js
+1 -1
@@ -375,7 +375,7 @@ let workInProgressRootRecoverableErrors: Array<CapturedValue<mixed>> | null =
375 // content as it streams in, to minimize jank.
376 // TODO: Think of a better name for this variable?
377 let globalMostRecentFallbackTime: number = 0;
378 -const FALLBACK_THROTTLE_MS: number = 500;
378 +const FALLBACK_THROTTLE_MS: number = 300;
379
380 // The absolute time for when we should start giving up on rendering
381 // more and prefer CPU suspense heuristics instead.
packages/react-reconciler/src/__tests__/ReactSuspenseWithNoopRenderer-test.js
+2 -2
@@ -1863,8 +1863,8 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1863 // Advance by a small amount of time. For testing purposes, this is meant
1864 // to be just under the throttling interval. It's a heurstic, though, so
1865 // if we adjust the heuristic we might have to update this test, too.
1866 - Scheduler.unstable_advanceTime(400);
1867 - jest.advanceTimersByTime(400);
1866 + Scheduler.unstable_advanceTime(200);
1867 + jest.advanceTimersByTime(200);
1868
1869 // Now resolve B.
1870 await act(async () => {