diff --git a/Libraries/Renderer/REVISION b/Libraries/Renderer/REVISION index 17eb2e29b65732..016e80ab3d1e11 100644 --- a/Libraries/Renderer/REVISION +++ b/Libraries/Renderer/REVISION @@ -1 +1 @@ -c96b78e0e7cd9e6ef7c0464748a50cf8510dde81 \ No newline at end of file +568dc3532e25b30eee5072de08503b1bbc4f065d \ No newline at end of file diff --git a/Libraries/Renderer/implementations/ReactFabric-dev.fb.js b/Libraries/Renderer/implementations/ReactFabric-dev.fb.js index 2e0727f74e6482..c3fc0ca6e0e596 100644 --- a/Libraries/Renderer/implementations/ReactFabric-dev.fb.js +++ b/Libraries/Renderer/implementations/ReactFabric-dev.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<<5e044cc6ca6afb37524e2b0f1b24bab5>> */ 'use strict'; @@ -2841,6 +2841,7 @@ function getComponentNameFromFiber(fiber) { // The rest of the flags are static for better dead code elimination. var enableProfilerTimer = true; +var enableProfilerCommitHooks = true; var enableLazyElements = false; var warnAboutStringRefs = false; var enableNewReconciler = false; @@ -3215,20 +3216,6 @@ function findCurrentHostFiberImpl(node) { return null; } -function doesFiberContain(parentFiber, childFiber) { - var node = childFiber; - var parentFiberAlternate = parentFiber.alternate; - - while (node !== null) { - if (node === parentFiber || node === parentFiberAlternate) { - return true; - } - - node = node.return; - } - - return false; -} /** * In the future, we should cleanup callbacks by cancelling them instead of @@ -5872,7 +5859,7 @@ var Passive$1 = /* */ 4; -var ReactVersion = "18.0.0-c96b78e0e"; +var ReactVersion = "18.0.0-568dc3532"; var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig; var NoTransition = 0; @@ -17021,19 +17008,10 @@ function safelyCallComponentWillUnmount( nearestMountedAncestor, instance ) { - { - invokeGuardedCallback( - null, - callComponentWillUnmountWithTimer, - null, - current, - instance - ); - - if (hasCaughtError()) { - var unmountError = clearCaughtError(); - captureCommitPhaseError(current, nearestMountedAncestor, unmountError); - } + try { + callComponentWillUnmountWithTimer(current, instance); + } catch (unmountError) { + captureCommitPhaseError(current, nearestMountedAncestor, unmountError); } } // Capture errors so they don't interrupt mounting. @@ -17042,19 +17020,23 @@ function safelyDetachRef(current, nearestMountedAncestor) { if (ref !== null) { if (typeof ref === "function") { - { - if (current.mode & ProfileMode) { - startLayoutEffectTimer(); - invokeGuardedCallback(null, ref, null, null); - recordLayoutEffectDuration(current); + try { + if ( + enableProfilerTimer && + enableProfilerCommitHooks && + current.mode & ProfileMode + ) { + try { + startLayoutEffectTimer(); + ref(null); + } finally { + recordLayoutEffectDuration(current); + } } else { - invokeGuardedCallback(null, ref, null, null); - } - - if (hasCaughtError()) { - var refError = clearCaughtError(); - captureCommitPhaseError(current, nearestMountedAncestor, refError); + ref(null); } + } catch (error) { + captureCommitPhaseError(current, nearestMountedAncestor, error); } } else { ref.current = null; @@ -17063,13 +17045,10 @@ function safelyDetachRef(current, nearestMountedAncestor) { } function safelyCallDestroy(current, nearestMountedAncestor, destroy) { - { - invokeGuardedCallback(null, destroy, null); - - if (hasCaughtError()) { - var error = clearCaughtError(); - captureCommitPhaseError(current, nearestMountedAncestor, error); - } + try { + destroy(); + } catch (error) { + captureCommitPhaseError(current, nearestMountedAncestor, error); } } @@ -17088,16 +17067,7 @@ function commitBeforeMutationEffects(root, firstChild) { function commitBeforeMutationEffects_begin() { while (nextEffect !== null) { - var fiber = nextEffect; // TODO: Should wrap this in flags check, too, as optimization - - var deletions = fiber.deletions; - - if (deletions !== null) { - for (var i = 0; i < deletions.length; i++) { - var deletion = deletions[i]; - commitBeforeMutationEffectsDeletion(deletion); - } - } + var fiber = nextEffect; // This phase is only used for beforeActiveInstanceBlur. var child = fiber.child; @@ -17116,24 +17086,15 @@ function commitBeforeMutationEffects_begin() { function commitBeforeMutationEffects_complete() { while (nextEffect !== null) { var fiber = nextEffect; + setCurrentFiber(fiber); - { - setCurrentFiber(fiber); - invokeGuardedCallback( - null, - commitBeforeMutationEffectsOnFiber, - null, - fiber - ); - - if (hasCaughtError()) { - var error = clearCaughtError(); - captureCommitPhaseError(fiber, fiber.return, error); - } - - resetCurrentFiber(); + try { + commitBeforeMutationEffectsOnFiber(fiber); + } catch (error) { + captureCommitPhaseError(fiber, fiber.return, error); } + resetCurrentFiber(); var sibling = fiber.sibling; if (sibling !== null) { @@ -17150,18 +17111,6 @@ function commitBeforeMutationEffectsOnFiber(finishedWork) { var current = finishedWork.alternate; var flags = finishedWork.flags; - if (!shouldFireAfterActiveInstanceBlur && focusedInstanceHandle !== null) { - // Check to see if the focused element was inside of a hidden (Suspense) subtree. - // TODO: Move this out of the hot path using a dedicated effect tag. - if ( - finishedWork.tag === SuspenseComponent && - isSuspenseBoundaryBeingHidden(current, finishedWork) && - doesFiberContain(finishedWork, focusedInstanceHandle) - ) { - shouldFireAfterActiveInstanceBlur = true; - } - } - if ((flags & Snapshot) !== NoFlags) { setCurrentFiber(finishedWork); @@ -17260,16 +17209,6 @@ function commitBeforeMutationEffectsOnFiber(finishedWork) { } } -function commitBeforeMutationEffectsDeletion(deletion) { - // TODO (effects) It would be nice to avoid calling doesFiberContain() - // Maybe we can repurpose one of the subtreeFlags positions for this instead? - // Use it to store which part of the tree the focused instance is in? - // This assumes we can safely determine that instance during the "render" phase. - if (doesFiberContain(deletion, focusedInstanceHandle)) { - shouldFireAfterActiveInstanceBlur = true; - } -} - function commitHookEffectListUnmount( flags, finishedWork, @@ -17947,20 +17886,50 @@ function detachFiberAfterEffects(fiber) { // `deletedTreeCleanUpLevel` is undefined. { - // This is the default branch (level 0). + // Clear cyclical Fiber fields. This level alone is designed to roughly + // approximate the planned Fiber refactor. In that world, `setState` will be + // bound to a special "instance" object instead of a Fiber. The Instance + // object will not have any of these fields. It will only be connected to + // the fiber tree via a single link at the root. So if this level alone is + // sufficient to fix memory issues, that bodes well for our plans. fiber.child = null; fiber.deletions = null; - fiber.dependencies = null; - fiber.memoizedProps = null; - fiber.memoizedState = null; - fiber.pendingProps = null; - fiber.sibling = null; - fiber.stateNode = null; - fiber.updateQueue = null; + fiber.sibling = null; // The `stateNode` is cyclical because on host nodes it points to the host + // tree, which has its own pointers to children, parents, and siblings. + // The other host nodes also point back to fibers, so we should detach that + // one, too. + + if (fiber.tag === HostComponent) { + var hostInstance = fiber.stateNode; + } + + fiber.stateNode = null; // I'm intentionally not clearing the `return` field in this level. We + // already disconnect the `return` pointer at the root of the deleted + // subtree (in `detachFiberMutation`). Besides, `return` by itself is not + // cyclical — it's only cyclical when combined with `child`, `sibling`, and + // `alternate`. But we'll clear it in the next level anyway, just in case. { fiber._debugOwner = null; } + + { + // Theoretically, nothing in here should be necessary, because we already + // disconnected the fiber from the tree. So even if something leaks this + // particular fiber, it won't leak anything else + // + // The purpose of this branch is to be super aggressive so we can measure + // if there's any difference in memory impact. If there is, that could + // indicate a React leak we don't know about. + fiber.return = null; + fiber.dependencies = null; + fiber.memoizedProps = null; + fiber.memoizedState = null; + fiber.pendingProps = null; + fiber.stateNode = null; // TODO: Move to `commitPassiveUnmountInsideDeletedTreeOnFiber` instead. + + fiber.updateQueue = null; + } } } @@ -18114,21 +18083,6 @@ function attachSuspenseRetryListeners(finishedWork) { }); } } // This function detects when a Suspense boundary goes from visible to hidden. -// It returns false if the boundary is already hidden. -// TODO: Use an effect tag. - -function isSuspenseBoundaryBeingHidden(current, finishedWork) { - if (current !== null) { - var oldState = current.memoizedState; - - if (oldState === null || oldState.dehydrated !== null) { - var newState = finishedWork.memoizedState; - return newState !== null && newState.dehydrated === null; - } - } - - return false; -} function commitMutationEffects(root, firstChild, committedLanes) { inProgressLanes = committedLanes; @@ -18149,20 +18103,10 @@ function commitMutationEffects_begin(root) { for (var i = 0; i < deletions.length; i++) { var childToDelete = deletions[i]; - { - invokeGuardedCallback( - null, - commitDeletion, - null, - root, - childToDelete, - fiber - ); - - if (hasCaughtError()) { - var error = clearCaughtError(); - captureCommitPhaseError(childToDelete, fiber, error); - } + try { + commitDeletion(root, childToDelete, fiber); + } catch (error) { + captureCommitPhaseError(childToDelete, fiber, error); } } } @@ -18181,25 +18125,15 @@ function commitMutationEffects_begin(root) { function commitMutationEffects_complete(root) { while (nextEffect !== null) { var fiber = nextEffect; + setCurrentFiber(fiber); - { - setCurrentFiber(fiber); - invokeGuardedCallback( - null, - commitMutationEffectsOnFiber, - null, - fiber, - root - ); - - if (hasCaughtError()) { - var error = clearCaughtError(); - captureCommitPhaseError(fiber, fiber.return, error); - } - - resetCurrentFiber(); + try { + commitMutationEffectsOnFiber(fiber, root); + } catch (error) { + captureCommitPhaseError(fiber, fiber.return, error); } + resetCurrentFiber(); var sibling = fiber.sibling; if (sibling !== null) { @@ -18304,26 +18238,15 @@ function commitLayoutMountEffects_complete(subtreeRoot, root, committedLanes) { if ((fiber.flags & LayoutMask) !== NoFlags) { var current = fiber.alternate; + setCurrentFiber(fiber); - { - setCurrentFiber(fiber); - invokeGuardedCallback( - null, - commitLayoutEffectOnFiber, - null, - root, - current, - fiber, - committedLanes - ); - - if (hasCaughtError()) { - var error = clearCaughtError(); - captureCommitPhaseError(fiber, fiber.return, error); - } - - resetCurrentFiber(); + try { + commitLayoutEffectOnFiber(root, current, fiber, committedLanes); + } catch (error) { + captureCommitPhaseError(fiber, fiber.return, error); } + + resetCurrentFiber(); } if (fiber === subtreeRoot) { @@ -18367,23 +18290,15 @@ function commitPassiveMountEffects_complete(subtreeRoot, root) { var fiber = nextEffect; if ((fiber.flags & Passive) !== NoFlags) { - { - setCurrentFiber(fiber); - invokeGuardedCallback( - null, - commitPassiveMountOnFiber, - null, - root, - fiber - ); - - if (hasCaughtError()) { - var error = clearCaughtError(); - captureCommitPhaseError(fiber, fiber.return, error); - } + setCurrentFiber(fiber); - resetCurrentFiber(); + try { + commitPassiveMountOnFiber(root, fiber); + } catch (error) { + captureCommitPhaseError(fiber, fiber.return, error); } + + resetCurrentFiber(); } if (fiber === subtreeRoot) { @@ -18572,10 +18487,12 @@ function commitPassiveUnmountEffectsInsideOfDeletedTree_complete( var returnFiber = fiber.return; { - // This is the default branch (level 0). We do not recursively clear all - // the fiber fields. Only the root of the deleted subtree. + // Recursively traverse the entire deleted tree and clean up fiber fields. + // This is more aggressive than ideal, and the long term goal is to only + // have to detach the deleted tree at the root. + detachFiberAfterEffects(fiber); + if (fiber === deletedSubtreeRoot) { - detachFiberAfterEffects(fiber); nextEffect = null; return; } @@ -18637,17 +18554,10 @@ function invokeLayoutEffectMountInDEV(fiber) { case FunctionComponent: case ForwardRef: case SimpleMemoComponent: { - invokeGuardedCallback( - null, - commitHookEffectListMount, - null, - Layout | HasEffect, - fiber - ); - - if (hasCaughtError()) { - var mountError = clearCaughtError(); - captureCommitPhaseError(fiber, fiber.return, mountError); + try { + commitHookEffectListMount(Layout | HasEffect, fiber); + } catch (error) { + captureCommitPhaseError(fiber, fiber.return, error); } break; @@ -18655,12 +18565,11 @@ function invokeLayoutEffectMountInDEV(fiber) { case ClassComponent: { var instance = fiber.stateNode; - invokeGuardedCallback(null, instance.componentDidMount, instance); - - if (hasCaughtError()) { - var _mountError = clearCaughtError(); - captureCommitPhaseError(fiber, fiber.return, _mountError); + try { + instance.componentDidMount(); + } catch (error) { + captureCommitPhaseError(fiber, fiber.return, error); } break; @@ -18677,17 +18586,10 @@ function invokePassiveEffectMountInDEV(fiber) { case FunctionComponent: case ForwardRef: case SimpleMemoComponent: { - invokeGuardedCallback( - null, - commitHookEffectListMount, - null, - Passive$1 | HasEffect, - fiber - ); - - if (hasCaughtError()) { - var mountError = clearCaughtError(); - captureCommitPhaseError(fiber, fiber.return, mountError); + try { + commitHookEffectListMount(Passive$1 | HasEffect, fiber); + } catch (error) { + captureCommitPhaseError(fiber, fiber.return, error); } break; @@ -18704,18 +18606,10 @@ function invokeLayoutEffectUnmountInDEV(fiber) { case FunctionComponent: case ForwardRef: case SimpleMemoComponent: { - invokeGuardedCallback( - null, - commitHookEffectListUnmount, - null, - Layout | HasEffect, - fiber, - fiber.return - ); - - if (hasCaughtError()) { - var unmountError = clearCaughtError(); - captureCommitPhaseError(fiber, fiber.return, unmountError); + try { + commitHookEffectListUnmount(Layout | HasEffect, fiber, fiber.return); + } catch (error) { + captureCommitPhaseError(fiber, fiber.return, error); } break; @@ -18725,20 +18619,7 @@ function invokeLayoutEffectUnmountInDEV(fiber) { var instance = fiber.stateNode; if (typeof instance.componentWillUnmount === "function") { - invokeGuardedCallback( - null, - safelyCallComponentWillUnmount, - null, - fiber, - fiber.return, - instance - ); - - if (hasCaughtError()) { - var _unmountError = clearCaughtError(); - - captureCommitPhaseError(fiber, fiber.return, _unmountError); - } + safelyCallComponentWillUnmount(fiber, fiber.return, instance); } break; @@ -18755,21 +18636,15 @@ function invokePassiveEffectUnmountInDEV(fiber) { case FunctionComponent: case ForwardRef: case SimpleMemoComponent: { - invokeGuardedCallback( - null, - commitHookEffectListUnmount, - null, - Passive$1 | HasEffect, - fiber, - fiber.return - ); - - if (hasCaughtError()) { - var unmountError = clearCaughtError(); - captureCommitPhaseError(fiber, fiber.return, unmountError); + try { + commitHookEffectListUnmount( + Passive$1 | HasEffect, + fiber, + fiber.return + ); + } catch (error) { + captureCommitPhaseError(fiber, fiber.return, error); } - - break; } } } diff --git a/Libraries/Renderer/implementations/ReactFabric-dev.js b/Libraries/Renderer/implementations/ReactFabric-dev.js index c34704311e0170..c668e0af34777e 100644 --- a/Libraries/Renderer/implementations/ReactFabric-dev.js +++ b/Libraries/Renderer/implementations/ReactFabric-dev.js @@ -8,7 +8,7 @@ * @nolint * @providesModule ReactFabric-dev * @preventMunge - * @generated SignedSource<<802b2fe3c3332e7eea4d369034929b93>> + * @generated SignedSource<> */ 'use strict'; @@ -2841,6 +2841,7 @@ function getComponentNameFromFiber(fiber) { } var enableProfilerTimer = true; +var enableProfilerCommitHooks = true; var enableLazyElements = false; var warnAboutStringRefs = false; var enableNewReconciler = false; @@ -3206,20 +3207,6 @@ function findCurrentHostFiberImpl(node) { return null; } -function doesFiberContain(parentFiber, childFiber) { - var node = childFiber; - var parentFiberAlternate = parentFiber.alternate; - - while (node !== null) { - if (node === parentFiber || node === parentFiberAlternate) { - return true; - } - - node = node.return; - } - - return false; -} /** * In the future, we should cleanup callbacks by cancelling them instead of @@ -5754,7 +5741,7 @@ var Passive$1 = /* */ 4; -var ReactVersion = "18.0.0-c96b78e0e"; +var ReactVersion = "18.0.0-568dc3532"; var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig; var NoTransition = 0; @@ -16744,19 +16731,10 @@ function safelyCallComponentWillUnmount( nearestMountedAncestor, instance ) { - { - invokeGuardedCallback( - null, - callComponentWillUnmountWithTimer, - null, - current, - instance - ); - - if (hasCaughtError()) { - var unmountError = clearCaughtError(); - captureCommitPhaseError(current, nearestMountedAncestor, unmountError); - } + try { + callComponentWillUnmountWithTimer(current, instance); + } catch (unmountError) { + captureCommitPhaseError(current, nearestMountedAncestor, unmountError); } } // Capture errors so they don't interrupt mounting. @@ -16765,19 +16743,23 @@ function safelyDetachRef(current, nearestMountedAncestor) { if (ref !== null) { if (typeof ref === "function") { - { - if (current.mode & ProfileMode) { - startLayoutEffectTimer(); - invokeGuardedCallback(null, ref, null, null); - recordLayoutEffectDuration(current); + try { + if ( + enableProfilerTimer && + enableProfilerCommitHooks && + current.mode & ProfileMode + ) { + try { + startLayoutEffectTimer(); + ref(null); + } finally { + recordLayoutEffectDuration(current); + } } else { - invokeGuardedCallback(null, ref, null, null); - } - - if (hasCaughtError()) { - var refError = clearCaughtError(); - captureCommitPhaseError(current, nearestMountedAncestor, refError); + ref(null); } + } catch (error) { + captureCommitPhaseError(current, nearestMountedAncestor, error); } } else { ref.current = null; @@ -16786,13 +16768,10 @@ function safelyDetachRef(current, nearestMountedAncestor) { } function safelyCallDestroy(current, nearestMountedAncestor, destroy) { - { - invokeGuardedCallback(null, destroy, null); - - if (hasCaughtError()) { - var error = clearCaughtError(); - captureCommitPhaseError(current, nearestMountedAncestor, error); - } + try { + destroy(); + } catch (error) { + captureCommitPhaseError(current, nearestMountedAncestor, error); } } @@ -16811,16 +16790,7 @@ function commitBeforeMutationEffects(root, firstChild) { function commitBeforeMutationEffects_begin() { while (nextEffect !== null) { - var fiber = nextEffect; // TODO: Should wrap this in flags check, too, as optimization - - var deletions = fiber.deletions; - - if (deletions !== null) { - for (var i = 0; i < deletions.length; i++) { - var deletion = deletions[i]; - commitBeforeMutationEffectsDeletion(deletion); - } - } + var fiber = nextEffect; // This phase is only used for beforeActiveInstanceBlur. var child = fiber.child; @@ -16839,24 +16809,15 @@ function commitBeforeMutationEffects_begin() { function commitBeforeMutationEffects_complete() { while (nextEffect !== null) { var fiber = nextEffect; + setCurrentFiber(fiber); - { - setCurrentFiber(fiber); - invokeGuardedCallback( - null, - commitBeforeMutationEffectsOnFiber, - null, - fiber - ); - - if (hasCaughtError()) { - var error = clearCaughtError(); - captureCommitPhaseError(fiber, fiber.return, error); - } - - resetCurrentFiber(); + try { + commitBeforeMutationEffectsOnFiber(fiber); + } catch (error) { + captureCommitPhaseError(fiber, fiber.return, error); } + resetCurrentFiber(); var sibling = fiber.sibling; if (sibling !== null) { @@ -16873,18 +16834,6 @@ function commitBeforeMutationEffectsOnFiber(finishedWork) { var current = finishedWork.alternate; var flags = finishedWork.flags; - if (!shouldFireAfterActiveInstanceBlur && focusedInstanceHandle !== null) { - // Check to see if the focused element was inside of a hidden (Suspense) subtree. - // TODO: Move this out of the hot path using a dedicated effect tag. - if ( - finishedWork.tag === SuspenseComponent && - isSuspenseBoundaryBeingHidden(current, finishedWork) && - doesFiberContain(finishedWork, focusedInstanceHandle) - ) { - shouldFireAfterActiveInstanceBlur = true; - } - } - if ((flags & Snapshot) !== NoFlags) { setCurrentFiber(finishedWork); @@ -16983,16 +16932,6 @@ function commitBeforeMutationEffectsOnFiber(finishedWork) { } } -function commitBeforeMutationEffectsDeletion(deletion) { - // TODO (effects) It would be nice to avoid calling doesFiberContain() - // Maybe we can repurpose one of the subtreeFlags positions for this instead? - // Use it to store which part of the tree the focused instance is in? - // This assumes we can safely determine that instance during the "render" phase. - if (doesFiberContain(deletion, focusedInstanceHandle)) { - shouldFireAfterActiveInstanceBlur = true; - } -} - function commitHookEffectListUnmount( flags, finishedWork, @@ -17670,20 +17609,50 @@ function detachFiberAfterEffects(fiber) { // `deletedTreeCleanUpLevel` is undefined. { - // This is the default branch (level 0). + // Clear cyclical Fiber fields. This level alone is designed to roughly + // approximate the planned Fiber refactor. In that world, `setState` will be + // bound to a special "instance" object instead of a Fiber. The Instance + // object will not have any of these fields. It will only be connected to + // the fiber tree via a single link at the root. So if this level alone is + // sufficient to fix memory issues, that bodes well for our plans. fiber.child = null; fiber.deletions = null; - fiber.dependencies = null; - fiber.memoizedProps = null; - fiber.memoizedState = null; - fiber.pendingProps = null; - fiber.sibling = null; - fiber.stateNode = null; - fiber.updateQueue = null; + fiber.sibling = null; // The `stateNode` is cyclical because on host nodes it points to the host + // tree, which has its own pointers to children, parents, and siblings. + // The other host nodes also point back to fibers, so we should detach that + // one, too. + + if (fiber.tag === HostComponent) { + var hostInstance = fiber.stateNode; + } + + fiber.stateNode = null; // I'm intentionally not clearing the `return` field in this level. We + // already disconnect the `return` pointer at the root of the deleted + // subtree (in `detachFiberMutation`). Besides, `return` by itself is not + // cyclical — it's only cyclical when combined with `child`, `sibling`, and + // `alternate`. But we'll clear it in the next level anyway, just in case. { fiber._debugOwner = null; } + + { + // Theoretically, nothing in here should be necessary, because we already + // disconnected the fiber from the tree. So even if something leaks this + // particular fiber, it won't leak anything else + // + // The purpose of this branch is to be super aggressive so we can measure + // if there's any difference in memory impact. If there is, that could + // indicate a React leak we don't know about. + fiber.return = null; + fiber.dependencies = null; + fiber.memoizedProps = null; + fiber.memoizedState = null; + fiber.pendingProps = null; + fiber.stateNode = null; // TODO: Move to `commitPassiveUnmountInsideDeletedTreeOnFiber` instead. + + fiber.updateQueue = null; + } } } @@ -17837,21 +17806,6 @@ function attachSuspenseRetryListeners(finishedWork) { }); } } // This function detects when a Suspense boundary goes from visible to hidden. -// It returns false if the boundary is already hidden. -// TODO: Use an effect tag. - -function isSuspenseBoundaryBeingHidden(current, finishedWork) { - if (current !== null) { - var oldState = current.memoizedState; - - if (oldState === null || oldState.dehydrated !== null) { - var newState = finishedWork.memoizedState; - return newState !== null && newState.dehydrated === null; - } - } - - return false; -} function commitMutationEffects(root, firstChild, committedLanes) { inProgressLanes = committedLanes; @@ -17872,20 +17826,10 @@ function commitMutationEffects_begin(root) { for (var i = 0; i < deletions.length; i++) { var childToDelete = deletions[i]; - { - invokeGuardedCallback( - null, - commitDeletion, - null, - root, - childToDelete, - fiber - ); - - if (hasCaughtError()) { - var error = clearCaughtError(); - captureCommitPhaseError(childToDelete, fiber, error); - } + try { + commitDeletion(root, childToDelete, fiber); + } catch (error) { + captureCommitPhaseError(childToDelete, fiber, error); } } } @@ -17904,25 +17848,15 @@ function commitMutationEffects_begin(root) { function commitMutationEffects_complete(root) { while (nextEffect !== null) { var fiber = nextEffect; + setCurrentFiber(fiber); - { - setCurrentFiber(fiber); - invokeGuardedCallback( - null, - commitMutationEffectsOnFiber, - null, - fiber, - root - ); - - if (hasCaughtError()) { - var error = clearCaughtError(); - captureCommitPhaseError(fiber, fiber.return, error); - } - - resetCurrentFiber(); + try { + commitMutationEffectsOnFiber(fiber, root); + } catch (error) { + captureCommitPhaseError(fiber, fiber.return, error); } + resetCurrentFiber(); var sibling = fiber.sibling; if (sibling !== null) { @@ -18027,26 +17961,15 @@ function commitLayoutMountEffects_complete(subtreeRoot, root, committedLanes) { if ((fiber.flags & LayoutMask) !== NoFlags) { var current = fiber.alternate; + setCurrentFiber(fiber); - { - setCurrentFiber(fiber); - invokeGuardedCallback( - null, - commitLayoutEffectOnFiber, - null, - root, - current, - fiber, - committedLanes - ); - - if (hasCaughtError()) { - var error = clearCaughtError(); - captureCommitPhaseError(fiber, fiber.return, error); - } - - resetCurrentFiber(); + try { + commitLayoutEffectOnFiber(root, current, fiber, committedLanes); + } catch (error) { + captureCommitPhaseError(fiber, fiber.return, error); } + + resetCurrentFiber(); } if (fiber === subtreeRoot) { @@ -18090,23 +18013,15 @@ function commitPassiveMountEffects_complete(subtreeRoot, root) { var fiber = nextEffect; if ((fiber.flags & Passive) !== NoFlags) { - { - setCurrentFiber(fiber); - invokeGuardedCallback( - null, - commitPassiveMountOnFiber, - null, - root, - fiber - ); - - if (hasCaughtError()) { - var error = clearCaughtError(); - captureCommitPhaseError(fiber, fiber.return, error); - } + setCurrentFiber(fiber); - resetCurrentFiber(); + try { + commitPassiveMountOnFiber(root, fiber); + } catch (error) { + captureCommitPhaseError(fiber, fiber.return, error); } + + resetCurrentFiber(); } if (fiber === subtreeRoot) { @@ -18295,10 +18210,12 @@ function commitPassiveUnmountEffectsInsideOfDeletedTree_complete( var returnFiber = fiber.return; { - // This is the default branch (level 0). We do not recursively clear all - // the fiber fields. Only the root of the deleted subtree. + // Recursively traverse the entire deleted tree and clean up fiber fields. + // This is more aggressive than ideal, and the long term goal is to only + // have to detach the deleted tree at the root. + detachFiberAfterEffects(fiber); + if (fiber === deletedSubtreeRoot) { - detachFiberAfterEffects(fiber); nextEffect = null; return; } diff --git a/Libraries/Renderer/implementations/ReactFabric-prod.fb.js b/Libraries/Renderer/implementations/ReactFabric-prod.fb.js index f22af4691d430b..2496f05ced389a 100644 --- a/Libraries/Renderer/implementations/ReactFabric-prod.fb.js +++ b/Libraries/Renderer/implementations/ReactFabric-prod.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<<6765a0c45bce3e794af875a678b9b3fa>> */ "use strict"; @@ -1288,18 +1288,6 @@ function findCurrentHostFiberImpl(node) { } return null; } -function doesFiberContain(parentFiber, childFiber) { - for ( - var parentFiberAlternate = parentFiber.alternate; - null !== childFiber; - - ) { - if (childFiber === parentFiber || childFiber === parentFiberAlternate) - return !0; - childFiber = childFiber.return; - } - return !1; -} function mountSafeCallback_NOT_REALLY_SAFE(context, callback) { return function() { if ( @@ -5516,54 +5504,26 @@ function safelyDetachRef(current, nearestMountedAncestor) { if ("function" === typeof ref) try { ref(null); - } catch (refError) { - captureCommitPhaseError(current, nearestMountedAncestor, refError); + } catch (error) { + captureCommitPhaseError(current, nearestMountedAncestor, error); } else ref.current = null; } -var focusedInstanceHandle = null, - shouldFireAfterActiveInstanceBlur = !1; +var shouldFireAfterActiveInstanceBlur = !1; function commitBeforeMutationEffects(root, firstChild) { - focusedInstanceHandle = null; - for (nextEffect = firstChild; null !== nextEffect; ) { - root = nextEffect; - firstChild = root.deletions; - if (null !== firstChild) - for (var i = 0; i < firstChild.length; i++) - doesFiberContain(firstChild[i], focusedInstanceHandle) && - (shouldFireAfterActiveInstanceBlur = !0); - firstChild = root.child; - if (0 !== (root.subtreeFlags & 516) && null !== firstChild) + for (nextEffect = firstChild; null !== nextEffect; ) + if ( + ((root = nextEffect), + (firstChild = root.child), + 0 !== (root.subtreeFlags & 516) && null !== firstChild) + ) (firstChild.return = root), (nextEffect = firstChild); else for (; null !== nextEffect; ) { root = nextEffect; try { - var current = root.alternate, - flags = root.flags; - if ( - !shouldFireAfterActiveInstanceBlur && - null !== focusedInstanceHandle - ) { - var JSCompiler_temp; - if ((JSCompiler_temp = 13 === root.tag)) - a: { - if (null !== current) { - var oldState = current.memoizedState; - if (null === oldState || null !== oldState.dehydrated) { - var newState = root.memoizedState; - JSCompiler_temp = - null !== newState && null === newState.dehydrated; - break a; - } - } - JSCompiler_temp = !1; - } - JSCompiler_temp && - doesFiberContain(root, focusedInstanceHandle) && - (shouldFireAfterActiveInstanceBlur = !0); - } - if (0 !== (flags & 512)) + var current = root.alternate; + if (0 !== (root.flags & 512)) switch (root.tag) { case 0: case 11: @@ -5606,10 +5566,8 @@ function commitBeforeMutationEffects(root, firstChild) { } nextEffect = root.return; } - } current = shouldFireAfterActiveInstanceBlur; shouldFireAfterActiveInstanceBlur = !1; - focusedInstanceHandle = null; return current; } function commitHookEffectListUnmount( @@ -5659,11 +5617,13 @@ function detachFiberAfterEffects(fiber) { ((fiber.alternate = null), detachFiberAfterEffects(alternate)); fiber.child = null; fiber.deletions = null; + fiber.sibling = null; + fiber.stateNode = null; + fiber.return = null; fiber.dependencies = null; fiber.memoizedProps = null; fiber.memoizedState = null; fiber.pendingProps = null; - fiber.sibling = null; fiber.stateNode = null; fiber.updateQueue = null; } @@ -6785,8 +6745,8 @@ function flushPassiveEffects() { fiber$jscomp$0 = nextEffect; var sibling = fiber$jscomp$0.sibling, returnFiber = fiber$jscomp$0.return; + detachFiberAfterEffects(fiber$jscomp$0); if (fiber$jscomp$0 === fiberToDelete) { - detachFiberAfterEffects(fiber$jscomp$0); nextEffect = null; break; } @@ -7792,10 +7752,10 @@ batchedUpdatesImpl = function(fn, a) { } }; var roots = new Map(), - devToolsConfig$jscomp$inline_942 = { + devToolsConfig$jscomp$inline_939 = { findFiberByHostInstance: getInstanceFromInstance, bundleType: 0, - version: "18.0.0-c96b78e0e", + version: "18.0.0-568dc3532", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function() { @@ -7810,11 +7770,11 @@ var roots = new Map(), }.bind(null, findNodeHandle) } }; -var internals$jscomp$inline_1183 = { - bundleType: devToolsConfig$jscomp$inline_942.bundleType, - version: devToolsConfig$jscomp$inline_942.version, - rendererPackageName: devToolsConfig$jscomp$inline_942.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_942.rendererConfig, +var internals$jscomp$inline_1177 = { + bundleType: devToolsConfig$jscomp$inline_939.bundleType, + version: devToolsConfig$jscomp$inline_939.version, + rendererPackageName: devToolsConfig$jscomp$inline_939.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_939.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -7830,26 +7790,26 @@ var internals$jscomp$inline_1183 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_942.findFiberByHostInstance || + devToolsConfig$jscomp$inline_939.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.0.0-c96b78e0e" + reconcilerVersion: "18.0.0-568dc3532" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1184 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_1178 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_1184.isDisabled && - hook$jscomp$inline_1184.supportsFiber + !hook$jscomp$inline_1178.isDisabled && + hook$jscomp$inline_1178.supportsFiber ) try { - (rendererID = hook$jscomp$inline_1184.inject( - internals$jscomp$inline_1183 + (rendererID = hook$jscomp$inline_1178.inject( + internals$jscomp$inline_1177 )), - (injectedHook = hook$jscomp$inline_1184); + (injectedHook = hook$jscomp$inline_1178); } catch (err) {} } exports.createPortal = function(children, containerTag) { diff --git a/Libraries/Renderer/implementations/ReactFabric-prod.js b/Libraries/Renderer/implementations/ReactFabric-prod.js index 35e278449958be..de7df01710c172 100644 --- a/Libraries/Renderer/implementations/ReactFabric-prod.js +++ b/Libraries/Renderer/implementations/ReactFabric-prod.js @@ -8,7 +8,7 @@ * @nolint * @providesModule ReactFabric-prod * @preventMunge - * @generated SignedSource<<2b5c5a5f3e3edee888af3971bac202a4>> + * @generated SignedSource<<5749c2b90feb6b0a0271a28ccf62b138>> */ "use strict"; @@ -1289,18 +1289,6 @@ function findCurrentHostFiberImpl(node) { } return null; } -function doesFiberContain(parentFiber, childFiber) { - for ( - var parentFiberAlternate = parentFiber.alternate; - null !== childFiber; - - ) { - if (childFiber === parentFiber || childFiber === parentFiberAlternate) - return !0; - childFiber = childFiber.return; - } - return !1; -} function mountSafeCallback_NOT_REALLY_SAFE(context, callback) { return function() { if ( @@ -5515,54 +5503,26 @@ function safelyDetachRef(current, nearestMountedAncestor) { if ("function" === typeof ref) try { ref(null); - } catch (refError) { - captureCommitPhaseError(current, nearestMountedAncestor, refError); + } catch (error) { + captureCommitPhaseError(current, nearestMountedAncestor, error); } else ref.current = null; } -var focusedInstanceHandle = null, - shouldFireAfterActiveInstanceBlur = !1; +var shouldFireAfterActiveInstanceBlur = !1; function commitBeforeMutationEffects(root, firstChild) { - focusedInstanceHandle = null; - for (nextEffect = firstChild; null !== nextEffect; ) { - root = nextEffect; - firstChild = root.deletions; - if (null !== firstChild) - for (var i = 0; i < firstChild.length; i++) - doesFiberContain(firstChild[i], focusedInstanceHandle) && - (shouldFireAfterActiveInstanceBlur = !0); - firstChild = root.child; - if (0 !== (root.subtreeFlags & 516) && null !== firstChild) + for (nextEffect = firstChild; null !== nextEffect; ) + if ( + ((root = nextEffect), + (firstChild = root.child), + 0 !== (root.subtreeFlags & 516) && null !== firstChild) + ) (firstChild.return = root), (nextEffect = firstChild); else for (; null !== nextEffect; ) { root = nextEffect; try { - var current = root.alternate, - flags = root.flags; - if ( - !shouldFireAfterActiveInstanceBlur && - null !== focusedInstanceHandle - ) { - var JSCompiler_temp; - if ((JSCompiler_temp = 13 === root.tag)) - a: { - if (null !== current) { - var oldState = current.memoizedState; - if (null === oldState || null !== oldState.dehydrated) { - var newState = root.memoizedState; - JSCompiler_temp = - null !== newState && null === newState.dehydrated; - break a; - } - } - JSCompiler_temp = !1; - } - JSCompiler_temp && - doesFiberContain(root, focusedInstanceHandle) && - (shouldFireAfterActiveInstanceBlur = !0); - } - if (0 !== (flags & 512)) + var current = root.alternate; + if (0 !== (root.flags & 512)) switch (root.tag) { case 0: case 11: @@ -5605,10 +5565,8 @@ function commitBeforeMutationEffects(root, firstChild) { } nextEffect = root.return; } - } current = shouldFireAfterActiveInstanceBlur; shouldFireAfterActiveInstanceBlur = !1; - focusedInstanceHandle = null; return current; } function commitHookEffectListUnmount( @@ -5658,11 +5616,13 @@ function detachFiberAfterEffects(fiber) { ((fiber.alternate = null), detachFiberAfterEffects(alternate)); fiber.child = null; fiber.deletions = null; + fiber.sibling = null; + fiber.stateNode = null; + fiber.return = null; fiber.dependencies = null; fiber.memoizedProps = null; fiber.memoizedState = null; fiber.pendingProps = null; - fiber.sibling = null; fiber.stateNode = null; fiber.updateQueue = null; } @@ -6780,8 +6740,8 @@ function flushPassiveEffects() { fiber$jscomp$0 = nextEffect; var sibling = fiber$jscomp$0.sibling, returnFiber = fiber$jscomp$0.return; + detachFiberAfterEffects(fiber$jscomp$0); if (fiber$jscomp$0 === fiberToDelete) { - detachFiberAfterEffects(fiber$jscomp$0); nextEffect = null; break; } @@ -7787,10 +7747,10 @@ batchedUpdatesImpl = function(fn, a) { } }; var roots = new Map(), - devToolsConfig$jscomp$inline_942 = { + devToolsConfig$jscomp$inline_939 = { findFiberByHostInstance: getInstanceFromInstance, bundleType: 0, - version: "18.0.0-experimental-c96b78e0e", + version: "18.0.0-experimental-568dc3532", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function() { @@ -7805,11 +7765,11 @@ var roots = new Map(), }.bind(null, findNodeHandle) } }; -var internals$jscomp$inline_1183 = { - bundleType: devToolsConfig$jscomp$inline_942.bundleType, - version: devToolsConfig$jscomp$inline_942.version, - rendererPackageName: devToolsConfig$jscomp$inline_942.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_942.rendererConfig, +var internals$jscomp$inline_1177 = { + bundleType: devToolsConfig$jscomp$inline_939.bundleType, + version: devToolsConfig$jscomp$inline_939.version, + rendererPackageName: devToolsConfig$jscomp$inline_939.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_939.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -7825,26 +7785,26 @@ var internals$jscomp$inline_1183 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_942.findFiberByHostInstance || + devToolsConfig$jscomp$inline_939.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.0.0-experimental-c96b78e0e" + reconcilerVersion: "18.0.0-experimental-568dc3532" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1184 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_1178 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_1184.isDisabled && - hook$jscomp$inline_1184.supportsFiber + !hook$jscomp$inline_1178.isDisabled && + hook$jscomp$inline_1178.supportsFiber ) try { - (rendererID = hook$jscomp$inline_1184.inject( - internals$jscomp$inline_1183 + (rendererID = hook$jscomp$inline_1178.inject( + internals$jscomp$inline_1177 )), - (injectedHook = hook$jscomp$inline_1184); + (injectedHook = hook$jscomp$inline_1178); } catch (err) {} } exports.createPortal = function(children, containerTag) { diff --git a/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js b/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js index bdbc0acccdc190..bfbef2506d8b0a 100644 --- a/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js +++ b/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<<0c18c82e93c04be7b78b4f8ff591f1b3>> */ "use strict"; @@ -1288,18 +1288,6 @@ function findCurrentHostFiberImpl(node) { } return null; } -function doesFiberContain(parentFiber, childFiber) { - for ( - var parentFiberAlternate = parentFiber.alternate; - null !== childFiber; - - ) { - if (childFiber === parentFiber || childFiber === parentFiberAlternate) - return !0; - childFiber = childFiber.return; - } - return !1; -} function mountSafeCallback_NOT_REALLY_SAFE(context, callback) { return function() { if ( @@ -5699,8 +5687,8 @@ function safelyDetachRef(current, nearestMountedAncestor) { recordLayoutEffectDuration(current); } else ref(null); - } catch (refError) { - captureCommitPhaseError(current, nearestMountedAncestor, refError); + } catch (error) { + captureCommitPhaseError(current, nearestMountedAncestor, error); } else ref.current = null; } @@ -5711,49 +5699,21 @@ function safelyCallDestroy(current, nearestMountedAncestor, destroy) { captureCommitPhaseError(current, nearestMountedAncestor, error); } } -var focusedInstanceHandle = null, - shouldFireAfterActiveInstanceBlur = !1; +var shouldFireAfterActiveInstanceBlur = !1; function commitBeforeMutationEffects(root, firstChild) { - focusedInstanceHandle = null; - for (nextEffect = firstChild; null !== nextEffect; ) { - root = nextEffect; - firstChild = root.deletions; - if (null !== firstChild) - for (var i = 0; i < firstChild.length; i++) - doesFiberContain(firstChild[i], focusedInstanceHandle) && - (shouldFireAfterActiveInstanceBlur = !0); - firstChild = root.child; - if (0 !== (root.subtreeFlags & 516) && null !== firstChild) + for (nextEffect = firstChild; null !== nextEffect; ) + if ( + ((root = nextEffect), + (firstChild = root.child), + 0 !== (root.subtreeFlags & 516) && null !== firstChild) + ) (firstChild.return = root), (nextEffect = firstChild); else for (; null !== nextEffect; ) { root = nextEffect; try { - var current = root.alternate, - flags = root.flags; - if ( - !shouldFireAfterActiveInstanceBlur && - null !== focusedInstanceHandle - ) { - var JSCompiler_temp; - if ((JSCompiler_temp = 13 === root.tag)) - a: { - if (null !== current) { - var oldState = current.memoizedState; - if (null === oldState || null !== oldState.dehydrated) { - var newState = root.memoizedState; - JSCompiler_temp = - null !== newState && null === newState.dehydrated; - break a; - } - } - JSCompiler_temp = !1; - } - JSCompiler_temp && - doesFiberContain(root, focusedInstanceHandle) && - (shouldFireAfterActiveInstanceBlur = !0); - } - if (0 !== (flags & 512)) + var current = root.alternate; + if (0 !== (root.flags & 512)) switch (root.tag) { case 0: case 11: @@ -5796,10 +5756,8 @@ function commitBeforeMutationEffects(root, firstChild) { } nextEffect = root.return; } - } current = shouldFireAfterActiveInstanceBlur; shouldFireAfterActiveInstanceBlur = !1; - focusedInstanceHandle = null; return current; } function commitHookEffectListUnmount( @@ -5842,11 +5800,13 @@ function detachFiberAfterEffects(fiber) { ((fiber.alternate = null), detachFiberAfterEffects(alternate)); fiber.child = null; fiber.deletions = null; + fiber.sibling = null; + fiber.stateNode = null; + fiber.return = null; fiber.dependencies = null; fiber.memoizedProps = null; fiber.memoizedState = null; fiber.pendingProps = null; - fiber.sibling = null; fiber.stateNode = null; fiber.updateQueue = null; } @@ -7138,8 +7098,8 @@ function flushPassiveEffects() { fiber$jscomp$0 = nextEffect; var sibling = fiber$jscomp$0.sibling, returnFiber = fiber$jscomp$0.return; + detachFiberAfterEffects(fiber$jscomp$0); if (fiber$jscomp$0 === fiberToDelete) { - detachFiberAfterEffects(fiber$jscomp$0); nextEffect = null; break; } @@ -8234,10 +8194,10 @@ batchedUpdatesImpl = function(fn, a) { } }; var roots = new Map(), - devToolsConfig$jscomp$inline_972 = { + devToolsConfig$jscomp$inline_969 = { findFiberByHostInstance: getInstanceFromInstance, bundleType: 0, - version: "18.0.0-c96b78e0e", + version: "18.0.0-568dc3532", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function() { @@ -8252,11 +8212,11 @@ var roots = new Map(), }.bind(null, findNodeHandle) } }; -var internals$jscomp$inline_1233 = { - bundleType: devToolsConfig$jscomp$inline_972.bundleType, - version: devToolsConfig$jscomp$inline_972.version, - rendererPackageName: devToolsConfig$jscomp$inline_972.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_972.rendererConfig, +var internals$jscomp$inline_1227 = { + bundleType: devToolsConfig$jscomp$inline_969.bundleType, + version: devToolsConfig$jscomp$inline_969.version, + rendererPackageName: devToolsConfig$jscomp$inline_969.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_969.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -8272,26 +8232,26 @@ var internals$jscomp$inline_1233 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_972.findFiberByHostInstance || + devToolsConfig$jscomp$inline_969.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.0.0-c96b78e0e" + reconcilerVersion: "18.0.0-568dc3532" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1234 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_1228 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_1234.isDisabled && - hook$jscomp$inline_1234.supportsFiber + !hook$jscomp$inline_1228.isDisabled && + hook$jscomp$inline_1228.supportsFiber ) try { - (rendererID = hook$jscomp$inline_1234.inject( - internals$jscomp$inline_1233 + (rendererID = hook$jscomp$inline_1228.inject( + internals$jscomp$inline_1227 )), - (injectedHook = hook$jscomp$inline_1234); + (injectedHook = hook$jscomp$inline_1228); } catch (err) {} } exports.createPortal = function(children, containerTag) { diff --git a/Libraries/Renderer/implementations/ReactFabric-profiling.js b/Libraries/Renderer/implementations/ReactFabric-profiling.js index e7aeef463ff91e..487e23a55b8a53 100644 --- a/Libraries/Renderer/implementations/ReactFabric-profiling.js +++ b/Libraries/Renderer/implementations/ReactFabric-profiling.js @@ -8,7 +8,7 @@ * @nolint * @providesModule ReactFabric-profiling * @preventMunge - * @generated SignedSource<<569ae1ac270f935b2f4e5b6ebc8036e0>> + * @generated SignedSource<> */ "use strict"; @@ -1289,18 +1289,6 @@ function findCurrentHostFiberImpl(node) { } return null; } -function doesFiberContain(parentFiber, childFiber) { - for ( - var parentFiberAlternate = parentFiber.alternate; - null !== childFiber; - - ) { - if (childFiber === parentFiber || childFiber === parentFiberAlternate) - return !0; - childFiber = childFiber.return; - } - return !1; -} function mountSafeCallback_NOT_REALLY_SAFE(context, callback) { return function() { if ( @@ -5698,8 +5686,8 @@ function safelyDetachRef(current, nearestMountedAncestor) { recordLayoutEffectDuration(current); } else ref(null); - } catch (refError) { - captureCommitPhaseError(current, nearestMountedAncestor, refError); + } catch (error) { + captureCommitPhaseError(current, nearestMountedAncestor, error); } else ref.current = null; } @@ -5710,49 +5698,21 @@ function safelyCallDestroy(current, nearestMountedAncestor, destroy) { captureCommitPhaseError(current, nearestMountedAncestor, error); } } -var focusedInstanceHandle = null, - shouldFireAfterActiveInstanceBlur = !1; +var shouldFireAfterActiveInstanceBlur = !1; function commitBeforeMutationEffects(root, firstChild) { - focusedInstanceHandle = null; - for (nextEffect = firstChild; null !== nextEffect; ) { - root = nextEffect; - firstChild = root.deletions; - if (null !== firstChild) - for (var i = 0; i < firstChild.length; i++) - doesFiberContain(firstChild[i], focusedInstanceHandle) && - (shouldFireAfterActiveInstanceBlur = !0); - firstChild = root.child; - if (0 !== (root.subtreeFlags & 516) && null !== firstChild) + for (nextEffect = firstChild; null !== nextEffect; ) + if ( + ((root = nextEffect), + (firstChild = root.child), + 0 !== (root.subtreeFlags & 516) && null !== firstChild) + ) (firstChild.return = root), (nextEffect = firstChild); else for (; null !== nextEffect; ) { root = nextEffect; try { - var current = root.alternate, - flags = root.flags; - if ( - !shouldFireAfterActiveInstanceBlur && - null !== focusedInstanceHandle - ) { - var JSCompiler_temp; - if ((JSCompiler_temp = 13 === root.tag)) - a: { - if (null !== current) { - var oldState = current.memoizedState; - if (null === oldState || null !== oldState.dehydrated) { - var newState = root.memoizedState; - JSCompiler_temp = - null !== newState && null === newState.dehydrated; - break a; - } - } - JSCompiler_temp = !1; - } - JSCompiler_temp && - doesFiberContain(root, focusedInstanceHandle) && - (shouldFireAfterActiveInstanceBlur = !0); - } - if (0 !== (flags & 512)) + var current = root.alternate; + if (0 !== (root.flags & 512)) switch (root.tag) { case 0: case 11: @@ -5795,10 +5755,8 @@ function commitBeforeMutationEffects(root, firstChild) { } nextEffect = root.return; } - } current = shouldFireAfterActiveInstanceBlur; shouldFireAfterActiveInstanceBlur = !1; - focusedInstanceHandle = null; return current; } function commitHookEffectListUnmount( @@ -5841,11 +5799,13 @@ function detachFiberAfterEffects(fiber) { ((fiber.alternate = null), detachFiberAfterEffects(alternate)); fiber.child = null; fiber.deletions = null; + fiber.sibling = null; + fiber.stateNode = null; + fiber.return = null; fiber.dependencies = null; fiber.memoizedProps = null; fiber.memoizedState = null; fiber.pendingProps = null; - fiber.sibling = null; fiber.stateNode = null; fiber.updateQueue = null; } @@ -7133,8 +7093,8 @@ function flushPassiveEffects() { fiber$jscomp$0 = nextEffect; var sibling = fiber$jscomp$0.sibling, returnFiber = fiber$jscomp$0.return; + detachFiberAfterEffects(fiber$jscomp$0); if (fiber$jscomp$0 === fiberToDelete) { - detachFiberAfterEffects(fiber$jscomp$0); nextEffect = null; break; } @@ -8229,10 +8189,10 @@ batchedUpdatesImpl = function(fn, a) { } }; var roots = new Map(), - devToolsConfig$jscomp$inline_972 = { + devToolsConfig$jscomp$inline_969 = { findFiberByHostInstance: getInstanceFromInstance, bundleType: 0, - version: "18.0.0-experimental-c96b78e0e", + version: "18.0.0-experimental-568dc3532", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function() { @@ -8247,11 +8207,11 @@ var roots = new Map(), }.bind(null, findNodeHandle) } }; -var internals$jscomp$inline_1233 = { - bundleType: devToolsConfig$jscomp$inline_972.bundleType, - version: devToolsConfig$jscomp$inline_972.version, - rendererPackageName: devToolsConfig$jscomp$inline_972.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_972.rendererConfig, +var internals$jscomp$inline_1227 = { + bundleType: devToolsConfig$jscomp$inline_969.bundleType, + version: devToolsConfig$jscomp$inline_969.version, + rendererPackageName: devToolsConfig$jscomp$inline_969.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_969.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -8267,26 +8227,26 @@ var internals$jscomp$inline_1233 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_972.findFiberByHostInstance || + devToolsConfig$jscomp$inline_969.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.0.0-experimental-c96b78e0e" + reconcilerVersion: "18.0.0-experimental-568dc3532" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1234 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_1228 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_1234.isDisabled && - hook$jscomp$inline_1234.supportsFiber + !hook$jscomp$inline_1228.isDisabled && + hook$jscomp$inline_1228.supportsFiber ) try { - (rendererID = hook$jscomp$inline_1234.inject( - internals$jscomp$inline_1233 + (rendererID = hook$jscomp$inline_1228.inject( + internals$jscomp$inline_1227 )), - (injectedHook = hook$jscomp$inline_1234); + (injectedHook = hook$jscomp$inline_1228); } catch (err) {} } exports.createPortal = function(children, containerTag) { diff --git a/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js b/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js index b96191fec24028..36e881a04505fd 100644 --- a/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js +++ b/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<> */ 'use strict'; @@ -3131,6 +3131,7 @@ function getComponentNameFromFiber(fiber) { // The rest of the flags are static for better dead code elimination. var enableProfilerTimer = true; +var enableProfilerCommitHooks = true; var enableLazyElements = false; var warnAboutStringRefs = false; var enableNewReconciler = false; @@ -3505,20 +3506,6 @@ function findCurrentHostFiberImpl(node) { return null; } -function doesFiberContain(parentFiber, childFiber) { - var node = childFiber; - var parentFiberAlternate = parentFiber.alternate; - - while (node !== null) { - if (node === parentFiber || node === parentFiberAlternate) { - return true; - } - - node = node.return; - } - - return false; -} // Modules provided by RN: var emptyObject = {}; @@ -6141,7 +6128,7 @@ var Passive$1 = /* */ 4; -var ReactVersion = "18.0.0-c96b78e0e"; +var ReactVersion = "18.0.0-568dc3532"; var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig; var NoTransition = 0; @@ -17086,19 +17073,10 @@ function safelyCallComponentWillUnmount( nearestMountedAncestor, instance ) { - { - invokeGuardedCallback( - null, - callComponentWillUnmountWithTimer, - null, - current, - instance - ); - - if (hasCaughtError()) { - var unmountError = clearCaughtError(); - captureCommitPhaseError(current, nearestMountedAncestor, unmountError); - } + try { + callComponentWillUnmountWithTimer(current, instance); + } catch (unmountError) { + captureCommitPhaseError(current, nearestMountedAncestor, unmountError); } } // Capture errors so they don't interrupt mounting. @@ -17107,19 +17085,23 @@ function safelyDetachRef(current, nearestMountedAncestor) { if (ref !== null) { if (typeof ref === "function") { - { - if (current.mode & ProfileMode) { - startLayoutEffectTimer(); - invokeGuardedCallback(null, ref, null, null); - recordLayoutEffectDuration(current); + try { + if ( + enableProfilerTimer && + enableProfilerCommitHooks && + current.mode & ProfileMode + ) { + try { + startLayoutEffectTimer(); + ref(null); + } finally { + recordLayoutEffectDuration(current); + } } else { - invokeGuardedCallback(null, ref, null, null); - } - - if (hasCaughtError()) { - var refError = clearCaughtError(); - captureCommitPhaseError(current, nearestMountedAncestor, refError); + ref(null); } + } catch (error) { + captureCommitPhaseError(current, nearestMountedAncestor, error); } } else { ref.current = null; @@ -17128,13 +17110,10 @@ function safelyDetachRef(current, nearestMountedAncestor) { } function safelyCallDestroy(current, nearestMountedAncestor, destroy) { - { - invokeGuardedCallback(null, destroy, null); - - if (hasCaughtError()) { - var error = clearCaughtError(); - captureCommitPhaseError(current, nearestMountedAncestor, error); - } + try { + destroy(); + } catch (error) { + captureCommitPhaseError(current, nearestMountedAncestor, error); } } @@ -17153,16 +17132,7 @@ function commitBeforeMutationEffects(root, firstChild) { function commitBeforeMutationEffects_begin() { while (nextEffect !== null) { - var fiber = nextEffect; // TODO: Should wrap this in flags check, too, as optimization - - var deletions = fiber.deletions; - - if (deletions !== null) { - for (var i = 0; i < deletions.length; i++) { - var deletion = deletions[i]; - commitBeforeMutationEffectsDeletion(deletion); - } - } + var fiber = nextEffect; // This phase is only used for beforeActiveInstanceBlur. var child = fiber.child; @@ -17181,24 +17151,15 @@ function commitBeforeMutationEffects_begin() { function commitBeforeMutationEffects_complete() { while (nextEffect !== null) { var fiber = nextEffect; + setCurrentFiber(fiber); - { - setCurrentFiber(fiber); - invokeGuardedCallback( - null, - commitBeforeMutationEffectsOnFiber, - null, - fiber - ); - - if (hasCaughtError()) { - var error = clearCaughtError(); - captureCommitPhaseError(fiber, fiber.return, error); - } - - resetCurrentFiber(); + try { + commitBeforeMutationEffectsOnFiber(fiber); + } catch (error) { + captureCommitPhaseError(fiber, fiber.return, error); } + resetCurrentFiber(); var sibling = fiber.sibling; if (sibling !== null) { @@ -17215,18 +17176,6 @@ function commitBeforeMutationEffectsOnFiber(finishedWork) { var current = finishedWork.alternate; var flags = finishedWork.flags; - if (!shouldFireAfterActiveInstanceBlur && focusedInstanceHandle !== null) { - // Check to see if the focused element was inside of a hidden (Suspense) subtree. - // TODO: Move this out of the hot path using a dedicated effect tag. - if ( - finishedWork.tag === SuspenseComponent && - isSuspenseBoundaryBeingHidden(current, finishedWork) && - doesFiberContain(finishedWork, focusedInstanceHandle) - ) { - shouldFireAfterActiveInstanceBlur = true; - } - } - if ((flags & Snapshot) !== NoFlags) { setCurrentFiber(finishedWork); @@ -17330,16 +17279,6 @@ function commitBeforeMutationEffectsOnFiber(finishedWork) { } } -function commitBeforeMutationEffectsDeletion(deletion) { - // TODO (effects) It would be nice to avoid calling doesFiberContain() - // Maybe we can repurpose one of the subtreeFlags positions for this instead? - // Use it to store which part of the tree the focused instance is in? - // This assumes we can safely determine that instance during the "render" phase. - if (doesFiberContain(deletion, focusedInstanceHandle)) { - shouldFireAfterActiveInstanceBlur = true; - } -} - function commitHookEffectListUnmount( flags, finishedWork, @@ -18089,20 +18028,50 @@ function detachFiberAfterEffects(fiber) { // `deletedTreeCleanUpLevel` is undefined. { - // This is the default branch (level 0). + // Clear cyclical Fiber fields. This level alone is designed to roughly + // approximate the planned Fiber refactor. In that world, `setState` will be + // bound to a special "instance" object instead of a Fiber. The Instance + // object will not have any of these fields. It will only be connected to + // the fiber tree via a single link at the root. So if this level alone is + // sufficient to fix memory issues, that bodes well for our plans. fiber.child = null; fiber.deletions = null; - fiber.dependencies = null; - fiber.memoizedProps = null; - fiber.memoizedState = null; - fiber.pendingProps = null; - fiber.sibling = null; - fiber.stateNode = null; - fiber.updateQueue = null; + fiber.sibling = null; // The `stateNode` is cyclical because on host nodes it points to the host + // tree, which has its own pointers to children, parents, and siblings. + // The other host nodes also point back to fibers, so we should detach that + // one, too. + + if (fiber.tag === HostComponent) { + var hostInstance = fiber.stateNode; + } + + fiber.stateNode = null; // I'm intentionally not clearing the `return` field in this level. We + // already disconnect the `return` pointer at the root of the deleted + // subtree (in `detachFiberMutation`). Besides, `return` by itself is not + // cyclical — it's only cyclical when combined with `child`, `sibling`, and + // `alternate`. But we'll clear it in the next level anyway, just in case. { fiber._debugOwner = null; } + + { + // Theoretically, nothing in here should be necessary, because we already + // disconnected the fiber from the tree. So even if something leaks this + // particular fiber, it won't leak anything else + // + // The purpose of this branch is to be super aggressive so we can measure + // if there's any difference in memory impact. If there is, that could + // indicate a React leak we don't know about. + fiber.return = null; + fiber.dependencies = null; + fiber.memoizedProps = null; + fiber.memoizedState = null; + fiber.pendingProps = null; + fiber.stateNode = null; // TODO: Move to `commitPassiveUnmountInsideDeletedTreeOnFiber` instead. + + fiber.updateQueue = null; + } } } @@ -18574,21 +18543,6 @@ function attachSuspenseRetryListeners(finishedWork) { }); } } // This function detects when a Suspense boundary goes from visible to hidden. -// It returns false if the boundary is already hidden. -// TODO: Use an effect tag. - -function isSuspenseBoundaryBeingHidden(current, finishedWork) { - if (current !== null) { - var oldState = current.memoizedState; - - if (oldState === null || oldState.dehydrated !== null) { - var newState = finishedWork.memoizedState; - return newState !== null && newState.dehydrated === null; - } - } - - return false; -} function commitResetTextContent(current) { resetTextContent(current.stateNode); @@ -18613,20 +18567,10 @@ function commitMutationEffects_begin(root) { for (var i = 0; i < deletions.length; i++) { var childToDelete = deletions[i]; - { - invokeGuardedCallback( - null, - commitDeletion, - null, - root, - childToDelete, - fiber - ); - - if (hasCaughtError()) { - var error = clearCaughtError(); - captureCommitPhaseError(childToDelete, fiber, error); - } + try { + commitDeletion(root, childToDelete, fiber); + } catch (error) { + captureCommitPhaseError(childToDelete, fiber, error); } } } @@ -18645,25 +18589,15 @@ function commitMutationEffects_begin(root) { function commitMutationEffects_complete(root) { while (nextEffect !== null) { var fiber = nextEffect; + setCurrentFiber(fiber); - { - setCurrentFiber(fiber); - invokeGuardedCallback( - null, - commitMutationEffectsOnFiber, - null, - fiber, - root - ); - - if (hasCaughtError()) { - var error = clearCaughtError(); - captureCommitPhaseError(fiber, fiber.return, error); - } - - resetCurrentFiber(); + try { + commitMutationEffectsOnFiber(fiber, root); + } catch (error) { + captureCommitPhaseError(fiber, fiber.return, error); } + resetCurrentFiber(); var sibling = fiber.sibling; if (sibling !== null) { @@ -18775,26 +18709,15 @@ function commitLayoutMountEffects_complete(subtreeRoot, root, committedLanes) { if ((fiber.flags & LayoutMask) !== NoFlags) { var current = fiber.alternate; + setCurrentFiber(fiber); - { - setCurrentFiber(fiber); - invokeGuardedCallback( - null, - commitLayoutEffectOnFiber, - null, - root, - current, - fiber, - committedLanes - ); - - if (hasCaughtError()) { - var error = clearCaughtError(); - captureCommitPhaseError(fiber, fiber.return, error); - } - - resetCurrentFiber(); + try { + commitLayoutEffectOnFiber(root, current, fiber, committedLanes); + } catch (error) { + captureCommitPhaseError(fiber, fiber.return, error); } + + resetCurrentFiber(); } if (fiber === subtreeRoot) { @@ -18838,23 +18761,15 @@ function commitPassiveMountEffects_complete(subtreeRoot, root) { var fiber = nextEffect; if ((fiber.flags & Passive) !== NoFlags) { - { - setCurrentFiber(fiber); - invokeGuardedCallback( - null, - commitPassiveMountOnFiber, - null, - root, - fiber - ); - - if (hasCaughtError()) { - var error = clearCaughtError(); - captureCommitPhaseError(fiber, fiber.return, error); - } + setCurrentFiber(fiber); - resetCurrentFiber(); + try { + commitPassiveMountOnFiber(root, fiber); + } catch (error) { + captureCommitPhaseError(fiber, fiber.return, error); } + + resetCurrentFiber(); } if (fiber === subtreeRoot) { @@ -19043,10 +18958,12 @@ function commitPassiveUnmountEffectsInsideOfDeletedTree_complete( var returnFiber = fiber.return; { - // This is the default branch (level 0). We do not recursively clear all - // the fiber fields. Only the root of the deleted subtree. + // Recursively traverse the entire deleted tree and clean up fiber fields. + // This is more aggressive than ideal, and the long term goal is to only + // have to detach the deleted tree at the root. + detachFiberAfterEffects(fiber); + if (fiber === deletedSubtreeRoot) { - detachFiberAfterEffects(fiber); nextEffect = null; return; } @@ -19108,17 +19025,10 @@ function invokeLayoutEffectMountInDEV(fiber) { case FunctionComponent: case ForwardRef: case SimpleMemoComponent: { - invokeGuardedCallback( - null, - commitHookEffectListMount, - null, - Layout | HasEffect, - fiber - ); - - if (hasCaughtError()) { - var mountError = clearCaughtError(); - captureCommitPhaseError(fiber, fiber.return, mountError); + try { + commitHookEffectListMount(Layout | HasEffect, fiber); + } catch (error) { + captureCommitPhaseError(fiber, fiber.return, error); } break; @@ -19126,12 +19036,11 @@ function invokeLayoutEffectMountInDEV(fiber) { case ClassComponent: { var instance = fiber.stateNode; - invokeGuardedCallback(null, instance.componentDidMount, instance); - - if (hasCaughtError()) { - var _mountError = clearCaughtError(); - captureCommitPhaseError(fiber, fiber.return, _mountError); + try { + instance.componentDidMount(); + } catch (error) { + captureCommitPhaseError(fiber, fiber.return, error); } break; @@ -19148,17 +19057,10 @@ function invokePassiveEffectMountInDEV(fiber) { case FunctionComponent: case ForwardRef: case SimpleMemoComponent: { - invokeGuardedCallback( - null, - commitHookEffectListMount, - null, - Passive$1 | HasEffect, - fiber - ); - - if (hasCaughtError()) { - var mountError = clearCaughtError(); - captureCommitPhaseError(fiber, fiber.return, mountError); + try { + commitHookEffectListMount(Passive$1 | HasEffect, fiber); + } catch (error) { + captureCommitPhaseError(fiber, fiber.return, error); } break; @@ -19175,18 +19077,10 @@ function invokeLayoutEffectUnmountInDEV(fiber) { case FunctionComponent: case ForwardRef: case SimpleMemoComponent: { - invokeGuardedCallback( - null, - commitHookEffectListUnmount, - null, - Layout | HasEffect, - fiber, - fiber.return - ); - - if (hasCaughtError()) { - var unmountError = clearCaughtError(); - captureCommitPhaseError(fiber, fiber.return, unmountError); + try { + commitHookEffectListUnmount(Layout | HasEffect, fiber, fiber.return); + } catch (error) { + captureCommitPhaseError(fiber, fiber.return, error); } break; @@ -19196,20 +19090,7 @@ function invokeLayoutEffectUnmountInDEV(fiber) { var instance = fiber.stateNode; if (typeof instance.componentWillUnmount === "function") { - invokeGuardedCallback( - null, - safelyCallComponentWillUnmount, - null, - fiber, - fiber.return, - instance - ); - - if (hasCaughtError()) { - var _unmountError = clearCaughtError(); - - captureCommitPhaseError(fiber, fiber.return, _unmountError); - } + safelyCallComponentWillUnmount(fiber, fiber.return, instance); } break; @@ -19226,21 +19107,15 @@ function invokePassiveEffectUnmountInDEV(fiber) { case FunctionComponent: case ForwardRef: case SimpleMemoComponent: { - invokeGuardedCallback( - null, - commitHookEffectListUnmount, - null, - Passive$1 | HasEffect, - fiber, - fiber.return - ); - - if (hasCaughtError()) { - var unmountError = clearCaughtError(); - captureCommitPhaseError(fiber, fiber.return, unmountError); + try { + commitHookEffectListUnmount( + Passive$1 | HasEffect, + fiber, + fiber.return + ); + } catch (error) { + captureCommitPhaseError(fiber, fiber.return, error); } - - break; } } } diff --git a/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js b/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js index 5f7a300466a225..557e1efd6dc47d 100644 --- a/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +++ b/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js @@ -8,7 +8,7 @@ * @nolint * @providesModule ReactNativeRenderer-dev * @preventMunge - * @generated SignedSource<<61618ec46c01f4420d0f803346bf7ac1>> + * @generated SignedSource<<2293994bcf1885347cabc2a323cb920e>> */ 'use strict'; @@ -3131,6 +3131,7 @@ function getComponentNameFromFiber(fiber) { } var enableProfilerTimer = true; +var enableProfilerCommitHooks = true; var enableLazyElements = false; var warnAboutStringRefs = false; var enableNewReconciler = false; @@ -3496,20 +3497,6 @@ function findCurrentHostFiberImpl(node) { return null; } -function doesFiberContain(parentFiber, childFiber) { - var node = childFiber; - var parentFiberAlternate = parentFiber.alternate; - - while (node !== null) { - if (node === parentFiber || node === parentFiberAlternate) { - return true; - } - - node = node.return; - } - - return false; -} // Modules provided by RN: var emptyObject = {}; @@ -6023,7 +6010,7 @@ var Passive$1 = /* */ 4; -var ReactVersion = "18.0.0-experimental-c96b78e0e"; +var ReactVersion = "18.0.0-experimental-568dc3532"; var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig; var NoTransition = 0; @@ -16809,19 +16796,10 @@ function safelyCallComponentWillUnmount( nearestMountedAncestor, instance ) { - { - invokeGuardedCallback( - null, - callComponentWillUnmountWithTimer, - null, - current, - instance - ); - - if (hasCaughtError()) { - var unmountError = clearCaughtError(); - captureCommitPhaseError(current, nearestMountedAncestor, unmountError); - } + try { + callComponentWillUnmountWithTimer(current, instance); + } catch (unmountError) { + captureCommitPhaseError(current, nearestMountedAncestor, unmountError); } } // Capture errors so they don't interrupt mounting. @@ -16830,19 +16808,23 @@ function safelyDetachRef(current, nearestMountedAncestor) { if (ref !== null) { if (typeof ref === "function") { - { - if (current.mode & ProfileMode) { - startLayoutEffectTimer(); - invokeGuardedCallback(null, ref, null, null); - recordLayoutEffectDuration(current); + try { + if ( + enableProfilerTimer && + enableProfilerCommitHooks && + current.mode & ProfileMode + ) { + try { + startLayoutEffectTimer(); + ref(null); + } finally { + recordLayoutEffectDuration(current); + } } else { - invokeGuardedCallback(null, ref, null, null); - } - - if (hasCaughtError()) { - var refError = clearCaughtError(); - captureCommitPhaseError(current, nearestMountedAncestor, refError); + ref(null); } + } catch (error) { + captureCommitPhaseError(current, nearestMountedAncestor, error); } } else { ref.current = null; @@ -16851,13 +16833,10 @@ function safelyDetachRef(current, nearestMountedAncestor) { } function safelyCallDestroy(current, nearestMountedAncestor, destroy) { - { - invokeGuardedCallback(null, destroy, null); - - if (hasCaughtError()) { - var error = clearCaughtError(); - captureCommitPhaseError(current, nearestMountedAncestor, error); - } + try { + destroy(); + } catch (error) { + captureCommitPhaseError(current, nearestMountedAncestor, error); } } @@ -16876,16 +16855,7 @@ function commitBeforeMutationEffects(root, firstChild) { function commitBeforeMutationEffects_begin() { while (nextEffect !== null) { - var fiber = nextEffect; // TODO: Should wrap this in flags check, too, as optimization - - var deletions = fiber.deletions; - - if (deletions !== null) { - for (var i = 0; i < deletions.length; i++) { - var deletion = deletions[i]; - commitBeforeMutationEffectsDeletion(deletion); - } - } + var fiber = nextEffect; // This phase is only used for beforeActiveInstanceBlur. var child = fiber.child; @@ -16904,24 +16874,15 @@ function commitBeforeMutationEffects_begin() { function commitBeforeMutationEffects_complete() { while (nextEffect !== null) { var fiber = nextEffect; + setCurrentFiber(fiber); - { - setCurrentFiber(fiber); - invokeGuardedCallback( - null, - commitBeforeMutationEffectsOnFiber, - null, - fiber - ); - - if (hasCaughtError()) { - var error = clearCaughtError(); - captureCommitPhaseError(fiber, fiber.return, error); - } - - resetCurrentFiber(); + try { + commitBeforeMutationEffectsOnFiber(fiber); + } catch (error) { + captureCommitPhaseError(fiber, fiber.return, error); } + resetCurrentFiber(); var sibling = fiber.sibling; if (sibling !== null) { @@ -16938,18 +16899,6 @@ function commitBeforeMutationEffectsOnFiber(finishedWork) { var current = finishedWork.alternate; var flags = finishedWork.flags; - if (!shouldFireAfterActiveInstanceBlur && focusedInstanceHandle !== null) { - // Check to see if the focused element was inside of a hidden (Suspense) subtree. - // TODO: Move this out of the hot path using a dedicated effect tag. - if ( - finishedWork.tag === SuspenseComponent && - isSuspenseBoundaryBeingHidden(current, finishedWork) && - doesFiberContain(finishedWork, focusedInstanceHandle) - ) { - shouldFireAfterActiveInstanceBlur = true; - } - } - if ((flags & Snapshot) !== NoFlags) { setCurrentFiber(finishedWork); @@ -17053,16 +17002,6 @@ function commitBeforeMutationEffectsOnFiber(finishedWork) { } } -function commitBeforeMutationEffectsDeletion(deletion) { - // TODO (effects) It would be nice to avoid calling doesFiberContain() - // Maybe we can repurpose one of the subtreeFlags positions for this instead? - // Use it to store which part of the tree the focused instance is in? - // This assumes we can safely determine that instance during the "render" phase. - if (doesFiberContain(deletion, focusedInstanceHandle)) { - shouldFireAfterActiveInstanceBlur = true; - } -} - function commitHookEffectListUnmount( flags, finishedWork, @@ -17812,20 +17751,50 @@ function detachFiberAfterEffects(fiber) { // `deletedTreeCleanUpLevel` is undefined. { - // This is the default branch (level 0). + // Clear cyclical Fiber fields. This level alone is designed to roughly + // approximate the planned Fiber refactor. In that world, `setState` will be + // bound to a special "instance" object instead of a Fiber. The Instance + // object will not have any of these fields. It will only be connected to + // the fiber tree via a single link at the root. So if this level alone is + // sufficient to fix memory issues, that bodes well for our plans. fiber.child = null; fiber.deletions = null; - fiber.dependencies = null; - fiber.memoizedProps = null; - fiber.memoizedState = null; - fiber.pendingProps = null; - fiber.sibling = null; - fiber.stateNode = null; - fiber.updateQueue = null; + fiber.sibling = null; // The `stateNode` is cyclical because on host nodes it points to the host + // tree, which has its own pointers to children, parents, and siblings. + // The other host nodes also point back to fibers, so we should detach that + // one, too. + + if (fiber.tag === HostComponent) { + var hostInstance = fiber.stateNode; + } + + fiber.stateNode = null; // I'm intentionally not clearing the `return` field in this level. We + // already disconnect the `return` pointer at the root of the deleted + // subtree (in `detachFiberMutation`). Besides, `return` by itself is not + // cyclical — it's only cyclical when combined with `child`, `sibling`, and + // `alternate`. But we'll clear it in the next level anyway, just in case. { fiber._debugOwner = null; } + + { + // Theoretically, nothing in here should be necessary, because we already + // disconnected the fiber from the tree. So even if something leaks this + // particular fiber, it won't leak anything else + // + // The purpose of this branch is to be super aggressive so we can measure + // if there's any difference in memory impact. If there is, that could + // indicate a React leak we don't know about. + fiber.return = null; + fiber.dependencies = null; + fiber.memoizedProps = null; + fiber.memoizedState = null; + fiber.pendingProps = null; + fiber.stateNode = null; // TODO: Move to `commitPassiveUnmountInsideDeletedTreeOnFiber` instead. + + fiber.updateQueue = null; + } } } @@ -18297,21 +18266,6 @@ function attachSuspenseRetryListeners(finishedWork) { }); } } // This function detects when a Suspense boundary goes from visible to hidden. -// It returns false if the boundary is already hidden. -// TODO: Use an effect tag. - -function isSuspenseBoundaryBeingHidden(current, finishedWork) { - if (current !== null) { - var oldState = current.memoizedState; - - if (oldState === null || oldState.dehydrated !== null) { - var newState = finishedWork.memoizedState; - return newState !== null && newState.dehydrated === null; - } - } - - return false; -} function commitResetTextContent(current) { resetTextContent(current.stateNode); @@ -18336,20 +18290,10 @@ function commitMutationEffects_begin(root) { for (var i = 0; i < deletions.length; i++) { var childToDelete = deletions[i]; - { - invokeGuardedCallback( - null, - commitDeletion, - null, - root, - childToDelete, - fiber - ); - - if (hasCaughtError()) { - var error = clearCaughtError(); - captureCommitPhaseError(childToDelete, fiber, error); - } + try { + commitDeletion(root, childToDelete, fiber); + } catch (error) { + captureCommitPhaseError(childToDelete, fiber, error); } } } @@ -18368,25 +18312,15 @@ function commitMutationEffects_begin(root) { function commitMutationEffects_complete(root) { while (nextEffect !== null) { var fiber = nextEffect; + setCurrentFiber(fiber); - { - setCurrentFiber(fiber); - invokeGuardedCallback( - null, - commitMutationEffectsOnFiber, - null, - fiber, - root - ); - - if (hasCaughtError()) { - var error = clearCaughtError(); - captureCommitPhaseError(fiber, fiber.return, error); - } - - resetCurrentFiber(); + try { + commitMutationEffectsOnFiber(fiber, root); + } catch (error) { + captureCommitPhaseError(fiber, fiber.return, error); } + resetCurrentFiber(); var sibling = fiber.sibling; if (sibling !== null) { @@ -18498,26 +18432,15 @@ function commitLayoutMountEffects_complete(subtreeRoot, root, committedLanes) { if ((fiber.flags & LayoutMask) !== NoFlags) { var current = fiber.alternate; + setCurrentFiber(fiber); - { - setCurrentFiber(fiber); - invokeGuardedCallback( - null, - commitLayoutEffectOnFiber, - null, - root, - current, - fiber, - committedLanes - ); - - if (hasCaughtError()) { - var error = clearCaughtError(); - captureCommitPhaseError(fiber, fiber.return, error); - } - - resetCurrentFiber(); + try { + commitLayoutEffectOnFiber(root, current, fiber, committedLanes); + } catch (error) { + captureCommitPhaseError(fiber, fiber.return, error); } + + resetCurrentFiber(); } if (fiber === subtreeRoot) { @@ -18561,23 +18484,15 @@ function commitPassiveMountEffects_complete(subtreeRoot, root) { var fiber = nextEffect; if ((fiber.flags & Passive) !== NoFlags) { - { - setCurrentFiber(fiber); - invokeGuardedCallback( - null, - commitPassiveMountOnFiber, - null, - root, - fiber - ); - - if (hasCaughtError()) { - var error = clearCaughtError(); - captureCommitPhaseError(fiber, fiber.return, error); - } + setCurrentFiber(fiber); - resetCurrentFiber(); + try { + commitPassiveMountOnFiber(root, fiber); + } catch (error) { + captureCommitPhaseError(fiber, fiber.return, error); } + + resetCurrentFiber(); } if (fiber === subtreeRoot) { @@ -18766,10 +18681,12 @@ function commitPassiveUnmountEffectsInsideOfDeletedTree_complete( var returnFiber = fiber.return; { - // This is the default branch (level 0). We do not recursively clear all - // the fiber fields. Only the root of the deleted subtree. + // Recursively traverse the entire deleted tree and clean up fiber fields. + // This is more aggressive than ideal, and the long term goal is to only + // have to detach the deleted tree at the root. + detachFiberAfterEffects(fiber); + if (fiber === deletedSubtreeRoot) { - detachFiberAfterEffects(fiber); nextEffect = null; return; } diff --git a/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js b/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js index 0141e330729036..6c7ed238d125d6 100644 --- a/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js +++ b/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<<1ea517705a715682abeb1aa7d378ce03>> */ "use strict"; @@ -1392,18 +1392,6 @@ function findCurrentHostFiberImpl(node) { } return null; } -function doesFiberContain(parentFiber, childFiber) { - for ( - var parentFiberAlternate = parentFiber.alternate; - null !== childFiber; - - ) { - if (childFiber === parentFiber || childFiber === parentFiberAlternate) - return !0; - childFiber = childFiber.return; - } - return !1; -} var emptyObject = {}, removedKeys = null, removedKeyCount = 0, @@ -5376,54 +5364,26 @@ function safelyDetachRef(current, nearestMountedAncestor) { if ("function" === typeof ref) try { ref(null); - } catch (refError) { - captureCommitPhaseError(current, nearestMountedAncestor, refError); + } catch (error) { + captureCommitPhaseError(current, nearestMountedAncestor, error); } else ref.current = null; } -var focusedInstanceHandle = null, - shouldFireAfterActiveInstanceBlur = !1; +var shouldFireAfterActiveInstanceBlur = !1; function commitBeforeMutationEffects(root, firstChild) { - focusedInstanceHandle = null; - for (nextEffect = firstChild; null !== nextEffect; ) { - root = nextEffect; - firstChild = root.deletions; - if (null !== firstChild) - for (var i = 0; i < firstChild.length; i++) - doesFiberContain(firstChild[i], focusedInstanceHandle) && - (shouldFireAfterActiveInstanceBlur = !0); - firstChild = root.child; - if (0 !== (root.subtreeFlags & 516) && null !== firstChild) + for (nextEffect = firstChild; null !== nextEffect; ) + if ( + ((root = nextEffect), + (firstChild = root.child), + 0 !== (root.subtreeFlags & 516) && null !== firstChild) + ) (firstChild.return = root), (nextEffect = firstChild); else for (; null !== nextEffect; ) { root = nextEffect; try { - var current = root.alternate, - flags = root.flags; - if ( - !shouldFireAfterActiveInstanceBlur && - null !== focusedInstanceHandle - ) { - var JSCompiler_temp; - if ((JSCompiler_temp = 13 === root.tag)) - a: { - if (null !== current) { - var oldState = current.memoizedState; - if (null === oldState || null !== oldState.dehydrated) { - var newState = root.memoizedState; - JSCompiler_temp = - null !== newState && null === newState.dehydrated; - break a; - } - } - JSCompiler_temp = !1; - } - JSCompiler_temp && - doesFiberContain(root, focusedInstanceHandle) && - (shouldFireAfterActiveInstanceBlur = !0); - } - if (0 !== (flags & 512)) + var current = root.alternate; + if (0 !== (root.flags & 512)) switch (root.tag) { case 0: case 11: @@ -5466,10 +5426,8 @@ function commitBeforeMutationEffects(root, firstChild) { } nextEffect = root.return; } - } current = shouldFireAfterActiveInstanceBlur; shouldFireAfterActiveInstanceBlur = !1; - focusedInstanceHandle = null; return current; } function commitHookEffectListUnmount( @@ -5641,11 +5599,13 @@ function detachFiberAfterEffects(fiber) { ((fiber.alternate = null), detachFiberAfterEffects(alternate)); fiber.child = null; fiber.deletions = null; + fiber.sibling = null; + fiber.stateNode = null; + fiber.return = null; fiber.dependencies = null; fiber.memoizedProps = null; fiber.memoizedState = null; fiber.pendingProps = null; - fiber.sibling = null; fiber.stateNode = null; fiber.updateQueue = null; } @@ -6980,8 +6940,8 @@ function flushPassiveEffects() { fiber$jscomp$0 = nextEffect; var sibling = fiber$jscomp$0.sibling, returnFiber = fiber$jscomp$0.return; + detachFiberAfterEffects(fiber$jscomp$0); if (fiber$jscomp$0 === fiberToDelete) { - detachFiberAfterEffects(fiber$jscomp$0); nextEffect = null; break; } @@ -7994,10 +7954,10 @@ batchedUpdatesImpl = function(fn, a) { } }; var roots = new Map(), - devToolsConfig$jscomp$inline_986 = { + devToolsConfig$jscomp$inline_983 = { findFiberByHostInstance: getInstanceFromTag, bundleType: 0, - version: "18.0.0-c96b78e0e", + version: "18.0.0-568dc3532", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function() { @@ -8012,11 +7972,11 @@ var roots = new Map(), }.bind(null, findNodeHandle) } }; -var internals$jscomp$inline_1243 = { - bundleType: devToolsConfig$jscomp$inline_986.bundleType, - version: devToolsConfig$jscomp$inline_986.version, - rendererPackageName: devToolsConfig$jscomp$inline_986.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_986.rendererConfig, +var internals$jscomp$inline_1237 = { + bundleType: devToolsConfig$jscomp$inline_983.bundleType, + version: devToolsConfig$jscomp$inline_983.version, + rendererPackageName: devToolsConfig$jscomp$inline_983.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_983.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -8032,26 +7992,26 @@ var internals$jscomp$inline_1243 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_986.findFiberByHostInstance || + devToolsConfig$jscomp$inline_983.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.0.0-c96b78e0e" + reconcilerVersion: "18.0.0-568dc3532" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1244 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_1238 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_1244.isDisabled && - hook$jscomp$inline_1244.supportsFiber + !hook$jscomp$inline_1238.isDisabled && + hook$jscomp$inline_1238.supportsFiber ) try { - (rendererID = hook$jscomp$inline_1244.inject( - internals$jscomp$inline_1243 + (rendererID = hook$jscomp$inline_1238.inject( + internals$jscomp$inline_1237 )), - (injectedHook = hook$jscomp$inline_1244); + (injectedHook = hook$jscomp$inline_1238); } catch (err) {} } exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = { diff --git a/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js b/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js index fba7003edc379f..1d79146054d3bd 100644 --- a/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +++ b/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js @@ -8,7 +8,7 @@ * @nolint * @providesModule ReactNativeRenderer-prod * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<> */ "use strict"; @@ -1393,18 +1393,6 @@ function findCurrentHostFiberImpl(node) { } return null; } -function doesFiberContain(parentFiber, childFiber) { - for ( - var parentFiberAlternate = parentFiber.alternate; - null !== childFiber; - - ) { - if (childFiber === parentFiber || childFiber === parentFiberAlternate) - return !0; - childFiber = childFiber.return; - } - return !1; -} var emptyObject = {}, removedKeys = null, removedKeyCount = 0, @@ -5375,54 +5363,26 @@ function safelyDetachRef(current, nearestMountedAncestor) { if ("function" === typeof ref) try { ref(null); - } catch (refError) { - captureCommitPhaseError(current, nearestMountedAncestor, refError); + } catch (error) { + captureCommitPhaseError(current, nearestMountedAncestor, error); } else ref.current = null; } -var focusedInstanceHandle = null, - shouldFireAfterActiveInstanceBlur = !1; +var shouldFireAfterActiveInstanceBlur = !1; function commitBeforeMutationEffects(root, firstChild) { - focusedInstanceHandle = null; - for (nextEffect = firstChild; null !== nextEffect; ) { - root = nextEffect; - firstChild = root.deletions; - if (null !== firstChild) - for (var i = 0; i < firstChild.length; i++) - doesFiberContain(firstChild[i], focusedInstanceHandle) && - (shouldFireAfterActiveInstanceBlur = !0); - firstChild = root.child; - if (0 !== (root.subtreeFlags & 516) && null !== firstChild) + for (nextEffect = firstChild; null !== nextEffect; ) + if ( + ((root = nextEffect), + (firstChild = root.child), + 0 !== (root.subtreeFlags & 516) && null !== firstChild) + ) (firstChild.return = root), (nextEffect = firstChild); else for (; null !== nextEffect; ) { root = nextEffect; try { - var current = root.alternate, - flags = root.flags; - if ( - !shouldFireAfterActiveInstanceBlur && - null !== focusedInstanceHandle - ) { - var JSCompiler_temp; - if ((JSCompiler_temp = 13 === root.tag)) - a: { - if (null !== current) { - var oldState = current.memoizedState; - if (null === oldState || null !== oldState.dehydrated) { - var newState = root.memoizedState; - JSCompiler_temp = - null !== newState && null === newState.dehydrated; - break a; - } - } - JSCompiler_temp = !1; - } - JSCompiler_temp && - doesFiberContain(root, focusedInstanceHandle) && - (shouldFireAfterActiveInstanceBlur = !0); - } - if (0 !== (flags & 512)) + var current = root.alternate; + if (0 !== (root.flags & 512)) switch (root.tag) { case 0: case 11: @@ -5465,10 +5425,8 @@ function commitBeforeMutationEffects(root, firstChild) { } nextEffect = root.return; } - } current = shouldFireAfterActiveInstanceBlur; shouldFireAfterActiveInstanceBlur = !1; - focusedInstanceHandle = null; return current; } function commitHookEffectListUnmount( @@ -5640,11 +5598,13 @@ function detachFiberAfterEffects(fiber) { ((fiber.alternate = null), detachFiberAfterEffects(alternate)); fiber.child = null; fiber.deletions = null; + fiber.sibling = null; + fiber.stateNode = null; + fiber.return = null; fiber.dependencies = null; fiber.memoizedProps = null; fiber.memoizedState = null; fiber.pendingProps = null; - fiber.sibling = null; fiber.stateNode = null; fiber.updateQueue = null; } @@ -6975,8 +6935,8 @@ function flushPassiveEffects() { fiber$jscomp$0 = nextEffect; var sibling = fiber$jscomp$0.sibling, returnFiber = fiber$jscomp$0.return; + detachFiberAfterEffects(fiber$jscomp$0); if (fiber$jscomp$0 === fiberToDelete) { - detachFiberAfterEffects(fiber$jscomp$0); nextEffect = null; break; } @@ -7989,10 +7949,10 @@ batchedUpdatesImpl = function(fn, a) { } }; var roots = new Map(), - devToolsConfig$jscomp$inline_986 = { + devToolsConfig$jscomp$inline_983 = { findFiberByHostInstance: getInstanceFromTag, bundleType: 0, - version: "18.0.0-experimental-c96b78e0e", + version: "18.0.0-experimental-568dc3532", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function() { @@ -8007,11 +7967,11 @@ var roots = new Map(), }.bind(null, findNodeHandle) } }; -var internals$jscomp$inline_1243 = { - bundleType: devToolsConfig$jscomp$inline_986.bundleType, - version: devToolsConfig$jscomp$inline_986.version, - rendererPackageName: devToolsConfig$jscomp$inline_986.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_986.rendererConfig, +var internals$jscomp$inline_1237 = { + bundleType: devToolsConfig$jscomp$inline_983.bundleType, + version: devToolsConfig$jscomp$inline_983.version, + rendererPackageName: devToolsConfig$jscomp$inline_983.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_983.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -8027,26 +7987,26 @@ var internals$jscomp$inline_1243 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_986.findFiberByHostInstance || + devToolsConfig$jscomp$inline_983.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.0.0-experimental-c96b78e0e" + reconcilerVersion: "18.0.0-experimental-568dc3532" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1244 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_1238 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_1244.isDisabled && - hook$jscomp$inline_1244.supportsFiber + !hook$jscomp$inline_1238.isDisabled && + hook$jscomp$inline_1238.supportsFiber ) try { - (rendererID = hook$jscomp$inline_1244.inject( - internals$jscomp$inline_1243 + (rendererID = hook$jscomp$inline_1238.inject( + internals$jscomp$inline_1237 )), - (injectedHook = hook$jscomp$inline_1244); + (injectedHook = hook$jscomp$inline_1238); } catch (err) {} } exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = { diff --git a/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js b/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js index 7830a297310ef4..216e1100be3a60 100644 --- a/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js +++ b/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<02ea6b7ee6d2a0eb5f4f256d6119f479>> + * @generated SignedSource<> */ "use strict"; @@ -1392,18 +1392,6 @@ function findCurrentHostFiberImpl(node) { } return null; } -function doesFiberContain(parentFiber, childFiber) { - for ( - var parentFiberAlternate = parentFiber.alternate; - null !== childFiber; - - ) { - if (childFiber === parentFiber || childFiber === parentFiberAlternate) - return !0; - childFiber = childFiber.return; - } - return !1; -} var emptyObject = {}, removedKeys = null, removedKeyCount = 0, @@ -5559,8 +5547,8 @@ function safelyDetachRef(current, nearestMountedAncestor) { recordLayoutEffectDuration(current); } else ref(null); - } catch (refError) { - captureCommitPhaseError(current, nearestMountedAncestor, refError); + } catch (error) { + captureCommitPhaseError(current, nearestMountedAncestor, error); } else ref.current = null; } @@ -5571,49 +5559,21 @@ function safelyCallDestroy(current, nearestMountedAncestor, destroy) { captureCommitPhaseError(current, nearestMountedAncestor, error); } } -var focusedInstanceHandle = null, - shouldFireAfterActiveInstanceBlur = !1; +var shouldFireAfterActiveInstanceBlur = !1; function commitBeforeMutationEffects(root, firstChild) { - focusedInstanceHandle = null; - for (nextEffect = firstChild; null !== nextEffect; ) { - root = nextEffect; - firstChild = root.deletions; - if (null !== firstChild) - for (var i = 0; i < firstChild.length; i++) - doesFiberContain(firstChild[i], focusedInstanceHandle) && - (shouldFireAfterActiveInstanceBlur = !0); - firstChild = root.child; - if (0 !== (root.subtreeFlags & 516) && null !== firstChild) + for (nextEffect = firstChild; null !== nextEffect; ) + if ( + ((root = nextEffect), + (firstChild = root.child), + 0 !== (root.subtreeFlags & 516) && null !== firstChild) + ) (firstChild.return = root), (nextEffect = firstChild); else for (; null !== nextEffect; ) { root = nextEffect; try { - var current = root.alternate, - flags = root.flags; - if ( - !shouldFireAfterActiveInstanceBlur && - null !== focusedInstanceHandle - ) { - var JSCompiler_temp; - if ((JSCompiler_temp = 13 === root.tag)) - a: { - if (null !== current) { - var oldState = current.memoizedState; - if (null === oldState || null !== oldState.dehydrated) { - var newState = root.memoizedState; - JSCompiler_temp = - null !== newState && null === newState.dehydrated; - break a; - } - } - JSCompiler_temp = !1; - } - JSCompiler_temp && - doesFiberContain(root, focusedInstanceHandle) && - (shouldFireAfterActiveInstanceBlur = !0); - } - if (0 !== (flags & 512)) + var current = root.alternate; + if (0 !== (root.flags & 512)) switch (root.tag) { case 0: case 11: @@ -5656,10 +5616,8 @@ function commitBeforeMutationEffects(root, firstChild) { } nextEffect = root.return; } - } current = shouldFireAfterActiveInstanceBlur; shouldFireAfterActiveInstanceBlur = !1; - focusedInstanceHandle = null; return current; } function commitHookEffectListUnmount( @@ -5826,11 +5784,13 @@ function detachFiberAfterEffects(fiber) { ((fiber.alternate = null), detachFiberAfterEffects(alternate)); fiber.child = null; fiber.deletions = null; + fiber.sibling = null; + fiber.stateNode = null; + fiber.return = null; fiber.dependencies = null; fiber.memoizedProps = null; fiber.memoizedState = null; fiber.pendingProps = null; - fiber.sibling = null; fiber.stateNode = null; fiber.updateQueue = null; } @@ -7327,8 +7287,8 @@ function flushPassiveEffects() { fiber$jscomp$0 = nextEffect; var sibling = fiber$jscomp$0.sibling, returnFiber = fiber$jscomp$0.return; + detachFiberAfterEffects(fiber$jscomp$0); if (fiber$jscomp$0 === fiberToDelete) { - detachFiberAfterEffects(fiber$jscomp$0); nextEffect = null; break; } @@ -8430,10 +8390,10 @@ batchedUpdatesImpl = function(fn, a) { } }; var roots = new Map(), - devToolsConfig$jscomp$inline_1016 = { + devToolsConfig$jscomp$inline_1013 = { findFiberByHostInstance: getInstanceFromTag, bundleType: 0, - version: "18.0.0-c96b78e0e", + version: "18.0.0-568dc3532", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function() { @@ -8448,11 +8408,11 @@ var roots = new Map(), }.bind(null, findNodeHandle) } }; -var internals$jscomp$inline_1293 = { - bundleType: devToolsConfig$jscomp$inline_1016.bundleType, - version: devToolsConfig$jscomp$inline_1016.version, - rendererPackageName: devToolsConfig$jscomp$inline_1016.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1016.rendererConfig, +var internals$jscomp$inline_1287 = { + bundleType: devToolsConfig$jscomp$inline_1013.bundleType, + version: devToolsConfig$jscomp$inline_1013.version, + rendererPackageName: devToolsConfig$jscomp$inline_1013.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1013.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -8468,26 +8428,26 @@ var internals$jscomp$inline_1293 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1016.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1013.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.0.0-c96b78e0e" + reconcilerVersion: "18.0.0-568dc3532" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1294 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_1288 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_1294.isDisabled && - hook$jscomp$inline_1294.supportsFiber + !hook$jscomp$inline_1288.isDisabled && + hook$jscomp$inline_1288.supportsFiber ) try { - (rendererID = hook$jscomp$inline_1294.inject( - internals$jscomp$inline_1293 + (rendererID = hook$jscomp$inline_1288.inject( + internals$jscomp$inline_1287 )), - (injectedHook = hook$jscomp$inline_1294); + (injectedHook = hook$jscomp$inline_1288); } catch (err) {} } exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = { diff --git a/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js b/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js index 860cad09c9aa45..1406e7227ad6cb 100644 --- a/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +++ b/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js @@ -8,7 +8,7 @@ * @nolint * @providesModule ReactNativeRenderer-profiling * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<> */ "use strict"; @@ -1393,18 +1393,6 @@ function findCurrentHostFiberImpl(node) { } return null; } -function doesFiberContain(parentFiber, childFiber) { - for ( - var parentFiberAlternate = parentFiber.alternate; - null !== childFiber; - - ) { - if (childFiber === parentFiber || childFiber === parentFiberAlternate) - return !0; - childFiber = childFiber.return; - } - return !1; -} var emptyObject = {}, removedKeys = null, removedKeyCount = 0, @@ -5558,8 +5546,8 @@ function safelyDetachRef(current, nearestMountedAncestor) { recordLayoutEffectDuration(current); } else ref(null); - } catch (refError) { - captureCommitPhaseError(current, nearestMountedAncestor, refError); + } catch (error) { + captureCommitPhaseError(current, nearestMountedAncestor, error); } else ref.current = null; } @@ -5570,49 +5558,21 @@ function safelyCallDestroy(current, nearestMountedAncestor, destroy) { captureCommitPhaseError(current, nearestMountedAncestor, error); } } -var focusedInstanceHandle = null, - shouldFireAfterActiveInstanceBlur = !1; +var shouldFireAfterActiveInstanceBlur = !1; function commitBeforeMutationEffects(root, firstChild) { - focusedInstanceHandle = null; - for (nextEffect = firstChild; null !== nextEffect; ) { - root = nextEffect; - firstChild = root.deletions; - if (null !== firstChild) - for (var i = 0; i < firstChild.length; i++) - doesFiberContain(firstChild[i], focusedInstanceHandle) && - (shouldFireAfterActiveInstanceBlur = !0); - firstChild = root.child; - if (0 !== (root.subtreeFlags & 516) && null !== firstChild) + for (nextEffect = firstChild; null !== nextEffect; ) + if ( + ((root = nextEffect), + (firstChild = root.child), + 0 !== (root.subtreeFlags & 516) && null !== firstChild) + ) (firstChild.return = root), (nextEffect = firstChild); else for (; null !== nextEffect; ) { root = nextEffect; try { - var current = root.alternate, - flags = root.flags; - if ( - !shouldFireAfterActiveInstanceBlur && - null !== focusedInstanceHandle - ) { - var JSCompiler_temp; - if ((JSCompiler_temp = 13 === root.tag)) - a: { - if (null !== current) { - var oldState = current.memoizedState; - if (null === oldState || null !== oldState.dehydrated) { - var newState = root.memoizedState; - JSCompiler_temp = - null !== newState && null === newState.dehydrated; - break a; - } - } - JSCompiler_temp = !1; - } - JSCompiler_temp && - doesFiberContain(root, focusedInstanceHandle) && - (shouldFireAfterActiveInstanceBlur = !0); - } - if (0 !== (flags & 512)) + var current = root.alternate; + if (0 !== (root.flags & 512)) switch (root.tag) { case 0: case 11: @@ -5655,10 +5615,8 @@ function commitBeforeMutationEffects(root, firstChild) { } nextEffect = root.return; } - } current = shouldFireAfterActiveInstanceBlur; shouldFireAfterActiveInstanceBlur = !1; - focusedInstanceHandle = null; return current; } function commitHookEffectListUnmount( @@ -5825,11 +5783,13 @@ function detachFiberAfterEffects(fiber) { ((fiber.alternate = null), detachFiberAfterEffects(alternate)); fiber.child = null; fiber.deletions = null; + fiber.sibling = null; + fiber.stateNode = null; + fiber.return = null; fiber.dependencies = null; fiber.memoizedProps = null; fiber.memoizedState = null; fiber.pendingProps = null; - fiber.sibling = null; fiber.stateNode = null; fiber.updateQueue = null; } @@ -7322,8 +7282,8 @@ function flushPassiveEffects() { fiber$jscomp$0 = nextEffect; var sibling = fiber$jscomp$0.sibling, returnFiber = fiber$jscomp$0.return; + detachFiberAfterEffects(fiber$jscomp$0); if (fiber$jscomp$0 === fiberToDelete) { - detachFiberAfterEffects(fiber$jscomp$0); nextEffect = null; break; } @@ -8425,10 +8385,10 @@ batchedUpdatesImpl = function(fn, a) { } }; var roots = new Map(), - devToolsConfig$jscomp$inline_1016 = { + devToolsConfig$jscomp$inline_1013 = { findFiberByHostInstance: getInstanceFromTag, bundleType: 0, - version: "18.0.0-experimental-c96b78e0e", + version: "18.0.0-experimental-568dc3532", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function() { @@ -8443,11 +8403,11 @@ var roots = new Map(), }.bind(null, findNodeHandle) } }; -var internals$jscomp$inline_1293 = { - bundleType: devToolsConfig$jscomp$inline_1016.bundleType, - version: devToolsConfig$jscomp$inline_1016.version, - rendererPackageName: devToolsConfig$jscomp$inline_1016.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1016.rendererConfig, +var internals$jscomp$inline_1287 = { + bundleType: devToolsConfig$jscomp$inline_1013.bundleType, + version: devToolsConfig$jscomp$inline_1013.version, + rendererPackageName: devToolsConfig$jscomp$inline_1013.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1013.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -8463,26 +8423,26 @@ var internals$jscomp$inline_1293 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1016.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1013.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.0.0-experimental-c96b78e0e" + reconcilerVersion: "18.0.0-experimental-568dc3532" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1294 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_1288 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_1294.isDisabled && - hook$jscomp$inline_1294.supportsFiber + !hook$jscomp$inline_1288.isDisabled && + hook$jscomp$inline_1288.supportsFiber ) try { - (rendererID = hook$jscomp$inline_1294.inject( - internals$jscomp$inline_1293 + (rendererID = hook$jscomp$inline_1288.inject( + internals$jscomp$inline_1287 )), - (injectedHook = hook$jscomp$inline_1294); + (injectedHook = hook$jscomp$inline_1288); } catch (err) {} } exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = {