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 c244ce9 commit 545bf7e
Show file tree
Hide file tree
Showing 24 changed files with 1,231 additions and 1,367 deletions.
2 changes: 1 addition & 1 deletion compiled-rn/VERSION_NATIVE_FB
Original file line number Diff line number Diff line change
@@ -1 +1 @@
19.1.0-native-fb-34ee3919-20241217
19.1.0-native-fb-facec3ee-20241217
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<30f52d921681128a0384ae46787dc225>>
* @generated SignedSource<<5f71600380649b875c0a51a31e58dff5>>
*/

"use strict";
Expand Down Expand Up @@ -420,5 +420,5 @@ __DEV__ &&
exports.useFormStatus = function () {
return resolveDispatcher().useHostTransitionStatus();
};
exports.version = "19.1.0-native-fb-34ee3919-20241217";
exports.version = "19.1.0-native-fb-facec3ee-20241217";
})();
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<071057a56fce7a4c79ad8d6f2900e7b2>>
* @generated SignedSource<<a8bc17ffe2d6bec1f415b3bf5659951d>>
*/

"use strict";
Expand Down Expand Up @@ -203,4 +203,4 @@ exports.useFormState = function (action, initialState, permalink) {
exports.useFormStatus = function () {
return ReactSharedInternals.H.useHostTransitionStatus();
};
exports.version = "19.1.0-native-fb-34ee3919-20241217";
exports.version = "19.1.0-native-fb-facec3ee-20241217";
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<071057a56fce7a4c79ad8d6f2900e7b2>>
* @generated SignedSource<<a8bc17ffe2d6bec1f415b3bf5659951d>>
*/

"use strict";
Expand Down Expand Up @@ -203,4 +203,4 @@ exports.useFormState = function (action, initialState, permalink) {
exports.useFormStatus = function () {
return ReactSharedInternals.H.useHostTransitionStatus();
};
exports.version = "19.1.0-native-fb-34ee3919-20241217";
exports.version = "19.1.0-native-fb-facec3ee-20241217";
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<44d6e479cf988ecaa5efc9779c05bcad>>
* @generated SignedSource<<b2dac17bca2690dc272ac344fbc8764b>>
*/

/*
Expand Down Expand Up @@ -16389,9 +16389,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 @@ -16405,24 +16402,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$1(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$1(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 = ReactDOMSharedInternals.p),
(updatedLanes = ReactDOMSharedInternals.p),
(ReactDOMSharedInternals.p = DiscreteEventPriority),
(updatedLanes = executionContext),
(suspendedRetryLanes = executionContext),
(executionContext |= CommitContext),
commitBeforeMutationEffects(root, finishedWork),
commitMutationEffects(
Expand All @@ -16446,12 +16449,12 @@ __DEV__ &&
typeof injectedProfilingHooks.markLayoutEffectsStopped &&
injectedProfilingHooks.markLayoutEffectsStopped(),
requestPaint(),
(executionContext = updatedLanes),
(ReactDOMSharedInternals.p = spawnedLane),
(executionContext = suspendedRetryLanes),
(ReactDOMSharedInternals.p = updatedLanes),
(ReactSharedInternals.T = transitions))
: (root.current = finishedWork);
(transitions = rootDoesHavePassiveEffects)
? ((rootDoesHavePassiveEffects = !1),
(transitions = spawnedLane)
? ((spawnedLane = !1),
(rootWithPendingPassiveEffects = root),
(pendingPassiveEffectsLanes = didIncludeRenderPhaseUpdate))
: (releaseRootPooledCache(root, remainingLanes),
Expand All @@ -16463,24 +16466,24 @@ __DEV__ &&
onCommitRoot$1(finishedWork.stateNode, renderPriorityLevel);
isDevToolsPresent && root.memoizedUpdaters.clear();
onCommitRoot();
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) &&
0 !== root.tag &&
flushPassiveEffects();
ensureRootIsScheduled(root);
remainingLanes = root.pendingLanes;
0 !== (didIncludeRenderPhaseUpdate & 4194218) &&
0 !== (remainingLanes & 42)
Expand Down Expand Up @@ -25323,7 +25326,6 @@ __DEV__ &&
RENDER_TIMEOUT_MS = 500,
workInProgressTransitions = null,
legacyErrorBoundariesThatAlreadyFailed = null,
rootDoesHavePassiveEffects = !1,
rootWithPendingPassiveEffects = null,
pendingPassiveEffectsLanes = 0,
pendingPassiveEffectsRemainingLanes = 0,
Expand Down Expand Up @@ -25883,11 +25885,11 @@ __DEV__ &&
};
(function () {
var isomorphicReactPackageVersion = React.version;
if ("19.1.0-native-fb-34ee3919-20241217" !== isomorphicReactPackageVersion)
if ("19.1.0-native-fb-facec3ee-20241217" !== isomorphicReactPackageVersion)
throw Error(
'Incompatible React versions: The "react" and "react-dom" packages must have the exact same version. Instead got:\n - react: ' +
(isomorphicReactPackageVersion +
"\n - react-dom: 19.1.0-native-fb-34ee3919-20241217\nLearn more: https://react.dev/warnings/version-mismatch")
"\n - react-dom: 19.1.0-native-fb-facec3ee-20241217\nLearn more: https://react.dev/warnings/version-mismatch")
);
})();
("function" === typeof Map &&
Expand Down Expand Up @@ -25924,10 +25926,10 @@ __DEV__ &&
!(function () {
var internals = {
bundleType: 1,
version: "19.1.0-native-fb-34ee3919-20241217",
version: "19.1.0-native-fb-facec3ee-20241217",
rendererPackageName: "react-dom",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.1.0-native-fb-34ee3919-20241217"
reconcilerVersion: "19.1.0-native-fb-facec3ee-20241217"
};
internals.overrideHookState = overrideHookState;
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
Expand Down Expand Up @@ -26073,5 +26075,5 @@ __DEV__ &&
listenToAllSupportedEvents(container);
return new ReactDOMHydrationRoot(initialChildren);
};
exports.version = "19.1.0-native-fb-34ee3919-20241217";
exports.version = "19.1.0-native-fb-facec3ee-20241217";
})();
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<3ce4685c4d100cff61246b33dd2513d1>>
* @generated SignedSource<<3983426ab11c7aaa107d81ebca2c5b9f>>
*/

/*
Expand Down Expand Up @@ -10938,7 +10938,6 @@ var DefaultAsyncDispatcher = {
workInProgressRootRenderTargetTime = Infinity,
workInProgressTransitions = null,
legacyErrorBoundariesThatAlreadyFailed = null,
rootDoesHavePassiveEffects = !1,
rootWithPendingPassiveEffects = null,
pendingPassiveEffectsLanes = 0,
pendingPassiveEffectsRemainingLanes = 0,
Expand Down Expand Up @@ -11828,9 +11827,6 @@ function commitRootImpl(
root.finishedWork = null;
root.finishedLanes = 0;
if (finishedWork === root.current) throw Error(formatProdErrorMessage(177));
root.callbackNode = null;
root.callbackPriority = 0;
root.cancelPendingCommit = null;
var remainingLanes = finishedWork.lanes | finishedWork.childLanes;
remainingLanes |= concurrentlyUpdatedLanes;
markRootFinished(
Expand All @@ -11844,23 +11840,29 @@ function commitRootImpl(
root === workInProgressRoot &&
((workInProgress = workInProgressRoot = null),
(workInProgressRootRenderLanes = 0));
(0 === (finishedWork.subtreeFlags & 10256) &&
0 === (finishedWork.flags & 10256)) ||
rootDoesHavePassiveEffects ||
((rootDoesHavePassiveEffects = !0),
(pendingPassiveEffectsRemainingLanes = remainingLanes),
(pendingPassiveTransitions = transitions),
scheduleCallback$1(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$1(NormalPriority$1, function () {
flushPassiveEffects(!0);
return null;
}))
: ((root.callbackNode = null),
(root.callbackPriority = 0),
(root.cancelPendingCommit = null));
transitions = 0 !== (finishedWork.flags & 15990);
0 !== (finishedWork.subtreeFlags & 15990) || transitions
? ((transitions = ReactSharedInternals.T),
(ReactSharedInternals.T = null),
(spawnedLane = ReactDOMSharedInternals.p),
(updatedLanes = ReactDOMSharedInternals.p),
(ReactDOMSharedInternals.p = 2),
(updatedLanes = executionContext),
(suspendedRetryLanes = executionContext),
(executionContext |= 4),
commitBeforeMutationEffects(root, finishedWork),
commitMutationEffectsOnFiber(finishedWork, root),
Expand All @@ -11870,19 +11872,18 @@ function commitRootImpl(
(root.current = finishedWork),
commitLayoutEffectOnFiber(root, finishedWork.alternate, finishedWork),
requestPaint(),
(executionContext = updatedLanes),
(ReactDOMSharedInternals.p = spawnedLane),
(executionContext = suspendedRetryLanes),
(ReactDOMSharedInternals.p = updatedLanes),
(ReactSharedInternals.T = transitions))
: (root.current = finishedWork);
rootDoesHavePassiveEffects
? ((rootDoesHavePassiveEffects = !1),
spawnedLane
? ((spawnedLane = !1),
(rootWithPendingPassiveEffects = root),
(pendingPassiveEffectsLanes = didIncludeRenderPhaseUpdate))
: releaseRootPooledCache(root, remainingLanes);
remainingLanes = root.pendingLanes;
0 === remainingLanes && (legacyErrorBoundariesThatAlreadyFailed = null);
onCommitRoot(finishedWork.stateNode, renderPriorityLevel);
ensureRootIsScheduled(root);
if (null !== recoverableErrors)
for (
renderPriorityLevel = root.onRecoverableError, finishedWork = 0;
Expand All @@ -11896,6 +11897,7 @@ function commitRootImpl(
0 !== (pendingPassiveEffectsLanes & 3) &&
0 !== root.tag &&
flushPassiveEffects();
ensureRootIsScheduled(root);
remainingLanes = root.pendingLanes;
0 !== (didIncludeRenderPhaseUpdate & 4194218) && 0 !== (remainingLanes & 42)
? root === rootWithNestedUpdates
Expand Down Expand Up @@ -15867,14 +15869,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
};
var isomorphicReactPackageVersion$jscomp$inline_1722 = React.version;
if (
"19.1.0-native-fb-34ee3919-20241217" !==
"19.1.0-native-fb-facec3ee-20241217" !==
isomorphicReactPackageVersion$jscomp$inline_1722
)
throw Error(
formatProdErrorMessage(
527,
isomorphicReactPackageVersion$jscomp$inline_1722,
"19.1.0-native-fb-34ee3919-20241217"
"19.1.0-native-fb-facec3ee-20241217"
)
);
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
Expand All @@ -15896,10 +15898,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
};
var internals$jscomp$inline_2177 = {
bundleType: 0,
version: "19.1.0-native-fb-34ee3919-20241217",
version: "19.1.0-native-fb-facec3ee-20241217",
rendererPackageName: "react-dom",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.1.0-native-fb-34ee3919-20241217"
reconcilerVersion: "19.1.0-native-fb-facec3ee-20241217"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_2178 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down Expand Up @@ -16005,4 +16007,4 @@ exports.hydrateRoot = function (container, initialChildren, options) {
listenToAllSupportedEvents(container);
return new ReactDOMHydrationRoot(initialChildren);
};
exports.version = "19.1.0-native-fb-34ee3919-20241217";
exports.version = "19.1.0-native-fb-facec3ee-20241217";
Loading

0 comments on commit 545bf7e

Please sign in to comment.