Skip to content

Commit 545bf7e

Browse files
committed
[Fiber] Schedule passive effects using the regular ensureRootIsScheduled 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)
1 parent c244ce9 commit 545bf7e

24 files changed

+1231
-1367
lines changed

compiled-rn/VERSION_NATIVE_FB

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
19.1.0-native-fb-34ee3919-20241217
1+
19.1.0-native-fb-facec3ee-20241217

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-dev.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<30f52d921681128a0384ae46787dc225>>
10+
* @generated SignedSource<<5f71600380649b875c0a51a31e58dff5>>
1111
*/
1212

1313
"use strict";
@@ -420,5 +420,5 @@ __DEV__ &&
420420
exports.useFormStatus = function () {
421421
return resolveDispatcher().useHostTransitionStatus();
422422
};
423-
exports.version = "19.1.0-native-fb-34ee3919-20241217";
423+
exports.version = "19.1.0-native-fb-facec3ee-20241217";
424424
})();

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-prod.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<071057a56fce7a4c79ad8d6f2900e7b2>>
10+
* @generated SignedSource<<a8bc17ffe2d6bec1f415b3bf5659951d>>
1111
*/
1212

1313
"use strict";
@@ -203,4 +203,4 @@ exports.useFormState = function (action, initialState, permalink) {
203203
exports.useFormStatus = function () {
204204
return ReactSharedInternals.H.useHostTransitionStatus();
205205
};
206-
exports.version = "19.1.0-native-fb-34ee3919-20241217";
206+
exports.version = "19.1.0-native-fb-facec3ee-20241217";

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-profiling.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<071057a56fce7a4c79ad8d6f2900e7b2>>
10+
* @generated SignedSource<<a8bc17ffe2d6bec1f415b3bf5659951d>>
1111
*/
1212

1313
"use strict";
@@ -203,4 +203,4 @@ exports.useFormState = function (action, initialState, permalink) {
203203
exports.useFormStatus = function () {
204204
return ReactSharedInternals.H.useHostTransitionStatus();
205205
};
206-
exports.version = "19.1.0-native-fb-34ee3919-20241217";
206+
exports.version = "19.1.0-native-fb-facec3ee-20241217";

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-dev.js

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<44d6e479cf988ecaa5efc9779c05bcad>>
10+
* @generated SignedSource<<b2dac17bca2690dc272ac344fbc8764b>>
1111
*/
1212

1313
/*
@@ -16389,9 +16389,6 @@ __DEV__ &&
1638916389
throw Error(
1639016390
"Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue."
1639116391
);
16392-
root.callbackNode = null;
16393-
root.callbackPriority = 0;
16394-
root.cancelPendingCommit = null;
1639516392
var remainingLanes = finishedWork.lanes | finishedWork.childLanes;
1639616393
remainingLanes |= concurrentlyUpdatedLanes;
1639716394
markRootFinished(
@@ -16405,24 +16402,30 @@ __DEV__ &&
1640516402
root === workInProgressRoot &&
1640616403
((workInProgress = workInProgressRoot = null),
1640716404
(workInProgressRootRenderLanes = 0));
16408-
(0 === (finishedWork.subtreeFlags & 10256) &&
16409-
0 === (finishedWork.flags & 10256)) ||
16410-
rootDoesHavePassiveEffects ||
16411-
((rootDoesHavePassiveEffects = !0),
16412-
(pendingPassiveEffectsRemainingLanes = remainingLanes),
16413-
(pendingPassiveTransitions = transitions),
16414-
scheduleCallback$1(NormalPriority$1, function () {
16415-
flushPassiveEffects(!0);
16416-
return null;
16417-
}));
16405+
spawnedLane = !1;
16406+
0 !== (finishedWork.subtreeFlags & 10256) ||
16407+
0 !== (finishedWork.flags & 10256)
16408+
? ((spawnedLane = !0),
16409+
(pendingPassiveEffectsRemainingLanes = remainingLanes),
16410+
(pendingPassiveTransitions = transitions),
16411+
(root.callbackNode = null),
16412+
(root.callbackPriority = 0),
16413+
(root.cancelPendingCommit = null),
16414+
scheduleCallback$1(NormalPriority$1, function () {
16415+
flushPassiveEffects(!0);
16416+
return null;
16417+
}))
16418+
: ((root.callbackNode = null),
16419+
(root.callbackPriority = 0),
16420+
(root.cancelPendingCommit = null));
1641816421
commitStartTime = now();
1641916422
transitions = 0 !== (finishedWork.flags & 15990);
1642016423
0 !== (finishedWork.subtreeFlags & 15990) || transitions
1642116424
? ((transitions = ReactSharedInternals.T),
1642216425
(ReactSharedInternals.T = null),
16423-
(spawnedLane = ReactDOMSharedInternals.p),
16426+
(updatedLanes = ReactDOMSharedInternals.p),
1642416427
(ReactDOMSharedInternals.p = DiscreteEventPriority),
16425-
(updatedLanes = executionContext),
16428+
(suspendedRetryLanes = executionContext),
1642616429
(executionContext |= CommitContext),
1642716430
commitBeforeMutationEffects(root, finishedWork),
1642816431
commitMutationEffects(
@@ -16446,12 +16449,12 @@ __DEV__ &&
1644616449
typeof injectedProfilingHooks.markLayoutEffectsStopped &&
1644716450
injectedProfilingHooks.markLayoutEffectsStopped(),
1644816451
requestPaint(),
16449-
(executionContext = updatedLanes),
16450-
(ReactDOMSharedInternals.p = spawnedLane),
16452+
(executionContext = suspendedRetryLanes),
16453+
(ReactDOMSharedInternals.p = updatedLanes),
1645116454
(ReactSharedInternals.T = transitions))
1645216455
: (root.current = finishedWork);
16453-
(transitions = rootDoesHavePassiveEffects)
16454-
? ((rootDoesHavePassiveEffects = !1),
16456+
(transitions = spawnedLane)
16457+
? ((spawnedLane = !1),
1645516458
(rootWithPendingPassiveEffects = root),
1645616459
(pendingPassiveEffectsLanes = didIncludeRenderPhaseUpdate))
1645716460
: (releaseRootPooledCache(root, remainingLanes),
@@ -16463,24 +16466,24 @@ __DEV__ &&
1646316466
onCommitRoot$1(finishedWork.stateNode, renderPriorityLevel);
1646416467
isDevToolsPresent && root.memoizedUpdaters.clear();
1646516468
onCommitRoot();
16466-
ensureRootIsScheduled(root);
1646716469
if (null !== recoverableErrors)
1646816470
for (
1646916471
renderPriorityLevel = root.onRecoverableError, finishedWork = 0;
1647016472
finishedWork < recoverableErrors.length;
1647116473
finishedWork++
1647216474
)
1647316475
(remainingLanes = recoverableErrors[finishedWork]),
16474-
(transitions = makeErrorInfo(remainingLanes.stack)),
16476+
(spawnedLane = makeErrorInfo(remainingLanes.stack)),
1647516477
runWithFiberInDEV(
1647616478
remainingLanes.source,
1647716479
renderPriorityLevel,
1647816480
remainingLanes.value,
16479-
transitions
16481+
spawnedLane
1648016482
);
1648116483
0 !== (pendingPassiveEffectsLanes & 3) &&
1648216484
0 !== root.tag &&
1648316485
flushPassiveEffects();
16486+
ensureRootIsScheduled(root);
1648416487
remainingLanes = root.pendingLanes;
1648516488
0 !== (didIncludeRenderPhaseUpdate & 4194218) &&
1648616489
0 !== (remainingLanes & 42)
@@ -25323,7 +25326,6 @@ __DEV__ &&
2532325326
RENDER_TIMEOUT_MS = 500,
2532425327
workInProgressTransitions = null,
2532525328
legacyErrorBoundariesThatAlreadyFailed = null,
25326-
rootDoesHavePassiveEffects = !1,
2532725329
rootWithPendingPassiveEffects = null,
2532825330
pendingPassiveEffectsLanes = 0,
2532925331
pendingPassiveEffectsRemainingLanes = 0,
@@ -25883,11 +25885,11 @@ __DEV__ &&
2588325885
};
2588425886
(function () {
2588525887
var isomorphicReactPackageVersion = React.version;
25886-
if ("19.1.0-native-fb-34ee3919-20241217" !== isomorphicReactPackageVersion)
25888+
if ("19.1.0-native-fb-facec3ee-20241217" !== isomorphicReactPackageVersion)
2588725889
throw Error(
2588825890
'Incompatible React versions: The "react" and "react-dom" packages must have the exact same version. Instead got:\n - react: ' +
2588925891
(isomorphicReactPackageVersion +
25890-
"\n - react-dom: 19.1.0-native-fb-34ee3919-20241217\nLearn more: https://react.dev/warnings/version-mismatch")
25892+
"\n - react-dom: 19.1.0-native-fb-facec3ee-20241217\nLearn more: https://react.dev/warnings/version-mismatch")
2589125893
);
2589225894
})();
2589325895
("function" === typeof Map &&
@@ -25924,10 +25926,10 @@ __DEV__ &&
2592425926
!(function () {
2592525927
var internals = {
2592625928
bundleType: 1,
25927-
version: "19.1.0-native-fb-34ee3919-20241217",
25929+
version: "19.1.0-native-fb-facec3ee-20241217",
2592825930
rendererPackageName: "react-dom",
2592925931
currentDispatcherRef: ReactSharedInternals,
25930-
reconcilerVersion: "19.1.0-native-fb-34ee3919-20241217"
25932+
reconcilerVersion: "19.1.0-native-fb-facec3ee-20241217"
2593125933
};
2593225934
internals.overrideHookState = overrideHookState;
2593325935
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -26073,5 +26075,5 @@ __DEV__ &&
2607326075
listenToAllSupportedEvents(container);
2607426076
return new ReactDOMHydrationRoot(initialChildren);
2607526077
};
26076-
exports.version = "19.1.0-native-fb-34ee3919-20241217";
26078+
exports.version = "19.1.0-native-fb-facec3ee-20241217";
2607726079
})();

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-prod.js

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<3ce4685c4d100cff61246b33dd2513d1>>
10+
* @generated SignedSource<<3983426ab11c7aaa107d81ebca2c5b9f>>
1111
*/
1212

1313
/*
@@ -10938,7 +10938,6 @@ var DefaultAsyncDispatcher = {
1093810938
workInProgressRootRenderTargetTime = Infinity,
1093910939
workInProgressTransitions = null,
1094010940
legacyErrorBoundariesThatAlreadyFailed = null,
10941-
rootDoesHavePassiveEffects = !1,
1094210941
rootWithPendingPassiveEffects = null,
1094310942
pendingPassiveEffectsLanes = 0,
1094410943
pendingPassiveEffectsRemainingLanes = 0,
@@ -11828,9 +11827,6 @@ function commitRootImpl(
1182811827
root.finishedWork = null;
1182911828
root.finishedLanes = 0;
1183011829
if (finishedWork === root.current) throw Error(formatProdErrorMessage(177));
11831-
root.callbackNode = null;
11832-
root.callbackPriority = 0;
11833-
root.cancelPendingCommit = null;
1183411830
var remainingLanes = finishedWork.lanes | finishedWork.childLanes;
1183511831
remainingLanes |= concurrentlyUpdatedLanes;
1183611832
markRootFinished(
@@ -11844,23 +11840,29 @@ function commitRootImpl(
1184411840
root === workInProgressRoot &&
1184511841
((workInProgress = workInProgressRoot = null),
1184611842
(workInProgressRootRenderLanes = 0));
11847-
(0 === (finishedWork.subtreeFlags & 10256) &&
11848-
0 === (finishedWork.flags & 10256)) ||
11849-
rootDoesHavePassiveEffects ||
11850-
((rootDoesHavePassiveEffects = !0),
11851-
(pendingPassiveEffectsRemainingLanes = remainingLanes),
11852-
(pendingPassiveTransitions = transitions),
11853-
scheduleCallback$1(NormalPriority$1, function () {
11854-
flushPassiveEffects(!0);
11855-
return null;
11856-
}));
11843+
spawnedLane = !1;
11844+
0 !== (finishedWork.subtreeFlags & 10256) ||
11845+
0 !== (finishedWork.flags & 10256)
11846+
? ((spawnedLane = !0),
11847+
(pendingPassiveEffectsRemainingLanes = remainingLanes),
11848+
(pendingPassiveTransitions = transitions),
11849+
(root.callbackNode = null),
11850+
(root.callbackPriority = 0),
11851+
(root.cancelPendingCommit = null),
11852+
scheduleCallback$1(NormalPriority$1, function () {
11853+
flushPassiveEffects(!0);
11854+
return null;
11855+
}))
11856+
: ((root.callbackNode = null),
11857+
(root.callbackPriority = 0),
11858+
(root.cancelPendingCommit = null));
1185711859
transitions = 0 !== (finishedWork.flags & 15990);
1185811860
0 !== (finishedWork.subtreeFlags & 15990) || transitions
1185911861
? ((transitions = ReactSharedInternals.T),
1186011862
(ReactSharedInternals.T = null),
11861-
(spawnedLane = ReactDOMSharedInternals.p),
11863+
(updatedLanes = ReactDOMSharedInternals.p),
1186211864
(ReactDOMSharedInternals.p = 2),
11863-
(updatedLanes = executionContext),
11865+
(suspendedRetryLanes = executionContext),
1186411866
(executionContext |= 4),
1186511867
commitBeforeMutationEffects(root, finishedWork),
1186611868
commitMutationEffectsOnFiber(finishedWork, root),
@@ -11870,19 +11872,18 @@ function commitRootImpl(
1187011872
(root.current = finishedWork),
1187111873
commitLayoutEffectOnFiber(root, finishedWork.alternate, finishedWork),
1187211874
requestPaint(),
11873-
(executionContext = updatedLanes),
11874-
(ReactDOMSharedInternals.p = spawnedLane),
11875+
(executionContext = suspendedRetryLanes),
11876+
(ReactDOMSharedInternals.p = updatedLanes),
1187511877
(ReactSharedInternals.T = transitions))
1187611878
: (root.current = finishedWork);
11877-
rootDoesHavePassiveEffects
11878-
? ((rootDoesHavePassiveEffects = !1),
11879+
spawnedLane
11880+
? ((spawnedLane = !1),
1187911881
(rootWithPendingPassiveEffects = root),
1188011882
(pendingPassiveEffectsLanes = didIncludeRenderPhaseUpdate))
1188111883
: releaseRootPooledCache(root, remainingLanes);
1188211884
remainingLanes = root.pendingLanes;
1188311885
0 === remainingLanes && (legacyErrorBoundariesThatAlreadyFailed = null);
1188411886
onCommitRoot(finishedWork.stateNode, renderPriorityLevel);
11885-
ensureRootIsScheduled(root);
1188611887
if (null !== recoverableErrors)
1188711888
for (
1188811889
renderPriorityLevel = root.onRecoverableError, finishedWork = 0;
@@ -11896,6 +11897,7 @@ function commitRootImpl(
1189611897
0 !== (pendingPassiveEffectsLanes & 3) &&
1189711898
0 !== root.tag &&
1189811899
flushPassiveEffects();
11900+
ensureRootIsScheduled(root);
1189911901
remainingLanes = root.pendingLanes;
1190011902
0 !== (didIncludeRenderPhaseUpdate & 4194218) && 0 !== (remainingLanes & 42)
1190111903
? root === rootWithNestedUpdates
@@ -15867,14 +15869,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
1586715869
};
1586815870
var isomorphicReactPackageVersion$jscomp$inline_1722 = React.version;
1586915871
if (
15870-
"19.1.0-native-fb-34ee3919-20241217" !==
15872+
"19.1.0-native-fb-facec3ee-20241217" !==
1587115873
isomorphicReactPackageVersion$jscomp$inline_1722
1587215874
)
1587315875
throw Error(
1587415876
formatProdErrorMessage(
1587515877
527,
1587615878
isomorphicReactPackageVersion$jscomp$inline_1722,
15877-
"19.1.0-native-fb-34ee3919-20241217"
15879+
"19.1.0-native-fb-facec3ee-20241217"
1587815880
)
1587915881
);
1588015882
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
@@ -15896,10 +15898,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
1589615898
};
1589715899
var internals$jscomp$inline_2177 = {
1589815900
bundleType: 0,
15899-
version: "19.1.0-native-fb-34ee3919-20241217",
15901+
version: "19.1.0-native-fb-facec3ee-20241217",
1590015902
rendererPackageName: "react-dom",
1590115903
currentDispatcherRef: ReactSharedInternals,
15902-
reconcilerVersion: "19.1.0-native-fb-34ee3919-20241217"
15904+
reconcilerVersion: "19.1.0-native-fb-facec3ee-20241217"
1590315905
};
1590415906
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
1590515907
var hook$jscomp$inline_2178 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
@@ -16005,4 +16007,4 @@ exports.hydrateRoot = function (container, initialChildren, options) {
1600516007
listenToAllSupportedEvents(container);
1600616008
return new ReactDOMHydrationRoot(initialChildren);
1600716009
};
16008-
exports.version = "19.1.0-native-fb-34ee3919-20241217";
16010+
exports.version = "19.1.0-native-fb-facec3ee-20241217";

0 commit comments

Comments
 (0)