Skip to content

Commit

Permalink
[Fiber] Schedule passive effects using the regular ensureRootIsSchedu…
Browse files Browse the repository at this point in the history
…led flow (facebook#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 facebook#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](facebook@facec3e)
  • Loading branch information
pull[bot] committed Dec 18, 2024
1 parent 01814dd commit 21e5027
Show file tree
Hide file tree
Showing 34 changed files with 1,540 additions and 1,566 deletions.
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
34ee3919c39bc9b149462322713a9811db4b8498
facec3ee71fff8b23f1e91005fce730cc96e4021
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION_TRANSFORMS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
34ee3919c39bc9b149462322713a9811db4b8498
facec3ee71fff8b23f1e91005fce730cc96e4021
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -1942,7 +1942,7 @@ __DEV__ &&
exports.useTransition = function () {
return resolveDispatcher().useTransition();
};
exports.version = "19.1.0-www-classic-34ee3919-20241217";
exports.version = "19.1.0-www-classic-facec3ee-20241217";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -1942,7 +1942,7 @@ __DEV__ &&
exports.useTransition = function () {
return resolveDispatcher().useTransition();
};
exports.version = "19.1.0-www-modern-34ee3919-20241217";
exports.version = "19.1.0-www-modern-facec3ee-20241217";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-prod.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -630,4 +630,4 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactSharedInternals.H.useTransition();
};
exports.version = "19.1.0-www-classic-34ee3919-20241217";
exports.version = "19.1.0-www-classic-facec3ee-20241217";
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-prod.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -630,4 +630,4 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactSharedInternals.H.useTransition();
};
exports.version = "19.1.0-www-modern-34ee3919-20241217";
exports.version = "19.1.0-www-modern-facec3ee-20241217";
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-profiling.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactSharedInternals.H.useTransition();
};
exports.version = "19.1.0-www-classic-34ee3919-20241217";
exports.version = "19.1.0-www-classic-facec3ee-20241217";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-profiling.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactSharedInternals.H.useTransition();
};
exports.version = "19.1.0-www-modern-34ee3919-20241217";
exports.version = "19.1.0-www-modern-facec3ee-20241217";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
54 changes: 28 additions & 26 deletions compiled/facebook-www/ReactART-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -13416,9 +13416,6 @@ __DEV__ &&
throw Error(
"Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue."
);
root.callbackNode = null;
root.callbackPriority = 0;
root.cancelPendingCommit = null;
var remainingLanes = finishedWork.lanes | finishedWork.childLanes;
remainingLanes |= concurrentlyUpdatedLanes;
markRootFinished(
Expand All @@ -13433,24 +13430,30 @@ __DEV__ &&
root === workInProgressRoot &&
((workInProgress = workInProgressRoot = null),
(workInProgressRootRenderLanes = 0));
(0 === (finishedWork.subtreeFlags & 10256) &&
0 === (finishedWork.flags & 10256)) ||
rootDoesHavePassiveEffects ||
((rootDoesHavePassiveEffects = !0),
(pendingPassiveEffectsRemainingLanes = remainingLanes),
(pendingPassiveTransitions = transitions),
scheduleCallback(NormalPriority$1, function () {
flushPassiveEffects(!0);
return null;
}));
spawnedLane = !1;
0 !== (finishedWork.subtreeFlags & 10256) ||
0 !== (finishedWork.flags & 10256)
? ((spawnedLane = !0),
(pendingPassiveEffectsRemainingLanes = remainingLanes),
(pendingPassiveTransitions = transitions),
(root.callbackNode = null),
(root.callbackPriority = 0),
(root.cancelPendingCommit = null),
scheduleCallback(NormalPriority$1, function () {
flushPassiveEffects(!0);
return null;
}))
: ((root.callbackNode = null),
(root.callbackPriority = 0),
(root.cancelPendingCommit = null));
commitStartTime = now();
transitions = 0 !== (finishedWork.flags & 15990);
0 !== (finishedWork.subtreeFlags & 15990) || transitions
? ((transitions = ReactSharedInternals.T),
(ReactSharedInternals.T = null),
(spawnedLane = currentUpdatePriority),
(updatedLanes = currentUpdatePriority),
(currentUpdatePriority = DiscreteEventPriority),
(updatedLanes = executionContext),
(suspendedRetryLanes = executionContext),
(executionContext |= CommitContext),
commitBeforeMutationEffects(root, finishedWork),
commitMutationEffects(root, finishedWork, lanes),
Expand All @@ -13469,12 +13472,12 @@ __DEV__ &&
typeof injectedProfilingHooks.markLayoutEffectsStopped &&
injectedProfilingHooks.markLayoutEffectsStopped(),
requestPaint(),
(executionContext = updatedLanes),
(currentUpdatePriority = spawnedLane),
(executionContext = suspendedRetryLanes),
(currentUpdatePriority = updatedLanes),
(ReactSharedInternals.T = transitions))
: (root.current = finishedWork);
(transitions = rootDoesHavePassiveEffects)
? ((rootDoesHavePassiveEffects = !1),
(transitions = spawnedLane)
? ((spawnedLane = !1),
(rootWithPendingPassiveEffects = root),
(pendingPassiveEffectsLanes = lanes))
: (releaseRootPooledCache(root, remainingLanes),
Expand All @@ -13485,22 +13488,22 @@ __DEV__ &&
transitions || commitDoubleInvokeEffectsInDEV(root);
onCommitRoot(finishedWork.stateNode, renderPriorityLevel);
isDevToolsPresent && root.memoizedUpdaters.clear();
ensureRootIsScheduled(root);
if (null !== recoverableErrors)
for (
renderPriorityLevel = root.onRecoverableError, finishedWork = 0;
finishedWork < recoverableErrors.length;
finishedWork++
)
(remainingLanes = recoverableErrors[finishedWork]),
(transitions = makeErrorInfo(remainingLanes.stack)),
(spawnedLane = makeErrorInfo(remainingLanes.stack)),
runWithFiberInDEV(
remainingLanes.source,
renderPriorityLevel,
remainingLanes.value,
transitions
spawnedLane
);
0 !== (pendingPassiveEffectsLanes & 3) && flushPassiveEffects();
ensureRootIsScheduled(root);
remainingLanes = root.pendingLanes;
(enableInfiniteRenderLoopDetection &&
(didIncludeRenderPhaseUpdate || didIncludeCommitPhaseUpdate)) ||
Expand Down Expand Up @@ -16657,7 +16660,6 @@ __DEV__ &&
currentPendingTransitionCallbacks = null,
currentEndTime = null,
legacyErrorBoundariesThatAlreadyFailed = null,
rootDoesHavePassiveEffects = !1,
rootWithPendingPassiveEffects = null,
pendingPassiveEffectsLanes = 0,
pendingPassiveEffectsRemainingLanes = 0,
Expand Down Expand Up @@ -16896,10 +16898,10 @@ __DEV__ &&
(function () {
var internals = {
bundleType: 1,
version: "19.1.0-www-classic-34ee3919-20241217",
version: "19.1.0-www-classic-facec3ee-20241217",
rendererPackageName: "react-art",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.1.0-www-classic-34ee3919-20241217"
reconcilerVersion: "19.1.0-www-classic-facec3ee-20241217"
};
internals.overrideHookState = overrideHookState;
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
Expand Down Expand Up @@ -16933,7 +16935,7 @@ __DEV__ &&
exports.Shape = Shape;
exports.Surface = Surface;
exports.Text = Text;
exports.version = "19.1.0-www-classic-34ee3919-20241217";
exports.version = "19.1.0-www-classic-facec3ee-20241217";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
54 changes: 28 additions & 26 deletions compiled/facebook-www/ReactART-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -13216,9 +13216,6 @@ __DEV__ &&
throw Error(
"Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue."
);
root.callbackNode = null;
root.callbackPriority = 0;
root.cancelPendingCommit = null;
var remainingLanes = finishedWork.lanes | finishedWork.childLanes;
remainingLanes |= concurrentlyUpdatedLanes;
markRootFinished(
Expand All @@ -13233,24 +13230,30 @@ __DEV__ &&
root === workInProgressRoot &&
((workInProgress = workInProgressRoot = null),
(workInProgressRootRenderLanes = 0));
(0 === (finishedWork.subtreeFlags & 10256) &&
0 === (finishedWork.flags & 10256)) ||
rootDoesHavePassiveEffects ||
((rootDoesHavePassiveEffects = !0),
(pendingPassiveEffectsRemainingLanes = remainingLanes),
(pendingPassiveTransitions = transitions),
scheduleCallback(NormalPriority$1, function () {
flushPassiveEffects(!0);
return null;
}));
spawnedLane = !1;
0 !== (finishedWork.subtreeFlags & 10256) ||
0 !== (finishedWork.flags & 10256)
? ((spawnedLane = !0),
(pendingPassiveEffectsRemainingLanes = remainingLanes),
(pendingPassiveTransitions = transitions),
(root.callbackNode = null),
(root.callbackPriority = 0),
(root.cancelPendingCommit = null),
scheduleCallback(NormalPriority$1, function () {
flushPassiveEffects(!0);
return null;
}))
: ((root.callbackNode = null),
(root.callbackPriority = 0),
(root.cancelPendingCommit = null));
commitStartTime = now();
transitions = 0 !== (finishedWork.flags & 15990);
0 !== (finishedWork.subtreeFlags & 15990) || transitions
? ((transitions = ReactSharedInternals.T),
(ReactSharedInternals.T = null),
(spawnedLane = currentUpdatePriority),
(updatedLanes = currentUpdatePriority),
(currentUpdatePriority = DiscreteEventPriority),
(updatedLanes = executionContext),
(suspendedRetryLanes = executionContext),
(executionContext |= CommitContext),
commitBeforeMutationEffects(root, finishedWork),
commitMutationEffects(root, finishedWork, lanes),
Expand All @@ -13269,12 +13272,12 @@ __DEV__ &&
typeof injectedProfilingHooks.markLayoutEffectsStopped &&
injectedProfilingHooks.markLayoutEffectsStopped(),
requestPaint(),
(executionContext = updatedLanes),
(currentUpdatePriority = spawnedLane),
(executionContext = suspendedRetryLanes),
(currentUpdatePriority = updatedLanes),
(ReactSharedInternals.T = transitions))
: (root.current = finishedWork);
(transitions = rootDoesHavePassiveEffects)
? ((rootDoesHavePassiveEffects = !1),
(transitions = spawnedLane)
? ((spawnedLane = !1),
(rootWithPendingPassiveEffects = root),
(pendingPassiveEffectsLanes = lanes))
: (releaseRootPooledCache(root, remainingLanes),
Expand All @@ -13285,22 +13288,22 @@ __DEV__ &&
transitions || commitDoubleInvokeEffectsInDEV(root);
onCommitRoot(finishedWork.stateNode, renderPriorityLevel);
isDevToolsPresent && root.memoizedUpdaters.clear();
ensureRootIsScheduled(root);
if (null !== recoverableErrors)
for (
renderPriorityLevel = root.onRecoverableError, finishedWork = 0;
finishedWork < recoverableErrors.length;
finishedWork++
)
(remainingLanes = recoverableErrors[finishedWork]),
(transitions = makeErrorInfo(remainingLanes.stack)),
(spawnedLane = makeErrorInfo(remainingLanes.stack)),
runWithFiberInDEV(
remainingLanes.source,
renderPriorityLevel,
remainingLanes.value,
transitions
spawnedLane
);
0 !== (pendingPassiveEffectsLanes & 3) && flushPassiveEffects();
ensureRootIsScheduled(root);
remainingLanes = root.pendingLanes;
(enableInfiniteRenderLoopDetection &&
(didIncludeRenderPhaseUpdate || didIncludeCommitPhaseUpdate)) ||
Expand Down Expand Up @@ -16420,7 +16423,6 @@ __DEV__ &&
currentPendingTransitionCallbacks = null,
currentEndTime = null,
legacyErrorBoundariesThatAlreadyFailed = null,
rootDoesHavePassiveEffects = !1,
rootWithPendingPassiveEffects = null,
pendingPassiveEffectsLanes = 0,
pendingPassiveEffectsRemainingLanes = 0,
Expand Down Expand Up @@ -16659,10 +16661,10 @@ __DEV__ &&
(function () {
var internals = {
bundleType: 1,
version: "19.1.0-www-modern-34ee3919-20241217",
version: "19.1.0-www-modern-facec3ee-20241217",
rendererPackageName: "react-art",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.1.0-www-modern-34ee3919-20241217"
reconcilerVersion: "19.1.0-www-modern-facec3ee-20241217"
};
internals.overrideHookState = overrideHookState;
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
Expand Down Expand Up @@ -16696,7 +16698,7 @@ __DEV__ &&
exports.Shape = Shape;
exports.Surface = Surface;
exports.Text = Text;
exports.version = "19.1.0-www-modern-34ee3919-20241217";
exports.version = "19.1.0-www-modern-facec3ee-20241217";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
Loading

0 comments on commit 21e5027

Please sign in to comment.