Skip to content

Commit 02ba30a

Browse files
committed
Add dynamic flag for infinite loop detection on React Native FB (#28456)
Add dynamic flag for infinite loop detection on React Native FB DiffTrain build for commit b8da12e.
1 parent 4942d00 commit 02ba30a

13 files changed

+407
-231
lines changed

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-dev.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -25735,7 +25735,7 @@ if (__DEV__) {
2573525735
return root;
2573625736
}
2573725737

25738-
var ReactVersion = "18.3.0-canary-fb10a2c66-20240228";
25738+
var ReactVersion = "18.3.0-canary-b8da12e8f-20240229";
2573925739

2574025740
// Might add PROFILE later.
2574125741

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-prod.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -9171,7 +9171,7 @@ var devToolsConfig$jscomp$inline_1014 = {
91719171
throw Error("TestRenderer does not support findFiberByHostInstance()");
91729172
},
91739173
bundleType: 0,
9174-
version: "18.3.0-canary-fb10a2c66-20240228",
9174+
version: "18.3.0-canary-b8da12e8f-20240229",
91759175
rendererPackageName: "react-test-renderer"
91769176
};
91779177
var internals$jscomp$inline_1195 = {
@@ -9202,7 +9202,7 @@ var internals$jscomp$inline_1195 = {
92029202
scheduleRoot: null,
92039203
setRefreshHandler: null,
92049204
getCurrentFiber: null,
9205-
reconcilerVersion: "18.3.0-canary-fb10a2c66-20240228"
9205+
reconcilerVersion: "18.3.0-canary-b8da12e8f-20240229"
92069206
};
92079207
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
92089208
var hook$jscomp$inline_1196 = __REACT_DEVTOOLS_GLOBAL_HOOK__;

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-profiling.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -9599,7 +9599,7 @@ var devToolsConfig$jscomp$inline_1056 = {
95999599
throw Error("TestRenderer does not support findFiberByHostInstance()");
96009600
},
96019601
bundleType: 0,
9602-
version: "18.3.0-canary-fb10a2c66-20240228",
9602+
version: "18.3.0-canary-b8da12e8f-20240229",
96039603
rendererPackageName: "react-test-renderer"
96049604
};
96059605
var internals$jscomp$inline_1236 = {
@@ -9630,7 +9630,7 @@ var internals$jscomp$inline_1236 = {
96309630
scheduleRoot: null,
96319631
setRefreshHandler: null,
96329632
getCurrentFiber: null,
9633-
reconcilerVersion: "18.3.0-canary-fb10a2c66-20240228"
9633+
reconcilerVersion: "18.3.0-canary-b8da12e8f-20240229"
96349634
};
96359635
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
96369636
var hook$jscomp$inline_1237 = __REACT_DEVTOOLS_GLOBAL_HOOK__;

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ if (__DEV__) {
2626
}
2727
var dynamicFlags = require("ReactNativeInternalFeatureFlags");
2828

29-
var ReactVersion = "18.3.0-canary-fb10a2c66-20240228";
29+
var ReactVersion = "18.3.0-canary-b8da12e8f-20240229";
3030

3131
// ATTENTION
3232
// When adding new symbols to this file,

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -598,4 +598,4 @@ exports.useSyncExternalStore = function (
598598
exports.useTransition = function () {
599599
return ReactCurrentDispatcher.current.useTransition();
600600
};
601-
exports.version = "18.3.0-canary-fb10a2c66-20240228";
601+
exports.version = "18.3.0-canary-b8da12e8f-20240229";

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ exports.useSyncExternalStore = function (
594594
exports.useTransition = function () {
595595
return ReactCurrentDispatcher.current.useTransition();
596596
};
597-
exports.version = "18.3.0-canary-fb10a2c66-20240228";
597+
exports.version = "18.3.0-canary-b8da12e8f-20240229";
598598
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
599599
"function" ===
600600
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
fb10a2c66a923d218471b535fdaf0dbc530417ee
1+
b8da12e8f8e6a6b087f6531c1c791ab41e5273d4

compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js

+54-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<cfbc1c43d4da5c44f22471790ecd61bf>>
10+
* @generated SignedSource<<a30628fd998018c262d2437b0c9edc0e>>
1111
*/
1212

1313
"use strict";
@@ -3238,7 +3238,9 @@ to return true:wantsResponderID| |
32383238
dynamicFlags.passChildrenWhenCloningPersistedNodes,
32393239
useMicrotasksForSchedulingInFabric =
32403240
dynamicFlags.useMicrotasksForSchedulingInFabric,
3241-
enableUnifiedSyncLane = dynamicFlags.enableUnifiedSyncLane; // The rest of the flags are static for better dead code elimination.
3241+
enableUnifiedSyncLane = dynamicFlags.enableUnifiedSyncLane,
3242+
enableInfiniteRenderLoopDetection =
3243+
dynamicFlags.enableInfiniteRenderLoopDetection; // The rest of the flags are static for better dead code elimination.
32423244
var enableSchedulingProfiler = true;
32433245
var enableProfilerTimer = true;
32443246
var enableProfilerCommitHooks = true;
@@ -23748,6 +23750,10 @@ to return true:wantsResponderID| |
2374823750
var workInProgressRootRecoverableErrors = null; // Tracks when an update occurs during the render phase.
2374923751

2375023752
var workInProgressRootDidIncludeRecursiveRenderUpdate = false; // Thacks when an update occurs during the commit phase. It's a separate
23753+
// variable from the one for renders because the commit phase may run
23754+
// concurrently to a render phase.
23755+
23756+
var didIncludeCommitPhaseUpdate = false; // The most recent time we either committed a fallback, or when a fallback was
2375123757
// filled in with the resolved UI. This lets us throttle the appearance of new
2375223758
// content as it streams in, to minimize jank.
2375323759
// TODO: Think of a better name for this variable?
@@ -24439,10 +24445,36 @@ to return true:wantsResponderID| |
2443924445

2444024446
function markRootUpdated(root, updatedLanes) {
2444124447
markRootUpdated$1(root, updatedLanes);
24448+
24449+
if (enableInfiniteRenderLoopDetection) {
24450+
// Check for recursive updates
24451+
if (executionContext & RenderContext) {
24452+
workInProgressRootDidIncludeRecursiveRenderUpdate = true;
24453+
} else if (executionContext & CommitContext) {
24454+
didIncludeCommitPhaseUpdate = true;
24455+
}
24456+
24457+
throwIfInfiniteUpdateLoopDetected();
24458+
}
2444224459
}
2444324460

2444424461
function markRootPinged(root, pingedLanes) {
2444524462
markRootPinged$1(root, pingedLanes);
24463+
24464+
if (enableInfiniteRenderLoopDetection) {
24465+
// Check for recursive pings. Pings are conceptually different from updates in
24466+
// other contexts but we call it an "update" in this context because
24467+
// repeatedly pinging a suspended render can cause a recursive render loop.
24468+
// The relevant property is that it can result in a new render attempt
24469+
// being scheduled.
24470+
if (executionContext & RenderContext) {
24471+
workInProgressRootDidIncludeRecursiveRenderUpdate = true;
24472+
} else if (executionContext & CommitContext) {
24473+
didIncludeCommitPhaseUpdate = true;
24474+
}
24475+
24476+
throwIfInfiniteUpdateLoopDetected();
24477+
}
2444624478
}
2444724479

2444824480
function markRootSuspended(root, suspendedLanes, spawnedLane) {
@@ -25796,6 +25828,8 @@ to return true:wantsResponderID| |
2579625828
remainingLanes = mergeLanes(remainingLanes, concurrentlyUpdatedLanes);
2579725829
markRootFinished(root, remainingLanes, spawnedLane); // Reset this before firing side effects so we can detect recursive updates.
2579825830

25831+
didIncludeCommitPhaseUpdate = false;
25832+
2579925833
if (root === workInProgressRoot) {
2580025834
// We can reset these now that they are finished.
2580125835
workInProgressRoot = null;
@@ -25987,9 +26021,10 @@ to return true:wantsResponderID| |
2598726021
// Check if there was a recursive update spawned by this render, in either
2598826022
// the render phase or the commit phase. We track these explicitly because
2598926023
// we can't infer from the remaining lanes alone.
25990-
// Was the finished render the result of an update (not hydration)?
25991-
includesSomeLane(lanes, UpdateLanes) && // Did it schedule a sync update?
25992-
includesSomeLane(remainingLanes, SyncUpdateLanes)
26024+
(enableInfiniteRenderLoopDetection &&
26025+
(didIncludeRenderPhaseUpdate || didIncludeCommitPhaseUpdate)) || // Was the finished render the result of an update (not hydration)?
26026+
(includesSomeLane(lanes, UpdateLanes) && // Did it schedule a sync update?
26027+
includesSomeLane(remainingLanes, SyncUpdateLanes))
2599326028
) {
2599426029
{
2599526030
markNestedUpdateScheduled();
@@ -26422,6 +26457,19 @@ to return true:wantsResponderID| |
2642226457
rootWithNestedUpdates = null;
2642326458
rootWithPassiveNestedUpdates = null;
2642426459

26460+
if (enableInfiniteRenderLoopDetection) {
26461+
if (executionContext & RenderContext && workInProgressRoot !== null) {
26462+
// We're in the render phase. Disable the concurrent error recovery
26463+
// mechanism to ensure that the error we're about to throw gets handled.
26464+
// We need it to trigger the nearest error boundary so that the infinite
26465+
// update loop is broken.
26466+
workInProgressRoot.errorRecoveryDisabledLanes = mergeLanes(
26467+
workInProgressRoot.errorRecoveryDisabledLanes,
26468+
workInProgressRootRenderLanes
26469+
);
26470+
}
26471+
}
26472+
2642526473
throw new Error(
2642626474
"Maximum update depth exceeded. This can happen when a component " +
2642726475
"repeatedly calls setState inside componentWillUpdate or " +
@@ -28042,7 +28090,7 @@ to return true:wantsResponderID| |
2804228090
return root;
2804328091
}
2804428092

28045-
var ReactVersion = "18.3.0-canary-26c89f2f";
28093+
var ReactVersion = "18.3.0-canary-b1191c0d";
2804628094

2804728095
function createPortal$1(
2804828096
children,

0 commit comments

Comments
 (0)