Skip to content

Commit 7a7933b

Browse files
committed
Cloned flag to avoid extra clones in persistent renderer (#27647)
Persistent renderers used the `Update` effect flag to check if a subtree needs to be cloned. In some cases, that causes extra renders, such as when a layout effect is triggered which only has an effect on the JS side, but doesn't update the host components. It's been a bit tricky to find the right places where this needs to be set and I'm not 100% sure I got all the cases even though the tests passed. DiffTrain build for commit 5fb67fa.
1 parent 9fc6c4c commit 7a7933b

File tree

14 files changed

+164
-96
lines changed

14 files changed

+164
-96
lines changed

compiled-rn/VERSION_NATIVE_FB

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
19.0.0-native-fb-88ee14ff-20240801
1+
19.0.0-native-fb-5fb67fa2-20240801

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<447f54fecd5a2fc72cfafd67c4e0dd53>>
10+
* @generated SignedSource<<fda434fa15a0692f5d5d9b1129466284>>
1111
*/
1212

1313
"use strict";
@@ -14925,11 +14925,11 @@ __DEV__ &&
1492514925
(function () {
1492614926
var internals = {
1492714927
bundleType: 1,
14928-
version: "19.0.0-native-fb-88ee14ff-20240801",
14928+
version: "19.0.0-native-fb-5fb67fa2-20240801",
1492914929
rendererPackageName: "react-test-renderer",
1493014930
currentDispatcherRef: ReactSharedInternals,
1493114931
findFiberByHostInstance: getInstanceFromNode,
14932-
reconcilerVersion: "19.0.0-native-fb-88ee14ff-20240801"
14932+
reconcilerVersion: "19.0.0-native-fb-5fb67fa2-20240801"
1493314933
};
1493414934
internals.overrideHookState = overrideHookState;
1493514935
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -15074,5 +15074,5 @@ __DEV__ &&
1507415074
flushSyncWorkAcrossRoots_impl(!0));
1507515075
}
1507615076
};
15077-
exports.version = "19.0.0-native-fb-88ee14ff-20240801";
15077+
exports.version = "19.0.0-native-fb-5fb67fa2-20240801";
1507815078
})();

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

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

1313
"use strict";
@@ -9311,14 +9311,14 @@ function wrapFiber(fiber) {
93119311
}
93129312
var internals$jscomp$inline_1206 = {
93139313
bundleType: 0,
9314-
version: "19.0.0-native-fb-88ee14ff-20240801",
9314+
version: "19.0.0-native-fb-5fb67fa2-20240801",
93159315
rendererPackageName: "react-test-renderer",
93169316
currentDispatcherRef: ReactSharedInternals,
93179317
findFiberByHostInstance: function (mockNode) {
93189318
mockNode = nodeToInstanceMap.get(mockNode);
93199319
return void 0 !== mockNode ? mockNode.internalInstanceHandle : null;
93209320
},
9321-
reconcilerVersion: "19.0.0-native-fb-88ee14ff-20240801"
9321+
reconcilerVersion: "19.0.0-native-fb-5fb67fa2-20240801"
93229322
};
93239323
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
93249324
var hook$jscomp$inline_1207 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
@@ -9454,4 +9454,4 @@ exports.unstable_batchedUpdates = function (fn, a) {
94549454
flushSyncWorkAcrossRoots_impl(!0));
94559455
}
94569456
};
9457-
exports.version = "19.0.0-native-fb-88ee14ff-20240801";
9457+
exports.version = "19.0.0-native-fb-5fb67fa2-20240801";

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<ce909fecc578f22876a2f4bdb176423e>>
10+
* @generated SignedSource<<0085c47726e639d7465c75af71cebff4>>
1111
*/
1212

1313
"use strict";
@@ -9924,14 +9924,14 @@ function wrapFiber(fiber) {
99249924
}
99259925
var internals$jscomp$inline_1115 = {
99269926
bundleType: 0,
9927-
version: "19.0.0-native-fb-88ee14ff-20240801",
9927+
version: "19.0.0-native-fb-5fb67fa2-20240801",
99289928
rendererPackageName: "react-test-renderer",
99299929
currentDispatcherRef: ReactSharedInternals,
99309930
findFiberByHostInstance: function (mockNode) {
99319931
mockNode = nodeToInstanceMap.get(mockNode);
99329932
return void 0 !== mockNode ? mockNode.internalInstanceHandle : null;
99339933
},
9934-
reconcilerVersion: "19.0.0-native-fb-88ee14ff-20240801",
9934+
reconcilerVersion: "19.0.0-native-fb-5fb67fa2-20240801",
99359935
getLaneLabelMap: function () {
99369936
for (
99379937
var map = new Map(), lane = 1, index$148 = 0;
@@ -10082,4 +10082,4 @@ exports.unstable_batchedUpdates = function (fn, a) {
1008210082
flushSyncWorkAcrossRoots_impl(!0));
1008310083
}
1008410084
};
10085-
exports.version = "19.0.0-native-fb-88ee14ff-20240801";
10085+
exports.version = "19.0.0-native-fb-5fb67fa2-20240801";

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

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

1313
"use strict";
@@ -1705,7 +1705,7 @@ __DEV__ &&
17051705
exports.useTransition = function () {
17061706
return resolveDispatcher().useTransition();
17071707
};
1708-
exports.version = "19.0.0-native-fb-88ee14ff-20240801";
1708+
exports.version = "19.0.0-native-fb-5fb67fa2-20240801";
17091709
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
17101710
"function" ===
17111711
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

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

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

1313
"use strict";
@@ -580,4 +580,4 @@ exports.useSyncExternalStore = function (
580580
exports.useTransition = function () {
581581
return ReactSharedInternals.H.useTransition();
582582
};
583-
exports.version = "19.0.0-native-fb-88ee14ff-20240801";
583+
exports.version = "19.0.0-native-fb-5fb67fa2-20240801";

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

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

1313
"use strict";
@@ -584,7 +584,7 @@ exports.useSyncExternalStore = function (
584584
exports.useTransition = function () {
585585
return ReactSharedInternals.H.useTransition();
586586
};
587-
exports.version = "19.0.0-native-fb-88ee14ff-20240801";
587+
exports.version = "19.0.0-native-fb-5fb67fa2-20240801";
588588
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
589589
"function" ===
590590
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
88ee14ffa57beb0689f26f0c52c357e3ac446af8
1+
5fb67fa25c4ea8be046c6d9af41047f3cc379279

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

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

1313
"use strict";
@@ -8986,13 +8986,17 @@ __DEV__ &&
89868986
? null
89878987
: { parent: CacheContext._currentValue2, pool: cacheFromPool };
89888988
}
8989+
function markCloned(workInProgress) {
8990+
enablePersistedModeClonedFlag && (workInProgress.flags |= 8);
8991+
}
89898992
function doesRequireClone(current, completedWork) {
89908993
if (null !== current && current.child === completedWork.child) return !1;
89918994
if (0 !== (completedWork.flags & 16)) return !0;
89928995
for (current = completedWork.child; null !== current; ) {
8996+
completedWork = enablePersistedModeClonedFlag ? 8218 : 13878;
89938997
if (
8994-
0 !== (current.flags & 13878) ||
8995-
0 !== (current.subtreeFlags & 13878)
8998+
0 !== (current.flags & completedWork) ||
8999+
0 !== (current.subtreeFlags & completedWork)
89969000
)
89979001
return !0;
89989002
current = current.sibling;
@@ -9255,7 +9259,8 @@ __DEV__ &&
92559259
var newChildSet = null;
92569260
current &&
92579261
passChildrenWhenCloningPersistedNodes &&
9258-
((newChildSet = passChildrenWhenCloningPersistedNodes
9262+
(markCloned(workInProgress),
9263+
(newChildSet = passChildrenWhenCloningPersistedNodes
92599264
? []
92609265
: createChildNodeSet()),
92619266
appendAllChildrenToContainer(
@@ -9298,11 +9303,13 @@ __DEV__ &&
92989303
}
92999304
newProps === renderLanes
93009305
? (workInProgress.stateNode = renderLanes)
9301-
: ((workInProgress.stateNode = newProps),
9306+
: (markCloned(workInProgress),
9307+
(workInProgress.stateNode = newProps),
93029308
current
93039309
? passChildrenWhenCloningPersistedNodes ||
93049310
appendAllChildren(newProps, workInProgress, !1, !1)
9305-
: (workInProgress.flags |= 4));
9311+
: enablePersistedModeClonedFlag ||
9312+
(workInProgress.flags |= 4));
93069313
} else workInProgress.stateNode = renderLanes;
93079314
} else {
93089315
if (!newProps) {
@@ -9346,6 +9353,7 @@ __DEV__ &&
93469353
publicInstance: _oldProps
93479354
}
93489355
};
9356+
markCloned(workInProgress);
93499357
appendAllChildren(current, workInProgress, !1, !1);
93509358
workInProgress.stateNode = current;
93519359
}
@@ -9357,13 +9365,14 @@ __DEV__ &&
93579365
current.memoizedProps !== newProps
93589366
? ((current = requiredContext(rootInstanceStackCursor.current)),
93599367
(renderLanes = requiredContext(contextStackCursor.current)),
9368+
markCloned(workInProgress),
93609369
(workInProgress.stateNode = createTextInstance(
93619370
newProps,
93629371
current,
93639372
renderLanes,
93649373
workInProgress
93659374
)),
9366-
(workInProgress.flags |= 4))
9375+
enablePersistedModeClonedFlag || (workInProgress.flags |= 4))
93679376
: (workInProgress.stateNode = current.stateNode);
93689377
else {
93699378
if (
@@ -9375,6 +9384,7 @@ __DEV__ &&
93759384
);
93769385
current = requiredContext(rootInstanceStackCursor.current);
93779386
renderLanes = requiredContext(contextStackCursor.current);
9387+
markCloned(workInProgress);
93789388
workInProgress.stateNode = createTextInstance(
93799389
newProps,
93809390
current,
@@ -10573,7 +10583,10 @@ __DEV__ &&
1057310583
captureCommitPhaseError(childToDelete, parentFiber, error$22);
1057410584
}
1057510585
}
10576-
if (parentFiber.subtreeFlags & 13878)
10586+
if (
10587+
parentFiber.subtreeFlags &
10588+
(enablePersistedModeClonedFlag ? 13886 : 13878)
10589+
)
1057710590
for (parentFiber = parentFiber.child; null !== parentFiber; )
1057810591
runWithFiberInDEV(
1057910592
parentFiber,
@@ -14169,6 +14182,8 @@ __DEV__ &&
1416914182
enableFabricCompleteRootInCommitPhase =
1417014183
dynamicFlagsUntyped.enableFabricCompleteRootInCommitPhase,
1417114184
enableObjectFiber = dynamicFlagsUntyped.enableObjectFiber,
14185+
enablePersistedModeClonedFlag =
14186+
dynamicFlagsUntyped.enablePersistedModeClonedFlag,
1417214187
enableShallowPropDiffing = dynamicFlagsUntyped.enableShallowPropDiffing,
1417314188
passChildrenWhenCloningPersistedNodes =
1417414189
dynamicFlagsUntyped.passChildrenWhenCloningPersistedNodes,
@@ -16901,11 +16916,11 @@ __DEV__ &&
1690116916
(function () {
1690216917
var internals = {
1690316918
bundleType: 1,
16904-
version: "19.0.0-native-fb-88ee14ff-20240801",
16919+
version: "19.0.0-native-fb-5fb67fa2-20240801",
1690516920
rendererPackageName: "react-native-renderer",
1690616921
currentDispatcherRef: ReactSharedInternals,
1690716922
findFiberByHostInstance: getInstanceFromNode,
16908-
reconcilerVersion: "19.0.0-native-fb-88ee14ff-20240801"
16923+
reconcilerVersion: "19.0.0-native-fb-5fb67fa2-20240801"
1690916924
};
1691016925
null !== extraDevToolsConfig &&
1691116926
(internals.rendererConfig = extraDevToolsConfig);

0 commit comments

Comments
 (0)