@samitouri / QOS-React-1 / commits / 13411e4589

[Re-land] Make prerendering always non-blocking: Add missing feature flag checks (#31238)

This is a partial re-land of https://github.com/facebook/react/pull/31056. We saw breakages surface after the original land and had to revert. Now that they've been fixed, let's try this again. This time we'll split up the commits to give us more control of testing and rollout internally. Original PR: https://github.com/facebook/react/pull/31056 Original Commit: https://github.com/facebook/react/pull/31056/commits/2a9fb445d98b60a97f3642cec2ff22469727e0c7 Revert PR: https://github.com/facebook/react/pull/31080 Commit description: ``` Neglected to wrap some places in the enableSiblingPrerendering flag. ``` Co-authored-by: Andrew Clark <git@andrewclark.io>

Jack Pope committed Oct 14, 2024 at 14:12 UTC 13411e4589f3d999727c5322781e2dd7bef3b256
2 files changed +21 -12
packages/react-reconciler/src/ReactFiberCompleteWork.js
+4 -1
@@ -42,6 +42,7 @@ import {
42 enableRenderableContext,
43 passChildrenWhenCloningPersistedNodes,
44 disableLegacyMode,
45 + enableSiblingPrerendering,
46 } from 'shared/ReactFeatureFlags';
47
48 import {now} from './Scheduler';
@@ -622,7 +623,9 @@ function scheduleRetryEffect(
623
624 // Track the lanes that have been scheduled for an immediate retry so that
625 // we can mark them as suspended upon committing the root.
625 - markSpawnedRetryLane(retryLane);
626 + if (enableSiblingPrerendering) {
627 + markSpawnedRetryLane(retryLane);
628 + }
629 }
630 }
631
packages/react-reconciler/src/ReactFiberLane.js
+17 -11
@@ -27,6 +27,7 @@ import {
27 transitionLaneExpirationMs,
28 retryLaneExpirationMs,
29 disableLegacyMode,
30 + enableSiblingPrerendering,
31 } from 'shared/ReactFeatureFlags';
32 import {isDevToolsPresent} from './ReactFiberDevToolsHook';
33 import {clz32} from './clz32';
@@ -270,11 +271,13 @@ export function getNextLanes(root: FiberRoot, wipLanes: Lanes): Lanes {
271 if (nonIdlePingedLanes !== NoLanes) {
272 nextLanes = getHighestPriorityLanes(nonIdlePingedLanes);
273 } else {
273 - // Nothing has been pinged. Check for lanes that need to be prewarmed.
274 - if (!rootHasPendingCommit) {
275 - const lanesToPrewarm = nonIdlePendingLanes & ~warmLanes;
276 - if (lanesToPrewarm !== NoLanes) {
277 - nextLanes = getHighestPriorityLanes(lanesToPrewarm);
274 + if (enableSiblingPrerendering) {
275 + // Nothing has been pinged. Check for lanes that need to be prewarmed.
276 + if (!rootHasPendingCommit) {
277 + const lanesToPrewarm = nonIdlePendingLanes & ~warmLanes;
278 + if (lanesToPrewarm !== NoLanes) {
279 + nextLanes = getHighestPriorityLanes(lanesToPrewarm);
280 + }
281 }
282 }
283 }
@@ -294,11 +297,13 @@ export function getNextLanes(root: FiberRoot, wipLanes: Lanes): Lanes {
297 if (pingedLanes !== NoLanes) {
298 nextLanes = getHighestPriorityLanes(pingedLanes);
299 } else {
297 - // Nothing has been pinged. Check for lanes that need to be prewarmed.
298 - if (!rootHasPendingCommit) {
299 - const lanesToPrewarm = pendingLanes & ~warmLanes;
300 - if (lanesToPrewarm !== NoLanes) {
301 - nextLanes = getHighestPriorityLanes(lanesToPrewarm);
300 + if (enableSiblingPrerendering) {
301 + // Nothing has been pinged. Check for lanes that need to be prewarmed.
302 + if (!rootHasPendingCommit) {
303 + const lanesToPrewarm = pendingLanes & ~warmLanes;
304 + if (lanesToPrewarm !== NoLanes) {
305 + nextLanes = getHighestPriorityLanes(lanesToPrewarm);
306 + }
307 }
308 }
309 }
@@ -765,7 +770,7 @@ export function markRootSuspended(
770 root.suspendedLanes |= suspendedLanes;
771 root.pingedLanes &= ~suspendedLanes;
772
768 - if (!didSkipSuspendedSiblings) {
773 + if (enableSiblingPrerendering && !didSkipSuspendedSiblings) {
774 // Mark these lanes as warm so we know there's nothing else to work on.
775 root.warmLanes |= suspendedLanes;
776 } else {
@@ -876,6 +881,7 @@ export function markRootFinished(
881 // suspended) instead of the regular mode (i.e. unwind and skip the siblings
882 // as soon as something suspends to unblock the rest of the update).
883 if (
884 + enableSiblingPrerendering &&
885 suspendedRetryLanes !== NoLanes &&
886 // Note that we only do this if there were no updates since we started
887 // rendering. This mirrors the logic in markRootUpdated — whenever we