From a19627ef67606c5d318dae4491dd1a9f49db5156 Mon Sep 17 00:00:00 2001 From: javache Date: Tue, 10 Oct 2023 14:16:16 +0000 Subject: [PATCH] [Fabric] Pass children when cloning (#27458) ## Summary Currently when cloning nodes in Fabric, we reset a node's children on each clone, and then repeatedly call appendChild to restore the previous list of children (even if it was quasi-identical to before). This causes unnecessary invalidation of the layout state in Fabric's ShadowNode data (which in turn may require additional yoga clones) and extra JSI calls. This PR adds a feature flag to pass in the children as part of the clone call, so Fabric always has a complete view of the node that's being mutated. This feature flag requires matching changes in the react-native repo: https://github.com/facebook/react-native/pull/39817 ## How did you test this change? Unit test added demonstrates the new behaviour ``` yarn test -r www-modern ReactFabric-test yarn test ReactFabric-test.internal ``` Tested a manual sync into React Native and verified core surfaces render correctly. DiffTrain build for commit https://github.com/facebook/react/commit/151e75a128d0fd436dce365335b96c5686f704d4. --- .../cjs/ReactTestRenderer-dev.js | 7 +- .../cjs/ReactTestRenderer-prod.js | 4 +- .../cjs/ReactTestRenderer-profiling.js | 4 +- .../RKJSModules/vendor/react/cjs/React-dev.js | 2 +- .../vendor/react/cjs/React-prod.js | 2 +- .../vendor/react/cjs/React-profiling.js | 2 +- .../Libraries/Renderer/REVISION | 2 +- .../implementations/ReactFabric-dev.fb.js | 117 +++++++++++++----- .../implementations/ReactFabric-prod.fb.js | 106 ++++++++++------ .../ReactFabric-profiling.fb.js | 114 ++++++++++------- .../ReactNativeRenderer-dev.fb.js | 7 +- 11 files changed, 241 insertions(+), 126 deletions(-) diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-dev.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-dev.js index 5e6c1c7b42b2f..6887775850d5e 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-dev.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-dev.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<99f1fded76af1fea6984fd8b08571351>> + * @generated SignedSource<<73b93e8e6858b35c538fb675ac42495a>> */ 'use strict'; @@ -16335,7 +16335,8 @@ function completeWork(current, workInProgress, renderLanes) { _rootContainerInstance, _currentHostContext, workInProgress - ); + ); // TODO: For persistent renderers, we should pass children as part + // of the initial instance creation appendAllChildren(_instance3, workInProgress); workInProgress.stateNode = _instance3; // Certain renderers require commit-time effects for initial mount. @@ -24772,7 +24773,7 @@ function createFiberRoot( return root; } -var ReactVersion = "18.3.0-canary-dddfe6882-20231005"; +var ReactVersion = "18.3.0-canary-151e75a12-20231010"; // Might add PROFILE later. diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-prod.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-prod.js index 804ed8b44ff97..95da6b90d2db1 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-prod.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-prod.js @@ -8978,7 +8978,7 @@ var devToolsConfig$jscomp$inline_998 = { throw Error("TestRenderer does not support findFiberByHostInstance()"); }, bundleType: 0, - version: "18.3.0-canary-dddfe6882-20231005", + version: "18.3.0-canary-151e75a12-20231010", rendererPackageName: "react-test-renderer" }; var internals$jscomp$inline_1191 = { @@ -9009,7 +9009,7 @@ var internals$jscomp$inline_1191 = { scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-canary-dddfe6882-20231005" + reconcilerVersion: "18.3.0-canary-151e75a12-20231010" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { var hook$jscomp$inline_1192 = __REACT_DEVTOOLS_GLOBAL_HOOK__; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-profiling.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-profiling.js index 5f13a653d7821..4ad0c699f9f68 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-profiling.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-profiling.js @@ -9404,7 +9404,7 @@ var devToolsConfig$jscomp$inline_1040 = { throw Error("TestRenderer does not support findFiberByHostInstance()"); }, bundleType: 0, - version: "18.3.0-canary-dddfe6882-20231005", + version: "18.3.0-canary-151e75a12-20231010", rendererPackageName: "react-test-renderer" }; var internals$jscomp$inline_1232 = { @@ -9435,7 +9435,7 @@ var internals$jscomp$inline_1232 = { scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-canary-dddfe6882-20231005" + reconcilerVersion: "18.3.0-canary-151e75a12-20231010" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { var hook$jscomp$inline_1233 = __REACT_DEVTOOLS_GLOBAL_HOOK__; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-dev.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-dev.js index 8ecb3af856ffe..5d4054abe2f3f 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-dev.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-dev.js @@ -27,7 +27,7 @@ if ( } "use strict"; -var ReactVersion = "18.3.0-canary-dddfe6882-20231005"; +var ReactVersion = "18.3.0-canary-151e75a12-20231010"; // ATTENTION // When adding new symbols to this file, diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-prod.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-prod.js index acdb6a2b06417..a3499d754d3f5 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-prod.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-prod.js @@ -616,4 +616,4 @@ exports.useSyncExternalStore = function ( exports.useTransition = function () { return ReactCurrentDispatcher.current.useTransition(); }; -exports.version = "18.3.0-canary-dddfe6882-20231005"; +exports.version = "18.3.0-canary-151e75a12-20231010"; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-profiling.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-profiling.js index e78de28a10ed5..62bc83bea974a 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-profiling.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-profiling.js @@ -619,7 +619,7 @@ exports.useSyncExternalStore = function ( exports.useTransition = function () { return ReactCurrentDispatcher.current.useTransition(); }; -exports.version = "18.3.0-canary-dddfe6882-20231005"; +exports.version = "18.3.0-canary-151e75a12-20231010"; /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ if ( diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION index 09e55664223be..0bc8b244d911e 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION @@ -1 +1 @@ -dddfe688206dafa5646550d351eb9a8e9c53654a +151e75a128d0fd436dce365335b96c5686f704d4 diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js index 93cd1416f922d..a7bc2eb3bc073 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<> */ 'use strict'; @@ -3180,7 +3180,9 @@ var enableUseRefAccessWarning = dynamicFlags.enableUseRefAccessWarning, dynamicFlags.enableDeferRootSchedulingToMicrotask, alwaysThrottleRetries = dynamicFlags.alwaysThrottleRetries, useMicrotasksForSchedulingInFabric = - dynamicFlags.useMicrotasksForSchedulingInFabric; // The rest of the flags are static for better dead code elimination. + dynamicFlags.useMicrotasksForSchedulingInFabric, + passChildrenWhenCloningPersistedNodes = + dynamicFlags.passChildrenWhenCloningPersistedNodes; // The rest of the flags are static for better dead code elimination. var enableSchedulingProfiler = true; var enableProfilerTimer = true; var enableProfilerCommitHooks = true; @@ -5007,9 +5009,8 @@ function cloneInstance( type, oldProps, newProps, - internalInstanceHandle, keepChildren, - recyclableInstance + newChildSet ) { var viewConfig = instance.canonical.viewConfig; var updatePayload = diff(oldProps, newProps, viewConfig.validAttributes); // TODO: If the event handlers have changed, we need to update the current props @@ -5028,10 +5029,23 @@ function cloneInstance( return instance; } } else { - if (updatePayload !== null) { - clone = cloneNodeWithNewChildrenAndProps(node, updatePayload); + // If passChildrenWhenCloningPersistedNodes is enabled, children will be non-null + if (newChildSet != null) { + if (updatePayload !== null) { + clone = cloneNodeWithNewChildrenAndProps( + node, + newChildSet, + updatePayload + ); + } else { + clone = cloneNodeWithNewChildren(node, newChildSet); + } } else { - clone = cloneNodeWithNewChildren(node); + if (updatePayload !== null) { + clone = cloneNodeWithNewChildrenAndProps(node, updatePayload); + } else { + clone = cloneNodeWithNewChildren(node); + } } } @@ -5040,7 +5054,7 @@ function cloneInstance( canonical: instance.canonical }; } -function cloneHiddenInstance(instance, type, props, internalInstanceHandle) { +function cloneHiddenInstance(instance, type, props) { var viewConfig = instance.canonical.viewConfig; var node = instance.node; var updatePayload = create( @@ -5056,19 +5070,29 @@ function cloneHiddenInstance(instance, type, props, internalInstanceHandle) { canonical: instance.canonical }; } -function cloneHiddenTextInstance(instance, text, internalInstanceHandle) { +function cloneHiddenTextInstance(instance, text) { throw new Error("Not yet implemented."); } -function createContainerChildSet(container) { - return createChildNodeSet(container); +function createContainerChildSet() { + if (passChildrenWhenCloningPersistedNodes) { + return []; + } else { + return createChildNodeSet(); + } } function appendChildToContainerChildSet(childSet, child) { - appendChildNodeToSet(childSet, child.node); + if (passChildrenWhenCloningPersistedNodes) { + childSet.push(child.node); + } else { + appendChildNodeToSet(childSet, child.node); + } } function finalizeContainerChildren(container, newChildren) { completeRoot(container, newChildren); } -function replaceContainerChildren(container, newChildren) {} +function replaceContainerChildren(container, newChildren) { + // Noop - children will be replaced in finalizeContainerChildren +} function preloadInstance(type, props) { return true; } @@ -18734,7 +18758,6 @@ function appendAllChildren( var _node = workInProgress.child; while (_node !== null) { - // eslint-disable-next-line no-labels if (_node.tag === HostComponent) { var instance = _node.stateNode; @@ -18764,7 +18787,14 @@ function appendAllChildren( child.return = _node; } - appendAllChildren(parent, _node, true, true); + appendAllChildren( + parent, + _node, + /* needsVisibilityToggle */ + true, + /* isHidden */ + true + ); } else if (_node.child !== null) { _node.child.return = _node; _node = _node.child; @@ -18836,7 +18866,9 @@ function appendAllChildrenToContainer( appendAllChildrenToContainer( containerChildSet, node, + /* needsVisibilityToggle */ _needsVisibilityToggle, + /* isHidden */ true ); } else if (node.child !== null) { @@ -18874,9 +18906,16 @@ function updateHostContainer(current, workInProgress) { if (childrenUnchanged); else { var container = portalOrRoot.containerInfo; - var newChildSet = createContainerChildSet(container); // If children might have changed, we have to add them all to the set. + var newChildSet = createContainerChildSet(); // If children might have changed, we have to add them all to the set. - appendAllChildrenToContainer(newChildSet, workInProgress, false, false); + appendAllChildrenToContainer( + newChildSet, + workInProgress, + /* needsVisibilityToggle */ + false, + /* isHidden */ + false + ); portalOrRoot.pendingChildren = newChildSet; // Schedule an update on the container to swap out the container. markUpdate(workInProgress); @@ -18905,14 +18944,30 @@ function updateHostComponent( workInProgress.stateNode = currentInstance; return; } + getHostContext(); + var newChildSet = null; + + if (!childrenUnchanged && passChildrenWhenCloningPersistedNodes) { + newChildSet = createContainerChildSet(); // If children might have changed, we have to add them all to the set. + + appendAllChildrenToContainer( + newChildSet, + workInProgress, + /* needsVisibilityToggle */ + false, + /* isHidden */ + false + ); + } + var newInstance = cloneInstance( currentInstance, type, _oldProps, newProps, - workInProgress, - childrenUnchanged + childrenUnchanged, + newChildSet ); if (newInstance === currentInstance) { @@ -18920,7 +18975,7 @@ function updateHostComponent( // Note that this might release a previous clone. workInProgress.stateNode = currentInstance; return; - } + } // Certain renderers require commit-time effects for initial mount. workInProgress.stateNode = newInstance; @@ -18929,9 +18984,16 @@ function updateHostComponent( // Even though we're not going to use it for anything. // Otherwise parents won't know that there are new children to propagate upwards. markUpdate(workInProgress); - } else { + } else if (!passChildrenWhenCloningPersistedNodes) { // If children might have changed, we have to add them all to the set. - appendAllChildren(newInstance, workInProgress, false, false); + appendAllChildren( + newInstance, + workInProgress, + /* needsVisibilityToggle */ + false, + /* isHidden */ + false + ); } } } // This function must be called at the very end of the complete phase, because @@ -19399,7 +19461,8 @@ function completeWork(current, workInProgress, renderLanes) { _rootContainerInstance, _currentHostContext, workInProgress - ); + ); // TODO: For persistent renderers, we should pass children as part + // of the initial instance creation appendAllChildren(_instance3, workInProgress, false, false); workInProgress.stateNode = _instance3; // Certain renderers require commit-time effects for initial mount. @@ -21092,9 +21155,7 @@ function detachFiberAfterEffects(fiber) { } function emptyPortalContainer(current) { - var portal = current.stateNode; - var containerInfo = portal.containerInfo; - createContainerChildSet(containerInfo); + createContainerChildSet(); } function commitPlacement(finishedWork) { @@ -21167,7 +21228,7 @@ function commitDeletionEffectsOnFiber( case HostPortal: { { - emptyPortalContainer(deletedFiber); + emptyPortalContainer(); recursivelyTraverseDeletionEffects( finishedRoot, nearestMountedAncestor, @@ -27063,7 +27124,7 @@ function createFiberRoot( return root; } -var ReactVersion = "18.3.0-canary-112791ea"; +var ReactVersion = "18.3.0-canary-4b68b914"; function createPortal$1( children, diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-prod.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-prod.fb.js index caf1cb1f73942..b644c1239a6cb 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-prod.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-prod.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<35a02eea4da4b468c9397d48533b560b>> + * @generated SignedSource<<27f98703fa1feb0efea3c70de170400c>> */ "use strict"; @@ -1320,6 +1320,8 @@ var enableUseRefAccessWarning = dynamicFlags.enableUseRefAccessWarning, alwaysThrottleRetries = dynamicFlags.alwaysThrottleRetries, useMicrotasksForSchedulingInFabric = dynamicFlags.useMicrotasksForSchedulingInFabric, + passChildrenWhenCloningPersistedNodes = + dynamicFlags.passChildrenWhenCloningPersistedNodes, scheduleCallback$2 = Scheduler.unstable_scheduleCallback, cancelCallback$1 = Scheduler.unstable_cancelCallback, shouldYield = Scheduler.unstable_shouldYield, @@ -5822,16 +5824,22 @@ function appendAllChildrenToContainer( needsVisibilityToggle && isHidden && (instance = cloneHiddenInstance(instance)); - appendChildNodeToSet(containerChildSet, instance.node); + var childSet = containerChildSet; + passChildrenWhenCloningPersistedNodes + ? childSet.push(instance.node) + : appendChildNodeToSet(childSet, instance.node); } else if (6 === node.tag) { instance = node.stateNode; if (needsVisibilityToggle && isHidden) throw Error("Not yet implemented."); - appendChildNodeToSet(containerChildSet, instance.node); + childSet = containerChildSet; + passChildrenWhenCloningPersistedNodes + ? childSet.push(instance.node) + : appendChildNodeToSet(childSet, instance.node); } else if (4 !== node.tag) if (22 === node.tag && null !== node.memoizedState) - (instance = node.child), - null !== instance && (instance.return = node), + (childSet = node.child), + null !== childSet && (childSet.return = node), appendAllChildrenToContainer( containerChildSet, node, @@ -5859,7 +5867,9 @@ function updateHostContainer(current, workInProgress) { var portalOrRoot = workInProgress.stateNode; if (!hadNoMutationsEffects(current, workInProgress)) { current = portalOrRoot.containerInfo; - var newChildSet = createChildNodeSet(current); + var newChildSet = passChildrenWhenCloningPersistedNodes + ? [] + : createChildNodeSet(); appendAllChildrenToContainer(newChildSet, workInProgress, !1, !1); portalOrRoot.pendingChildren = newChildSet; workInProgress.flags |= 4; @@ -5975,6 +5985,13 @@ function completeWork(current, workInProgress, renderLanes) { if (childrenUnchanged && oldProps === newProps) workInProgress.stateNode = renderLanes; else { + var newChildSet = null; + !childrenUnchanged && + passChildrenWhenCloningPersistedNodes && + ((newChildSet = passChildrenWhenCloningPersistedNodes + ? [] + : createChildNodeSet()), + appendAllChildrenToContainer(newChildSet, workInProgress, !1, !1)); b: { oldProps = diffProperties( null, @@ -5993,7 +6010,15 @@ function completeWork(current, workInProgress, renderLanes) { } else newProps = - null !== oldProps + null != newChildSet + ? null !== oldProps + ? cloneNodeWithNewChildrenAndProps( + newProps, + newChildSet, + oldProps + ) + : cloneNodeWithNewChildren(newProps, newChildSet) + : null !== oldProps ? cloneNodeWithNewChildrenAndProps(newProps, oldProps) : cloneNodeWithNewChildren(newProps); newProps = { node: newProps, canonical: renderLanes.canonical }; @@ -6003,7 +6028,8 @@ function completeWork(current, workInProgress, renderLanes) { : ((workInProgress.stateNode = newProps), childrenUnchanged ? (workInProgress.flags |= 4) - : appendAllChildren(newProps, workInProgress, !1, !1)); + : passChildrenWhenCloningPersistedNodes || + appendAllChildren(newProps, workInProgress, !1, !1)); } current.ref !== workInProgress.ref && (workInProgress.flags |= 2097664); } else { @@ -6019,7 +6045,7 @@ function completeWork(current, workInProgress, renderLanes) { current = nextReactTag; nextReactTag += 2; renderLanes = getViewConfigForType(renderLanes); - oldProps = diffProperties( + newChildSet = diffProperties( null, emptyObject$1, newProps, @@ -6029,10 +6055,10 @@ function completeWork(current, workInProgress, renderLanes) { current, renderLanes.uiViewClassName, childrenUnchanged, - oldProps, + newChildSet, workInProgress ); - oldProps = ReactNativePrivateInterface.createPublicInstance( + newChildSet = ReactNativePrivateInterface.createPublicInstance( current, renderLanes, workInProgress @@ -6044,7 +6070,7 @@ function completeWork(current, workInProgress, renderLanes) { viewConfig: renderLanes, currentProps: newProps, internalInstanceHandle: workInProgress, - publicInstance: oldProps + publicInstance: newChildSet } }; appendAllChildren(current, workInProgress, !1, !1); @@ -6142,8 +6168,8 @@ function completeWork(current, workInProgress, renderLanes) { if (null === childrenUnchanged) return bubbleProperties(workInProgress), null; newProps = 0 !== (workInProgress.flags & 128); - oldProps = childrenUnchanged.rendering; - if (null === oldProps) + newChildSet = childrenUnchanged.rendering; + if (null === newChildSet) if (newProps) cutOffTailIfNeeded(childrenUnchanged, !1); else { if ( @@ -6151,11 +6177,11 @@ function completeWork(current, workInProgress, renderLanes) { (null !== current && 0 !== (current.flags & 128)) ) for (current = workInProgress.child; null !== current; ) { - oldProps = findFirstSuspended(current); - if (null !== oldProps) { + newChildSet = findFirstSuspended(current); + if (null !== newChildSet) { workInProgress.flags |= 128; cutOffTailIfNeeded(childrenUnchanged, !1); - current = oldProps.updateQueue; + current = newChildSet.updateQueue; workInProgress.updateQueue = current; scheduleRetryEffect(workInProgress, current); workInProgress.subtreeFlags = 0; @@ -6180,7 +6206,7 @@ function completeWork(current, workInProgress, renderLanes) { } else { if (!newProps) - if (((current = findFirstSuspended(oldProps)), null !== current)) { + if (((current = findFirstSuspended(newChildSet)), null !== current)) { if ( ((workInProgress.flags |= 128), (newProps = !0), @@ -6190,7 +6216,7 @@ function completeWork(current, workInProgress, renderLanes) { cutOffTailIfNeeded(childrenUnchanged, !0), null === childrenUnchanged.tail && "hidden" === childrenUnchanged.tailMode && - !oldProps.alternate) + !newChildSet.alternate) ) return bubbleProperties(workInProgress), null; } else @@ -6202,13 +6228,13 @@ function completeWork(current, workInProgress, renderLanes) { cutOffTailIfNeeded(childrenUnchanged, !1), (workInProgress.lanes = 8388608)); childrenUnchanged.isBackwards - ? ((oldProps.sibling = workInProgress.child), - (workInProgress.child = oldProps)) + ? ((newChildSet.sibling = workInProgress.child), + (workInProgress.child = newChildSet)) : ((current = childrenUnchanged.last), null !== current - ? (current.sibling = oldProps) - : (workInProgress.child = oldProps), - (childrenUnchanged.last = oldProps)); + ? (current.sibling = newChildSet) + : (workInProgress.child = newChildSet), + (childrenUnchanged.last = newChildSet)); } if (null !== childrenUnchanged.tail) return ( @@ -6696,7 +6722,7 @@ function commitDeletionEffectsOnFiber( case 18: break; case 4: - createChildNodeSet(deletedFiber.stateNode.containerInfo); + passChildrenWhenCloningPersistedNodes || createChildNodeSet(); recursivelyTraverseDeletionEffects( finishedRoot, nearestMountedAncestor, @@ -9437,10 +9463,10 @@ batchedUpdatesImpl = function (fn, a) { } }; var roots = new Map(), - devToolsConfig$jscomp$inline_1035 = { + devToolsConfig$jscomp$inline_1032 = { findFiberByHostInstance: getInstanceFromNode, bundleType: 0, - version: "18.3.0-canary-6367a5b9", + version: "18.3.0-canary-68bb52fc", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForInstance: getInspectorDataForInstance, @@ -9456,11 +9482,11 @@ var roots = new Map(), }.bind(null, findNodeHandle) } }; -var internals$jscomp$inline_1277 = { - bundleType: devToolsConfig$jscomp$inline_1035.bundleType, - version: devToolsConfig$jscomp$inline_1035.version, - rendererPackageName: devToolsConfig$jscomp$inline_1035.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1035.rendererConfig, +var internals$jscomp$inline_1274 = { + bundleType: devToolsConfig$jscomp$inline_1032.bundleType, + version: devToolsConfig$jscomp$inline_1032.version, + rendererPackageName: devToolsConfig$jscomp$inline_1032.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1032.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -9476,26 +9502,26 @@ var internals$jscomp$inline_1277 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1035.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1032.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-canary-6367a5b9" + reconcilerVersion: "18.3.0-canary-68bb52fc" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1278 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_1275 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_1278.isDisabled && - hook$jscomp$inline_1278.supportsFiber + !hook$jscomp$inline_1275.isDisabled && + hook$jscomp$inline_1275.supportsFiber ) try { - (rendererID = hook$jscomp$inline_1278.inject( - internals$jscomp$inline_1277 + (rendererID = hook$jscomp$inline_1275.inject( + internals$jscomp$inline_1274 )), - (injectedHook = hook$jscomp$inline_1278); + (injectedHook = hook$jscomp$inline_1275); } catch (err) {} } exports.createPortal = function (children, containerTag) { diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js index a000be1b1998e..6de981c2c3799 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<<22e592d0aff592aea0c72beaaeae2d2e>> */ @@ -1331,6 +1331,8 @@ var enableUseRefAccessWarning = dynamicFlags.enableUseRefAccessWarning, alwaysThrottleRetries = dynamicFlags.alwaysThrottleRetries, useMicrotasksForSchedulingInFabric = dynamicFlags.useMicrotasksForSchedulingInFabric, + passChildrenWhenCloningPersistedNodes = + dynamicFlags.passChildrenWhenCloningPersistedNodes, scheduleCallback$2 = Scheduler.unstable_scheduleCallback, cancelCallback$1 = Scheduler.unstable_cancelCallback, shouldYield = Scheduler.unstable_shouldYield, @@ -6052,16 +6054,22 @@ function appendAllChildrenToContainer( needsVisibilityToggle && isHidden && (instance = cloneHiddenInstance(instance)); - appendChildNodeToSet(containerChildSet, instance.node); + var childSet = containerChildSet; + passChildrenWhenCloningPersistedNodes + ? childSet.push(instance.node) + : appendChildNodeToSet(childSet, instance.node); } else if (6 === node.tag) { instance = node.stateNode; if (needsVisibilityToggle && isHidden) throw Error("Not yet implemented."); - appendChildNodeToSet(containerChildSet, instance.node); + childSet = containerChildSet; + passChildrenWhenCloningPersistedNodes + ? childSet.push(instance.node) + : appendChildNodeToSet(childSet, instance.node); } else if (4 !== node.tag) if (22 === node.tag && null !== node.memoizedState) - (instance = node.child), - null !== instance && (instance.return = node), + (childSet = node.child), + null !== childSet && (childSet.return = node), appendAllChildrenToContainer( containerChildSet, node, @@ -6089,7 +6097,9 @@ function updateHostContainer(current, workInProgress) { var portalOrRoot = workInProgress.stateNode; if (!hadNoMutationsEffects(current, workInProgress)) { current = portalOrRoot.containerInfo; - var newChildSet = createChildNodeSet(current); + var newChildSet = passChildrenWhenCloningPersistedNodes + ? [] + : createChildNodeSet(); appendAllChildrenToContainer(newChildSet, workInProgress, !1, !1); portalOrRoot.pendingChildren = newChildSet; workInProgress.flags |= 4; @@ -6210,13 +6220,13 @@ function completeWork(current, workInProgress, renderLanes) { ); case 3: return ( - (renderLanes = workInProgress.stateNode), + (newProps = workInProgress.stateNode), popHostContainer(), pop(didPerformWorkStackCursor), pop(contextStackCursor$1), - renderLanes.pendingContext && - ((renderLanes.context = renderLanes.pendingContext), - (renderLanes.pendingContext = null)), + newProps.pendingContext && + ((newProps.context = newProps.pendingContext), + (newProps.pendingContext = null)), (null !== current && null !== current.child) || null === current || (current.memoizedState.isDehydrated && @@ -6241,6 +6251,13 @@ function completeWork(current, workInProgress, renderLanes) { if (childrenUnchanged && oldProps === newProps) workInProgress.stateNode = renderLanes; else { + var newChildSet = null; + !childrenUnchanged && + passChildrenWhenCloningPersistedNodes && + ((newChildSet = passChildrenWhenCloningPersistedNodes + ? [] + : createChildNodeSet()), + appendAllChildrenToContainer(newChildSet, workInProgress, !1, !1)); b: { oldProps = diffProperties( null, @@ -6259,7 +6276,15 @@ function completeWork(current, workInProgress, renderLanes) { } else newProps = - null !== oldProps + null != newChildSet + ? null !== oldProps + ? cloneNodeWithNewChildrenAndProps( + newProps, + newChildSet, + oldProps + ) + : cloneNodeWithNewChildren(newProps, newChildSet) + : null !== oldProps ? cloneNodeWithNewChildrenAndProps(newProps, oldProps) : cloneNodeWithNewChildren(newProps); newProps = { node: newProps, canonical: renderLanes.canonical }; @@ -6269,7 +6294,8 @@ function completeWork(current, workInProgress, renderLanes) { : ((workInProgress.stateNode = newProps), childrenUnchanged ? (workInProgress.flags |= 4) - : appendAllChildren(newProps, workInProgress, !1, !1)); + : passChildrenWhenCloningPersistedNodes || + appendAllChildren(newProps, workInProgress, !1, !1)); } current.ref !== workInProgress.ref && (workInProgress.flags |= 2097664); } else { @@ -6285,7 +6311,7 @@ function completeWork(current, workInProgress, renderLanes) { current = nextReactTag; nextReactTag += 2; renderLanes = getViewConfigForType(renderLanes); - oldProps = diffProperties( + newChildSet = diffProperties( null, emptyObject$1, newProps, @@ -6295,10 +6321,10 @@ function completeWork(current, workInProgress, renderLanes) { current, renderLanes.uiViewClassName, childrenUnchanged, - oldProps, + newChildSet, workInProgress ); - oldProps = ReactNativePrivateInterface.createPublicInstance( + newChildSet = ReactNativePrivateInterface.createPublicInstance( current, renderLanes, workInProgress @@ -6310,7 +6336,7 @@ function completeWork(current, workInProgress, renderLanes) { viewConfig: renderLanes, currentProps: newProps, internalInstanceHandle: workInProgress, - publicInstance: oldProps + publicInstance: newChildSet } }; appendAllChildren(current, workInProgress, !1, !1); @@ -6387,14 +6413,14 @@ function completeWork(current, workInProgress, renderLanes) { transferActualDuration(workInProgress), workInProgress ); - renderLanes = null !== newProps; - renderLanes !== (null !== current && null !== current.memoizedState) && - renderLanes && + newProps = null !== newProps; + newProps !== (null !== current && null !== current.memoizedState) && + newProps && (workInProgress.child.flags |= 8192); scheduleRetryEffect(workInProgress, workInProgress.updateQueue); bubbleProperties(workInProgress); 0 !== (workInProgress.mode & 2) && - renderLanes && + newProps && ((current = workInProgress.child), null !== current && (workInProgress.treeBaseDuration -= current.treeBaseDuration)); @@ -6424,8 +6450,8 @@ function completeWork(current, workInProgress, renderLanes) { if (null === childrenUnchanged) return bubbleProperties(workInProgress), null; newProps = 0 !== (workInProgress.flags & 128); - oldProps = childrenUnchanged.rendering; - if (null === oldProps) + newChildSet = childrenUnchanged.rendering; + if (null === newChildSet) if (newProps) cutOffTailIfNeeded(childrenUnchanged, !1); else { if ( @@ -6433,18 +6459,18 @@ function completeWork(current, workInProgress, renderLanes) { (null !== current && 0 !== (current.flags & 128)) ) for (current = workInProgress.child; null !== current; ) { - oldProps = findFirstSuspended(current); - if (null !== oldProps) { + newChildSet = findFirstSuspended(current); + if (null !== newChildSet) { workInProgress.flags |= 128; cutOffTailIfNeeded(childrenUnchanged, !1); - current = oldProps.updateQueue; + current = newChildSet.updateQueue; workInProgress.updateQueue = current; scheduleRetryEffect(workInProgress, current); workInProgress.subtreeFlags = 0; current = renderLanes; - for (renderLanes = workInProgress.child; null !== renderLanes; ) - resetWorkInProgress(renderLanes, current), - (renderLanes = renderLanes.sibling); + for (newProps = workInProgress.child; null !== newProps; ) + resetWorkInProgress(newProps, current), + (newProps = newProps.sibling); push( suspenseStackCursor, (suspenseStackCursor.current & 1) | 2 @@ -6462,7 +6488,7 @@ function completeWork(current, workInProgress, renderLanes) { } else { if (!newProps) - if (((current = findFirstSuspended(oldProps)), null !== current)) { + if (((current = findFirstSuspended(newChildSet)), null !== current)) { if ( ((workInProgress.flags |= 128), (newProps = !0), @@ -6472,7 +6498,7 @@ function completeWork(current, workInProgress, renderLanes) { cutOffTailIfNeeded(childrenUnchanged, !0), null === childrenUnchanged.tail && "hidden" === childrenUnchanged.tailMode && - !oldProps.alternate) + !newChildSet.alternate) ) return bubbleProperties(workInProgress), null; } else @@ -6484,13 +6510,13 @@ function completeWork(current, workInProgress, renderLanes) { cutOffTailIfNeeded(childrenUnchanged, !1), (workInProgress.lanes = 8388608)); childrenUnchanged.isBackwards - ? ((oldProps.sibling = workInProgress.child), - (workInProgress.child = oldProps)) + ? ((newChildSet.sibling = workInProgress.child), + (workInProgress.child = newChildSet)) : ((current = childrenUnchanged.last), null !== current - ? (current.sibling = oldProps) - : (workInProgress.child = oldProps), - (childrenUnchanged.last = oldProps)); + ? (current.sibling = newChildSet) + : (workInProgress.child = newChildSet), + (childrenUnchanged.last = newChildSet)); } if (null !== childrenUnchanged.tail) return ( @@ -7142,7 +7168,7 @@ function commitDeletionEffectsOnFiber( case 18: break; case 4: - createChildNodeSet(deletedFiber.stateNode.containerInfo); + passChildrenWhenCloningPersistedNodes || createChildNodeSet(); recursivelyTraverseDeletionEffects( finishedRoot, nearestMountedAncestor, @@ -10145,10 +10171,10 @@ batchedUpdatesImpl = function (fn, a) { } }; var roots = new Map(), - devToolsConfig$jscomp$inline_1113 = { + devToolsConfig$jscomp$inline_1110 = { findFiberByHostInstance: getInstanceFromNode, bundleType: 0, - version: "18.3.0-canary-00f435b3", + version: "18.3.0-canary-458981f7", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForInstance: getInspectorDataForInstance, @@ -10178,10 +10204,10 @@ var roots = new Map(), } catch (err) {} return hook.checkDCE ? !0 : !1; })({ - bundleType: devToolsConfig$jscomp$inline_1113.bundleType, - version: devToolsConfig$jscomp$inline_1113.version, - rendererPackageName: devToolsConfig$jscomp$inline_1113.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1113.rendererConfig, + bundleType: devToolsConfig$jscomp$inline_1110.bundleType, + version: devToolsConfig$jscomp$inline_1110.version, + rendererPackageName: devToolsConfig$jscomp$inline_1110.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1110.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -10197,14 +10223,14 @@ var roots = new Map(), return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1113.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1110.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-canary-00f435b3" + reconcilerVersion: "18.3.0-canary-458981f7" }); exports.createPortal = function (children, containerTag) { return createPortal$1( diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js index d0c8b04c4b430..b818e8d967535 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<543fb8317c4df4706b2ce72a1d3b1115>> + * @generated SignedSource<<618d7f1ec57772dec84c06297453ecaa>> */ 'use strict'; @@ -19500,7 +19500,8 @@ function completeWork(current, workInProgress, renderLanes) { _rootContainerInstance, _currentHostContext, workInProgress - ); + ); // TODO: For persistent renderers, we should pass children as part + // of the initial instance creation appendAllChildren(_instance3, workInProgress); workInProgress.stateNode = _instance3; // Certain renderers require commit-time effects for initial mount. @@ -27553,7 +27554,7 @@ function createFiberRoot( return root; } -var ReactVersion = "18.3.0-canary-7f160471"; +var ReactVersion = "18.3.0-canary-acf14d9e"; function createPortal$1( children,