Skip to content

Commit 13411e4

Browse files
jackpopeacdlite
andauthored
[Re-land] Make prerendering always non-blocking: Add missing feature flag checks (#31238)
This is a partial re-land of #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: #31056 Original Commit: 2a9fb44 Revert PR: #31080 Commit description: ``` Neglected to wrap some places in the enableSiblingPrerendering flag. ``` Co-authored-by: Andrew Clark <[email protected]>
1 parent 6cf8518 commit 13411e4

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

packages/react-reconciler/src/ReactFiberCompleteWork.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import {
4242
enableRenderableContext,
4343
passChildrenWhenCloningPersistedNodes,
4444
disableLegacyMode,
45+
enableSiblingPrerendering,
4546
} from 'shared/ReactFeatureFlags';
4647

4748
import {now} from './Scheduler';
@@ -622,7 +623,9 @@ function scheduleRetryEffect(
622623

623624
// Track the lanes that have been scheduled for an immediate retry so that
624625
// we can mark them as suspended upon committing the root.
625-
markSpawnedRetryLane(retryLane);
626+
if (enableSiblingPrerendering) {
627+
markSpawnedRetryLane(retryLane);
628+
}
626629
}
627630
}
628631

packages/react-reconciler/src/ReactFiberLane.js

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
transitionLaneExpirationMs,
2828
retryLaneExpirationMs,
2929
disableLegacyMode,
30+
enableSiblingPrerendering,
3031
} from 'shared/ReactFeatureFlags';
3132
import {isDevToolsPresent} from './ReactFiberDevToolsHook';
3233
import {clz32} from './clz32';
@@ -270,11 +271,13 @@ export function getNextLanes(root: FiberRoot, wipLanes: Lanes): Lanes {
270271
if (nonIdlePingedLanes !== NoLanes) {
271272
nextLanes = getHighestPriorityLanes(nonIdlePingedLanes);
272273
} 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+
}
278281
}
279282
}
280283
}
@@ -294,11 +297,13 @@ export function getNextLanes(root: FiberRoot, wipLanes: Lanes): Lanes {
294297
if (pingedLanes !== NoLanes) {
295298
nextLanes = getHighestPriorityLanes(pingedLanes);
296299
} 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+
}
302307
}
303308
}
304309
}
@@ -765,7 +770,7 @@ export function markRootSuspended(
765770
root.suspendedLanes |= suspendedLanes;
766771
root.pingedLanes &= ~suspendedLanes;
767772

768-
if (!didSkipSuspendedSiblings) {
773+
if (enableSiblingPrerendering && !didSkipSuspendedSiblings) {
769774
// Mark these lanes as warm so we know there's nothing else to work on.
770775
root.warmLanes |= suspendedLanes;
771776
} else {
@@ -876,6 +881,7 @@ export function markRootFinished(
876881
// suspended) instead of the regular mode (i.e. unwind and skip the siblings
877882
// as soon as something suspends to unblock the rest of the update).
878883
if (
884+
enableSiblingPrerendering &&
879885
suspendedRetryLanes !== NoLanes &&
880886
// Note that we only do this if there were no updates since we started
881887
// rendering. This mirrors the logic in markRootUpdated — whenever we

0 commit comments

Comments
 (0)