Skip to content

Commit 990edd3

Browse files
committed
[Fiber] Schedule passive effects using the regular ensureRootIsScheduled flow (#31785)
This treats workInProgressRoot work and rootWithPendingPassiveEffects the same way. Basically as long as there's some work on the root, yield the current task. Including passive effects. This means that passive effects are now a continuation instead of a separate callback. This can mean they're earlier or later than before. Later for Idle in case there's other non-React work. Earlier for same Default if there's other Default priority work. This makes sense since increasing priority of the passive effects beyond Idle doesn't really make sense for an Idle render. However, for any given render at same priority it's more important to complete this work than start something new. Since we special case continuations to always yield to the browser, this has the same effect as #31784 without implementing `requestPaint`. At least assuming nothing else calls `requestPaint`. <img width="587" alt="Screenshot 2024-12-14 at 5 37 37 PM" src="https://github.com/user-attachments/assets/8641b172-8842-4191-8bf0-50cbe263a30c" /> DiffTrain build for [facec3e](facec3e)
1 parent 5963da6 commit 990edd3

34 files changed

+1540
-1566
lines changed

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
34ee3919c39bc9b149462322713a9811db4b8498
1+
facec3ee71fff8b23f1e91005fce730cc96e4021
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
34ee3919c39bc9b149462322713a9811db4b8498
1+
facec3ee71fff8b23f1e91005fce730cc96e4021

compiled/facebook-www/React-dev.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1942,7 +1942,7 @@ __DEV__ &&
19421942
exports.useTransition = function () {
19431943
return resolveDispatcher().useTransition();
19441944
};
1945-
exports.version = "19.1.0-www-classic-34ee3919-20241217";
1945+
exports.version = "19.1.0-www-classic-facec3ee-20241217";
19461946
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
19471947
"function" ===
19481948
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-dev.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1942,7 +1942,7 @@ __DEV__ &&
19421942
exports.useTransition = function () {
19431943
return resolveDispatcher().useTransition();
19441944
};
1945-
exports.version = "19.1.0-www-modern-34ee3919-20241217";
1945+
exports.version = "19.1.0-www-modern-facec3ee-20241217";
19461946
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
19471947
"function" ===
19481948
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-prod.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,4 +630,4 @@ exports.useSyncExternalStore = function (
630630
exports.useTransition = function () {
631631
return ReactSharedInternals.H.useTransition();
632632
};
633-
exports.version = "19.1.0-www-classic-34ee3919-20241217";
633+
exports.version = "19.1.0-www-classic-facec3ee-20241217";

compiled/facebook-www/React-prod.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,4 +630,4 @@ exports.useSyncExternalStore = function (
630630
exports.useTransition = function () {
631631
return ReactSharedInternals.H.useTransition();
632632
};
633-
exports.version = "19.1.0-www-modern-34ee3919-20241217";
633+
exports.version = "19.1.0-www-modern-facec3ee-20241217";

compiled/facebook-www/React-profiling.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ exports.useSyncExternalStore = function (
634634
exports.useTransition = function () {
635635
return ReactSharedInternals.H.useTransition();
636636
};
637-
exports.version = "19.1.0-www-classic-34ee3919-20241217";
637+
exports.version = "19.1.0-www-classic-facec3ee-20241217";
638638
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
639639
"function" ===
640640
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-profiling.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ exports.useSyncExternalStore = function (
634634
exports.useTransition = function () {
635635
return ReactSharedInternals.H.useTransition();
636636
};
637-
exports.version = "19.1.0-www-modern-34ee3919-20241217";
637+
exports.version = "19.1.0-www-modern-facec3ee-20241217";
638638
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
639639
"function" ===
640640
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/ReactART-dev.classic.js

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13416,9 +13416,6 @@ __DEV__ &&
1341613416
throw Error(
1341713417
"Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue."
1341813418
);
13419-
root.callbackNode = null;
13420-
root.callbackPriority = 0;
13421-
root.cancelPendingCommit = null;
1342213419
var remainingLanes = finishedWork.lanes | finishedWork.childLanes;
1342313420
remainingLanes |= concurrentlyUpdatedLanes;
1342413421
markRootFinished(
@@ -13433,24 +13430,30 @@ __DEV__ &&
1343313430
root === workInProgressRoot &&
1343413431
((workInProgress = workInProgressRoot = null),
1343513432
(workInProgressRootRenderLanes = 0));
13436-
(0 === (finishedWork.subtreeFlags & 10256) &&
13437-
0 === (finishedWork.flags & 10256)) ||
13438-
rootDoesHavePassiveEffects ||
13439-
((rootDoesHavePassiveEffects = !0),
13440-
(pendingPassiveEffectsRemainingLanes = remainingLanes),
13441-
(pendingPassiveTransitions = transitions),
13442-
scheduleCallback(NormalPriority$1, function () {
13443-
flushPassiveEffects(!0);
13444-
return null;
13445-
}));
13433+
spawnedLane = !1;
13434+
0 !== (finishedWork.subtreeFlags & 10256) ||
13435+
0 !== (finishedWork.flags & 10256)
13436+
? ((spawnedLane = !0),
13437+
(pendingPassiveEffectsRemainingLanes = remainingLanes),
13438+
(pendingPassiveTransitions = transitions),
13439+
(root.callbackNode = null),
13440+
(root.callbackPriority = 0),
13441+
(root.cancelPendingCommit = null),
13442+
scheduleCallback(NormalPriority$1, function () {
13443+
flushPassiveEffects(!0);
13444+
return null;
13445+
}))
13446+
: ((root.callbackNode = null),
13447+
(root.callbackPriority = 0),
13448+
(root.cancelPendingCommit = null));
1344613449
commitStartTime = now();
1344713450
transitions = 0 !== (finishedWork.flags & 15990);
1344813451
0 !== (finishedWork.subtreeFlags & 15990) || transitions
1344913452
? ((transitions = ReactSharedInternals.T),
1345013453
(ReactSharedInternals.T = null),
13451-
(spawnedLane = currentUpdatePriority),
13454+
(updatedLanes = currentUpdatePriority),
1345213455
(currentUpdatePriority = DiscreteEventPriority),
13453-
(updatedLanes = executionContext),
13456+
(suspendedRetryLanes = executionContext),
1345413457
(executionContext |= CommitContext),
1345513458
commitBeforeMutationEffects(root, finishedWork),
1345613459
commitMutationEffects(root, finishedWork, lanes),
@@ -13469,12 +13472,12 @@ __DEV__ &&
1346913472
typeof injectedProfilingHooks.markLayoutEffectsStopped &&
1347013473
injectedProfilingHooks.markLayoutEffectsStopped(),
1347113474
requestPaint(),
13472-
(executionContext = updatedLanes),
13473-
(currentUpdatePriority = spawnedLane),
13475+
(executionContext = suspendedRetryLanes),
13476+
(currentUpdatePriority = updatedLanes),
1347413477
(ReactSharedInternals.T = transitions))
1347513478
: (root.current = finishedWork);
13476-
(transitions = rootDoesHavePassiveEffects)
13477-
? ((rootDoesHavePassiveEffects = !1),
13479+
(transitions = spawnedLane)
13480+
? ((spawnedLane = !1),
1347813481
(rootWithPendingPassiveEffects = root),
1347913482
(pendingPassiveEffectsLanes = lanes))
1348013483
: (releaseRootPooledCache(root, remainingLanes),
@@ -13485,22 +13488,22 @@ __DEV__ &&
1348513488
transitions || commitDoubleInvokeEffectsInDEV(root);
1348613489
onCommitRoot(finishedWork.stateNode, renderPriorityLevel);
1348713490
isDevToolsPresent && root.memoizedUpdaters.clear();
13488-
ensureRootIsScheduled(root);
1348913491
if (null !== recoverableErrors)
1349013492
for (
1349113493
renderPriorityLevel = root.onRecoverableError, finishedWork = 0;
1349213494
finishedWork < recoverableErrors.length;
1349313495
finishedWork++
1349413496
)
1349513497
(remainingLanes = recoverableErrors[finishedWork]),
13496-
(transitions = makeErrorInfo(remainingLanes.stack)),
13498+
(spawnedLane = makeErrorInfo(remainingLanes.stack)),
1349713499
runWithFiberInDEV(
1349813500
remainingLanes.source,
1349913501
renderPriorityLevel,
1350013502
remainingLanes.value,
13501-
transitions
13503+
spawnedLane
1350213504
);
1350313505
0 !== (pendingPassiveEffectsLanes & 3) && flushPassiveEffects();
13506+
ensureRootIsScheduled(root);
1350413507
remainingLanes = root.pendingLanes;
1350513508
(enableInfiniteRenderLoopDetection &&
1350613509
(didIncludeRenderPhaseUpdate || didIncludeCommitPhaseUpdate)) ||
@@ -16657,7 +16660,6 @@ __DEV__ &&
1665716660
currentPendingTransitionCallbacks = null,
1665816661
currentEndTime = null,
1665916662
legacyErrorBoundariesThatAlreadyFailed = null,
16660-
rootDoesHavePassiveEffects = !1,
1666116663
rootWithPendingPassiveEffects = null,
1666216664
pendingPassiveEffectsLanes = 0,
1666316665
pendingPassiveEffectsRemainingLanes = 0,
@@ -16896,10 +16898,10 @@ __DEV__ &&
1689616898
(function () {
1689716899
var internals = {
1689816900
bundleType: 1,
16899-
version: "19.1.0-www-classic-34ee3919-20241217",
16901+
version: "19.1.0-www-classic-facec3ee-20241217",
1690016902
rendererPackageName: "react-art",
1690116903
currentDispatcherRef: ReactSharedInternals,
16902-
reconcilerVersion: "19.1.0-www-classic-34ee3919-20241217"
16904+
reconcilerVersion: "19.1.0-www-classic-facec3ee-20241217"
1690316905
};
1690416906
internals.overrideHookState = overrideHookState;
1690516907
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -16933,7 +16935,7 @@ __DEV__ &&
1693316935
exports.Shape = Shape;
1693416936
exports.Surface = Surface;
1693516937
exports.Text = Text;
16936-
exports.version = "19.1.0-www-classic-34ee3919-20241217";
16938+
exports.version = "19.1.0-www-classic-facec3ee-20241217";
1693716939
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
1693816940
"function" ===
1693916941
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/ReactART-dev.modern.js

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13216,9 +13216,6 @@ __DEV__ &&
1321613216
throw Error(
1321713217
"Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue."
1321813218
);
13219-
root.callbackNode = null;
13220-
root.callbackPriority = 0;
13221-
root.cancelPendingCommit = null;
1322213219
var remainingLanes = finishedWork.lanes | finishedWork.childLanes;
1322313220
remainingLanes |= concurrentlyUpdatedLanes;
1322413221
markRootFinished(
@@ -13233,24 +13230,30 @@ __DEV__ &&
1323313230
root === workInProgressRoot &&
1323413231
((workInProgress = workInProgressRoot = null),
1323513232
(workInProgressRootRenderLanes = 0));
13236-
(0 === (finishedWork.subtreeFlags & 10256) &&
13237-
0 === (finishedWork.flags & 10256)) ||
13238-
rootDoesHavePassiveEffects ||
13239-
((rootDoesHavePassiveEffects = !0),
13240-
(pendingPassiveEffectsRemainingLanes = remainingLanes),
13241-
(pendingPassiveTransitions = transitions),
13242-
scheduleCallback(NormalPriority$1, function () {
13243-
flushPassiveEffects(!0);
13244-
return null;
13245-
}));
13233+
spawnedLane = !1;
13234+
0 !== (finishedWork.subtreeFlags & 10256) ||
13235+
0 !== (finishedWork.flags & 10256)
13236+
? ((spawnedLane = !0),
13237+
(pendingPassiveEffectsRemainingLanes = remainingLanes),
13238+
(pendingPassiveTransitions = transitions),
13239+
(root.callbackNode = null),
13240+
(root.callbackPriority = 0),
13241+
(root.cancelPendingCommit = null),
13242+
scheduleCallback(NormalPriority$1, function () {
13243+
flushPassiveEffects(!0);
13244+
return null;
13245+
}))
13246+
: ((root.callbackNode = null),
13247+
(root.callbackPriority = 0),
13248+
(root.cancelPendingCommit = null));
1324613249
commitStartTime = now();
1324713250
transitions = 0 !== (finishedWork.flags & 15990);
1324813251
0 !== (finishedWork.subtreeFlags & 15990) || transitions
1324913252
? ((transitions = ReactSharedInternals.T),
1325013253
(ReactSharedInternals.T = null),
13251-
(spawnedLane = currentUpdatePriority),
13254+
(updatedLanes = currentUpdatePriority),
1325213255
(currentUpdatePriority = DiscreteEventPriority),
13253-
(updatedLanes = executionContext),
13256+
(suspendedRetryLanes = executionContext),
1325413257
(executionContext |= CommitContext),
1325513258
commitBeforeMutationEffects(root, finishedWork),
1325613259
commitMutationEffects(root, finishedWork, lanes),
@@ -13269,12 +13272,12 @@ __DEV__ &&
1326913272
typeof injectedProfilingHooks.markLayoutEffectsStopped &&
1327013273
injectedProfilingHooks.markLayoutEffectsStopped(),
1327113274
requestPaint(),
13272-
(executionContext = updatedLanes),
13273-
(currentUpdatePriority = spawnedLane),
13275+
(executionContext = suspendedRetryLanes),
13276+
(currentUpdatePriority = updatedLanes),
1327413277
(ReactSharedInternals.T = transitions))
1327513278
: (root.current = finishedWork);
13276-
(transitions = rootDoesHavePassiveEffects)
13277-
? ((rootDoesHavePassiveEffects = !1),
13279+
(transitions = spawnedLane)
13280+
? ((spawnedLane = !1),
1327813281
(rootWithPendingPassiveEffects = root),
1327913282
(pendingPassiveEffectsLanes = lanes))
1328013283
: (releaseRootPooledCache(root, remainingLanes),
@@ -13285,22 +13288,22 @@ __DEV__ &&
1328513288
transitions || commitDoubleInvokeEffectsInDEV(root);
1328613289
onCommitRoot(finishedWork.stateNode, renderPriorityLevel);
1328713290
isDevToolsPresent && root.memoizedUpdaters.clear();
13288-
ensureRootIsScheduled(root);
1328913291
if (null !== recoverableErrors)
1329013292
for (
1329113293
renderPriorityLevel = root.onRecoverableError, finishedWork = 0;
1329213294
finishedWork < recoverableErrors.length;
1329313295
finishedWork++
1329413296
)
1329513297
(remainingLanes = recoverableErrors[finishedWork]),
13296-
(transitions = makeErrorInfo(remainingLanes.stack)),
13298+
(spawnedLane = makeErrorInfo(remainingLanes.stack)),
1329713299
runWithFiberInDEV(
1329813300
remainingLanes.source,
1329913301
renderPriorityLevel,
1330013302
remainingLanes.value,
13301-
transitions
13303+
spawnedLane
1330213304
);
1330313305
0 !== (pendingPassiveEffectsLanes & 3) && flushPassiveEffects();
13306+
ensureRootIsScheduled(root);
1330413307
remainingLanes = root.pendingLanes;
1330513308
(enableInfiniteRenderLoopDetection &&
1330613309
(didIncludeRenderPhaseUpdate || didIncludeCommitPhaseUpdate)) ||
@@ -16420,7 +16423,6 @@ __DEV__ &&
1642016423
currentPendingTransitionCallbacks = null,
1642116424
currentEndTime = null,
1642216425
legacyErrorBoundariesThatAlreadyFailed = null,
16423-
rootDoesHavePassiveEffects = !1,
1642416426
rootWithPendingPassiveEffects = null,
1642516427
pendingPassiveEffectsLanes = 0,
1642616428
pendingPassiveEffectsRemainingLanes = 0,
@@ -16659,10 +16661,10 @@ __DEV__ &&
1665916661
(function () {
1666016662
var internals = {
1666116663
bundleType: 1,
16662-
version: "19.1.0-www-modern-34ee3919-20241217",
16664+
version: "19.1.0-www-modern-facec3ee-20241217",
1666316665
rendererPackageName: "react-art",
1666416666
currentDispatcherRef: ReactSharedInternals,
16665-
reconcilerVersion: "19.1.0-www-modern-34ee3919-20241217"
16667+
reconcilerVersion: "19.1.0-www-modern-facec3ee-20241217"
1666616668
};
1666716669
internals.overrideHookState = overrideHookState;
1666816670
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -16696,7 +16698,7 @@ __DEV__ &&
1669616698
exports.Shape = Shape;
1669716699
exports.Surface = Surface;
1669816700
exports.Text = Text;
16699-
exports.version = "19.1.0-www-modern-34ee3919-20241217";
16701+
exports.version = "19.1.0-www-modern-facec3ee-20241217";
1670016702
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
1670116703
"function" ===
1670216704
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

0 commit comments

Comments
 (0)