Skip to content

Commit ef88944

Browse files
authored
Rollout enablePersistedModeClonedFlag (facebook#34520)
## Summary Experimentation has completed for this at Meta and we've observed positive impact on key React Native surfaces. ## How did you test this change? yarn flow fabric
1 parent e6f2a8a commit ef88944

11 files changed

+18
-43
lines changed

packages/react-native-renderer/src/__tests__/ReactFabric-test.internal.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,6 @@ describe('ReactFabric', () => {
287287
expect(nativeFabricUIManager.completeRoot).toBeCalled();
288288
});
289289

290-
// @gate enablePersistedModeClonedFlag
291290
it('should not clone nodes when layout effects are used', async () => {
292291
const View = createReactNativeComponentClass('RCTView', () => ({
293292
validAttributes: {foo: true},
@@ -305,6 +304,8 @@ describe('ReactFabric', () => {
305304
<ComponentWithEffect />
306305
</View>,
307306
11,
307+
null,
308+
true,
308309
),
309310
);
310311
expect(nativeFabricUIManager.completeRoot).toBeCalled();
@@ -316,6 +317,8 @@ describe('ReactFabric', () => {
316317
<ComponentWithEffect />
317318
</View>,
318319
11,
320+
null,
321+
true,
319322
),
320323
);
321324
expect(nativeFabricUIManager.cloneNode).not.toBeCalled();
@@ -327,7 +330,6 @@ describe('ReactFabric', () => {
327330
expect(nativeFabricUIManager.completeRoot).not.toBeCalled();
328331
});
329332

330-
// @gate enablePersistedModeClonedFlag
331333
it('should not clone nodes when insertion effects are used', async () => {
332334
const View = createReactNativeComponentClass('RCTView', () => ({
333335
validAttributes: {foo: true},
@@ -345,6 +347,8 @@ describe('ReactFabric', () => {
345347
<ComponentWithRef />
346348
</View>,
347349
11,
350+
null,
351+
true,
348352
),
349353
);
350354
expect(nativeFabricUIManager.completeRoot).toBeCalled();
@@ -356,6 +360,8 @@ describe('ReactFabric', () => {
356360
<ComponentWithRef />
357361
</View>,
358362
11,
363+
null,
364+
true,
359365
),
360366
);
361367
expect(nativeFabricUIManager.cloneNode).not.toBeCalled();
@@ -367,7 +373,6 @@ describe('ReactFabric', () => {
367373
expect(nativeFabricUIManager.completeRoot).not.toBeCalled();
368374
});
369375

370-
// @gate enablePersistedModeClonedFlag
371376
it('should not clone nodes when useImperativeHandle is used', async () => {
372377
const View = createReactNativeComponentClass('RCTView', () => ({
373378
validAttributes: {foo: true},
@@ -387,6 +392,8 @@ describe('ReactFabric', () => {
387392
<ComponentWithImperativeHandle ref={ref} />
388393
</View>,
389394
11,
395+
null,
396+
true,
390397
),
391398
);
392399
expect(nativeFabricUIManager.completeRoot).toBeCalled();
@@ -399,6 +406,8 @@ describe('ReactFabric', () => {
399406
<ComponentWithImperativeHandle ref={ref} />
400407
</View>,
401408
11,
409+
null,
410+
true,
402411
),
403412
);
404413
expect(nativeFabricUIManager.cloneNode).not.toBeCalled();

packages/react-reconciler/src/ReactFiberCommitWork.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ import {
4848
alwaysThrottleRetries,
4949
enableCreateEventHandleAPI,
5050
enableHiddenSubtreeInsertionEffectCleanup,
51-
enablePersistedModeClonedFlag,
5251
enableProfilerTimer,
5352
enableProfilerCommitHooks,
5453
enableSuspenseCallback,
@@ -1969,10 +1968,7 @@ function recursivelyTraverseMutationEffects(
19691968
}
19701969
}
19711970

1972-
if (
1973-
parentFiber.subtreeFlags &
1974-
(enablePersistedModeClonedFlag ? MutationMask | Cloned : MutationMask)
1975-
) {
1971+
if (parentFiber.subtreeFlags & (MutationMask | Cloned)) {
19761972
let child = parentFiber.child;
19771973
while (child !== null) {
19781974
commitMutationEffectsOnFiber(child, root, lanes);

packages/react-reconciler/src/ReactFiberCompleteWork.js

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import {
3535
enableLegacyHidden,
3636
enableSuspenseCallback,
3737
enableScopeAPI,
38-
enablePersistedModeClonedFlag,
3938
enableProfilerTimer,
4039
enableTransitionTracing,
4140
passChildrenWhenCloningPersistedNodes,
@@ -92,7 +91,6 @@ import {
9291
Snapshot,
9392
ChildDeletion,
9493
StaticMask,
95-
MutationMask,
9694
Passive,
9795
ForceClientRender,
9896
MaySuspendCommit,
@@ -205,7 +203,7 @@ function markUpdate(workInProgress: Fiber) {
205203
* it received an update that requires a clone of the tree above.
206204
*/
207205
function markCloned(workInProgress: Fiber) {
208-
if (supportsPersistence && enablePersistedModeClonedFlag) {
206+
if (supportsPersistence) {
209207
workInProgress.flags |= Cloned;
210208
}
211209
}
@@ -227,9 +225,7 @@ function doesRequireClone(current: null | Fiber, completedWork: Fiber) {
227225
// then we only have to check the `completedWork.subtreeFlags`.
228226
let child = completedWork.child;
229227
while (child !== null) {
230-
const checkedFlags = enablePersistedModeClonedFlag
231-
? Cloned | Visibility | Placement | ChildDeletion
232-
: MutationMask;
228+
const checkedFlags = Cloned | Visibility | Placement | ChildDeletion;
233229
if (
234230
(child.flags & checkedFlags) !== NoFlags ||
235231
(child.subtreeFlags & checkedFlags) !== NoFlags
@@ -526,16 +522,9 @@ function updateHostComponent(
526522
markUpdate(workInProgress);
527523
}
528524
workInProgress.stateNode = newInstance;
529-
if (!requiresClone) {
530-
if (!enablePersistedModeClonedFlag) {
531-
// If there are no other effects in this tree, we need to flag this node as having one.
532-
// Even though we're not going to use it for anything.
533-
// Otherwise parents won't know that there are new children to propagate upwards.
534-
markUpdate(workInProgress);
535-
}
536-
} else if (
537-
!passChildrenWhenCloningPersistedNodes ||
538-
hasOffscreenComponentChild
525+
if (
526+
requiresClone &&
527+
(!passChildrenWhenCloningPersistedNodes || hasOffscreenComponentChild)
539528
) {
540529
// If children have changed, we have to add them all to the set.
541530
appendAllChildren(
@@ -693,11 +682,6 @@ function updateHostText(
693682
currentHostContext,
694683
workInProgress,
695684
);
696-
if (!enablePersistedModeClonedFlag) {
697-
// We'll have to mark it as having an effect, even though we won't use the effect for anything.
698-
// This lets the parents know that at least one of their children has changed.
699-
markUpdate(workInProgress);
700-
}
701685
} else {
702686
workInProgress.stateNode = current.stateNode;
703687
}

packages/shared/ReactFeatureFlags.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,6 @@ export const alwaysThrottleRetries: boolean = true;
129129

130130
export const passChildrenWhenCloningPersistedNodes: boolean = false;
131131

132-
/**
133-
* Enables a new Fiber flag used in persisted mode to reduce the number
134-
* of cloned host components.
135-
*/
136-
export const enablePersistedModeClonedFlag: boolean = false;
137-
138132
export const enableEagerAlternateStateNodeCleanup: boolean = true;
139133

140134
/**

packages/shared/forks/ReactFeatureFlags.native-fb-dynamic.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
export const alwaysThrottleRetries = __VARIANT__;
2121
export const enableObjectFiber = __VARIANT__;
2222
export const enableHiddenSubtreeInsertionEffectCleanup = __VARIANT__;
23-
export const enablePersistedModeClonedFlag = __VARIANT__;
2423
export const enableEagerAlternateStateNodeCleanup = __VARIANT__;
2524
export const passChildrenWhenCloningPersistedNodes = __VARIANT__;
2625
export const renameElementSymbol = __VARIANT__;

packages/shared/forks/ReactFeatureFlags.native-fb.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export const {
2222
alwaysThrottleRetries,
2323
enableHiddenSubtreeInsertionEffectCleanup,
2424
enableObjectFiber,
25-
enablePersistedModeClonedFlag,
2625
enableEagerAlternateStateNodeCleanup,
2726
passChildrenWhenCloningPersistedNodes,
2827
renameElementSymbol,

packages/shared/forks/ReactFeatureFlags.native-oss.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ export const enableLegacyFBSupport: boolean = false;
3838
export const enableLegacyHidden: boolean = false;
3939
export const enableNoCloningMemoCache: boolean = false;
4040
export const enableObjectFiber: boolean = false;
41-
export const enablePersistedModeClonedFlag: boolean = false;
4241
export const enablePostpone: boolean = false;
4342
export const enableReactTestRendererWarning: boolean = false;
4443
export const enableRetryLaneExpiration: boolean = false;

packages/shared/forks/ReactFeatureFlags.test-renderer.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ export const enableFizzExternalRuntime: boolean = true;
5353
export const alwaysThrottleRetries: boolean = true;
5454

5555
export const passChildrenWhenCloningPersistedNodes: boolean = false;
56-
export const enablePersistedModeClonedFlag: boolean = false;
5756
export const disableClientCache: boolean = true;
5857

5958
export const enableInfiniteRenderLoopDetection: boolean = false;

packages/shared/forks/ReactFeatureFlags.test-renderer.native-fb.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ export const enableLegacyFBSupport = false;
3333
export const enableLegacyHidden = false;
3434
export const enableNoCloningMemoCache = false;
3535
export const enableObjectFiber = false;
36-
export const enablePersistedModeClonedFlag = false;
3736
export const enablePostpone = false;
3837
export const enableProfilerCommitHooks = __PROFILE__;
3938
export const enableProfilerNestedUpdatePhase = __PROFILE__;

packages/shared/forks/ReactFeatureFlags.test-renderer.www.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ export const enableFizzExternalRuntime: boolean = false;
5454
export const alwaysThrottleRetries: boolean = true;
5555

5656
export const passChildrenWhenCloningPersistedNodes: boolean = false;
57-
export const enablePersistedModeClonedFlag: boolean = false;
5857
export const disableClientCache: boolean = true;
5958

6059
export const enableInfiniteRenderLoopDetection: boolean = false;

0 commit comments

Comments
 (0)