Skip to content

Commit

Permalink
Add dynamic flag for infinite loop detection on React Native FB (#28456)
Browse files Browse the repository at this point in the history
Add dynamic flag for infinite loop detection on React Native FB

DiffTrain build for commit b8da12e.
  • Loading branch information
kassens committed Feb 29, 2024
1 parent 4942d00 commit 02ba30a
Show file tree
Hide file tree
Showing 13 changed files with 407 additions and 231 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25735,7 +25735,7 @@ if (__DEV__) {
return root;
}

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

// Might add PROFILE later.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9171,7 +9171,7 @@ var devToolsConfig$jscomp$inline_1014 = {
throw Error("TestRenderer does not support findFiberByHostInstance()");
},
bundleType: 0,
version: "18.3.0-canary-fb10a2c66-20240228",
version: "18.3.0-canary-b8da12e8f-20240229",
rendererPackageName: "react-test-renderer"
};
var internals$jscomp$inline_1195 = {
Expand Down Expand Up @@ -9202,7 +9202,7 @@ var internals$jscomp$inline_1195 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-canary-fb10a2c66-20240228"
reconcilerVersion: "18.3.0-canary-b8da12e8f-20240229"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1196 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9599,7 +9599,7 @@ var devToolsConfig$jscomp$inline_1056 = {
throw Error("TestRenderer does not support findFiberByHostInstance()");
},
bundleType: 0,
version: "18.3.0-canary-fb10a2c66-20240228",
version: "18.3.0-canary-b8da12e8f-20240229",
rendererPackageName: "react-test-renderer"
};
var internals$jscomp$inline_1236 = {
Expand Down Expand Up @@ -9630,7 +9630,7 @@ var internals$jscomp$inline_1236 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-canary-fb10a2c66-20240228"
reconcilerVersion: "18.3.0-canary-b8da12e8f-20240229"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1237 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ if (__DEV__) {
}
var dynamicFlags = require("ReactNativeInternalFeatureFlags");

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

// ATTENTION
// When adding new symbols to this file,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -598,4 +598,4 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactCurrentDispatcher.current.useTransition();
};
exports.version = "18.3.0-canary-fb10a2c66-20240228";
exports.version = "18.3.0-canary-b8da12e8f-20240229";
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactCurrentDispatcher.current.useTransition();
};
exports.version = "18.3.0-canary-fb10a2c66-20240228";
exports.version = "18.3.0-canary-b8da12e8f-20240229";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
fb10a2c66a923d218471b535fdaf0dbc530417ee
b8da12e8f8e6a6b087f6531c1c791ab41e5273d4
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<cfbc1c43d4da5c44f22471790ecd61bf>>
* @generated SignedSource<<a30628fd998018c262d2437b0c9edc0e>>
*/

"use strict";
Expand Down Expand Up @@ -3238,7 +3238,9 @@ to return true:wantsResponderID| |
dynamicFlags.passChildrenWhenCloningPersistedNodes,
useMicrotasksForSchedulingInFabric =
dynamicFlags.useMicrotasksForSchedulingInFabric,
enableUnifiedSyncLane = dynamicFlags.enableUnifiedSyncLane; // The rest of the flags are static for better dead code elimination.
enableUnifiedSyncLane = dynamicFlags.enableUnifiedSyncLane,
enableInfiniteRenderLoopDetection =
dynamicFlags.enableInfiniteRenderLoopDetection; // The rest of the flags are static for better dead code elimination.
var enableSchedulingProfiler = true;
var enableProfilerTimer = true;
var enableProfilerCommitHooks = true;
Expand Down Expand Up @@ -23748,6 +23750,10 @@ to return true:wantsResponderID| |
var workInProgressRootRecoverableErrors = null; // Tracks when an update occurs during the render phase.

var workInProgressRootDidIncludeRecursiveRenderUpdate = false; // Thacks when an update occurs during the commit phase. It's a separate
// variable from the one for renders because the commit phase may run
// concurrently to a render phase.

var didIncludeCommitPhaseUpdate = false; // The most recent time we either committed a fallback, or when a fallback was
// filled in with the resolved UI. This lets us throttle the appearance of new
// content as it streams in, to minimize jank.
// TODO: Think of a better name for this variable?
Expand Down Expand Up @@ -24439,10 +24445,36 @@ to return true:wantsResponderID| |

function markRootUpdated(root, updatedLanes) {
markRootUpdated$1(root, updatedLanes);

if (enableInfiniteRenderLoopDetection) {
// Check for recursive updates
if (executionContext & RenderContext) {
workInProgressRootDidIncludeRecursiveRenderUpdate = true;
} else if (executionContext & CommitContext) {
didIncludeCommitPhaseUpdate = true;
}

throwIfInfiniteUpdateLoopDetected();
}
}

function markRootPinged(root, pingedLanes) {
markRootPinged$1(root, pingedLanes);

if (enableInfiniteRenderLoopDetection) {
// Check for recursive pings. Pings are conceptually different from updates in
// other contexts but we call it an "update" in this context because
// repeatedly pinging a suspended render can cause a recursive render loop.
// The relevant property is that it can result in a new render attempt
// being scheduled.
if (executionContext & RenderContext) {
workInProgressRootDidIncludeRecursiveRenderUpdate = true;
} else if (executionContext & CommitContext) {
didIncludeCommitPhaseUpdate = true;
}

throwIfInfiniteUpdateLoopDetected();
}
}

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

didIncludeCommitPhaseUpdate = false;

if (root === workInProgressRoot) {
// We can reset these now that they are finished.
workInProgressRoot = null;
Expand Down Expand Up @@ -25987,9 +26021,10 @@ to return true:wantsResponderID| |
// Check if there was a recursive update spawned by this render, in either
// the render phase or the commit phase. We track these explicitly because
// we can't infer from the remaining lanes alone.
// Was the finished render the result of an update (not hydration)?
includesSomeLane(lanes, UpdateLanes) && // Did it schedule a sync update?
includesSomeLane(remainingLanes, SyncUpdateLanes)
(enableInfiniteRenderLoopDetection &&
(didIncludeRenderPhaseUpdate || didIncludeCommitPhaseUpdate)) || // Was the finished render the result of an update (not hydration)?
(includesSomeLane(lanes, UpdateLanes) && // Did it schedule a sync update?
includesSomeLane(remainingLanes, SyncUpdateLanes))
) {
{
markNestedUpdateScheduled();
Expand Down Expand Up @@ -26422,6 +26457,19 @@ to return true:wantsResponderID| |
rootWithNestedUpdates = null;
rootWithPassiveNestedUpdates = null;

if (enableInfiniteRenderLoopDetection) {
if (executionContext & RenderContext && workInProgressRoot !== null) {
// We're in the render phase. Disable the concurrent error recovery
// mechanism to ensure that the error we're about to throw gets handled.
// We need it to trigger the nearest error boundary so that the infinite
// update loop is broken.
workInProgressRoot.errorRecoveryDisabledLanes = mergeLanes(
workInProgressRoot.errorRecoveryDisabledLanes,
workInProgressRootRenderLanes
);
}
}

throw new Error(
"Maximum update depth exceeded. This can happen when a component " +
"repeatedly calls setState inside componentWillUpdate or " +
Expand Down Expand Up @@ -28042,7 +28090,7 @@ to return true:wantsResponderID| |
return root;
}

var ReactVersion = "18.3.0-canary-26c89f2f";
var ReactVersion = "18.3.0-canary-b1191c0d";

function createPortal$1(
children,
Expand Down
Loading

0 comments on commit 02ba30a

Please sign in to comment.