Skip to content

Commit 76aee6f

Browse files
authored
Revert "Make prerendering always non-blocking" (#31080)
Reverts #31056
1 parent 60b1420 commit 76aee6f

File tree

7 files changed

+137
-298
lines changed

7 files changed

+137
-298
lines changed

packages/react-dom/src/__tests__/ReactDOMFiberAsync-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ describe('ReactDOMFiberAsync', () => {
744744
// Because it suspended, it remains on the current path
745745
expect(div.textContent).toBe('/path/a');
746746
});
747-
assertLog(gate('enableSiblingPrerendering') ? ['Suspend! [/path/b]'] : []);
747+
assertLog([]);
748748

749749
await act(async () => {
750750
resolvePromise();

packages/react-reconciler/src/ReactFiberCompleteWork.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ import {
4242
enableRenderableContext,
4343
passChildrenWhenCloningPersistedNodes,
4444
disableLegacyMode,
45-
enableSiblingPrerendering,
4645
} from 'shared/ReactFeatureFlags';
4746

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

624623
// Track the lanes that have been scheduled for an immediate retry so that
625624
// we can mark them as suspended upon committing the root.
626-
if (enableSiblingPrerendering) {
627-
markSpawnedRetryLane(retryLane);
628-
}
625+
markSpawnedRetryLane(retryLane);
629626
}
630627
}
631628

packages/react-reconciler/src/ReactFiberLane.js

+12-20
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import {
2727
transitionLaneExpirationMs,
2828
retryLaneExpirationMs,
2929
disableLegacyMode,
30-
enableSiblingPrerendering,
3130
} from 'shared/ReactFeatureFlags';
3231
import {isDevToolsPresent} from './ReactFiberDevToolsHook';
3332
import {clz32} from './clz32';
@@ -271,13 +270,11 @@ export function getNextLanes(root: FiberRoot, wipLanes: Lanes): Lanes {
271270
if (nonIdlePingedLanes !== NoLanes) {
272271
nextLanes = getHighestPriorityLanes(nonIdlePingedLanes);
273272
} else {
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-
}
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);
281278
}
282279
}
283280
}
@@ -297,13 +294,11 @@ export function getNextLanes(root: FiberRoot, wipLanes: Lanes): Lanes {
297294
if (pingedLanes !== NoLanes) {
298295
nextLanes = getHighestPriorityLanes(pingedLanes);
299296
} else {
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-
}
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);
307302
}
308303
}
309304
}
@@ -765,14 +760,12 @@ export function markRootSuspended(
765760
root: FiberRoot,
766761
suspendedLanes: Lanes,
767762
spawnedLane: Lane,
768-
didAttemptEntireTree: boolean,
763+
didSkipSuspendedSiblings: boolean,
769764
) {
770-
// TODO: Split this into separate functions for marking the root at the end of
771-
// a render attempt versus suspending while the root is still in progress.
772765
root.suspendedLanes |= suspendedLanes;
773766
root.pingedLanes &= ~suspendedLanes;
774767

775-
if (enableSiblingPrerendering && didAttemptEntireTree) {
768+
if (!didSkipSuspendedSiblings) {
776769
// Mark these lanes as warm so we know there's nothing else to work on.
777770
root.warmLanes |= suspendedLanes;
778771
} else {
@@ -883,7 +876,6 @@ export function markRootFinished(
883876
// suspended) instead of the regular mode (i.e. unwind and skip the siblings
884877
// as soon as something suspends to unblock the rest of the update).
885878
if (
886-
enableSiblingPrerendering &&
887879
suspendedRetryLanes !== NoLanes &&
888880
// Note that we only do this if there were no updates since we started
889881
// rendering. This mirrors the logic in markRootUpdated — whenever we

packages/react-reconciler/src/ReactFiberRootScheduler.js

+4-16
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import {
1818
disableSchedulerTimeoutInWorkLoop,
1919
enableProfilerTimer,
2020
enableProfilerNestedUpdatePhase,
21-
enableSiblingPrerendering,
2221
} from 'shared/ReactFeatureFlags';
2322
import {
2423
NoLane,
@@ -30,7 +29,6 @@ import {
3029
markStarvedLanesAsExpired,
3130
claimNextTransitionLane,
3231
getNextLanesToFlushSync,
33-
checkIfRootIsPrerendering,
3432
} from './ReactFiberLane';
3533
import {
3634
CommitContext,
@@ -208,10 +206,7 @@ function flushSyncWorkAcrossRoots_impl(
208206
? workInProgressRootRenderLanes
209207
: NoLanes,
210208
);
211-
if (
212-
includesSyncLane(nextLanes) &&
213-
!checkIfRootIsPrerendering(root, nextLanes)
214-
) {
209+
if (includesSyncLane(nextLanes)) {
215210
// This root has pending sync work. Flush it now.
216211
didPerformSomeWork = true;
217212
performSyncWorkOnRoot(root, nextLanes);
@@ -346,13 +341,7 @@ function scheduleTaskForRootDuringMicrotask(
346341
}
347342

348343
// Schedule a new callback in the host environment.
349-
if (
350-
includesSyncLane(nextLanes) &&
351-
// If we're prerendering, then we should use the concurrent work loop
352-
// even if the lanes are synchronous, so that prerendering never blocks
353-
// the main thread.
354-
!(enableSiblingPrerendering && checkIfRootIsPrerendering(root, nextLanes))
355-
) {
344+
if (includesSyncLane(nextLanes)) {
356345
// Synchronous work is always flushed at the end of the microtask, so we
357346
// don't need to schedule an additional task.
358347
if (existingCallbackNode !== null) {
@@ -386,10 +375,9 @@ function scheduleTaskForRootDuringMicrotask(
386375

387376
let schedulerPriorityLevel;
388377
switch (lanesToEventPriority(nextLanes)) {
389-
// Scheduler does have an "ImmediatePriority", but now that we use
390-
// microtasks for sync work we no longer use that. Any sync work that
391-
// reaches this path is meant to be time sliced.
392378
case DiscreteEventPriority:
379+
schedulerPriorityLevel = ImmediateSchedulerPriority;
380+
break;
393381
case ContinuousEventPriority:
394382
schedulerPriorityLevel = UserBlockingSchedulerPriority;
395383
break;

0 commit comments

Comments
 (0)