Skip to content

Commit ba33548

Browse files
javachefacebook-github-bot
authored andcommitted
Clean up enableEagerAlternateStateNodeCleanup
Summary: The `enableEagerAlternateStateNodeCleanup` flag is no longer read by the renderer, so the feature-flag definition and the two prelude overrides that forced it on become dead code. Drop the flag entry from `ReactNativeInternalFeatureFlags` (incl. its test mirror and the Fantom mock) and remove the `= true` assignments from the Airwave and FB4TV preludes. The dedicated `VirtualView-enableEagerAlternateStateNodeCleanup-itest.js` is folded into `VirtualView-itest.js`'s `memory management` describe so the shadow-node retention regression test continues to run, just no longer keyed on a non-existent flag. Vendored React (`react-devtools-facade`), the append-only mobileconfig stable_id, and the generated `react-devtools-core` bundles are intentionally untouched. Changelog: [Internal] Differential Revision: D110043719
1 parent 318bb21 commit ba33548

3 files changed

Lines changed: 23 additions & 53 deletions

File tree

packages/react-native/src/private/components/virtualview/__tests__/VirtualView-enableEagerAlternateStateNodeCleanup-itest.js

Lines changed: 0 additions & 47 deletions
This file was deleted.

packages/react-native/src/private/components/virtualview/__tests__/VirtualView-itest.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import type {NativeModeChangeEvent} from '../VirtualViewNativeComponent';
1515

1616
import ensureInstance from '../../../__tests__/utilities/ensureInstance';
1717
import isUnreachable from '../../../__tests__/utilities/isUnreachable';
18+
import {createShadowNodeReferenceCountingRef} from '../../../__tests__/utilities/ShadowNodeReferenceCounter';
1819
import {getNodeFromPublicInstance} from '../../../../../Libraries/ReactPrivate/ReactNativePrivateInterface';
1920
import ReactNativeElement from '../../../webapis/dom/nodes/ReactNativeElement';
2021
import VirtualView, {_logs, VirtualViewMode} from '../VirtualView';
@@ -291,6 +292,28 @@ describe('memory management', () => {
291292

292293
expect(isUnreachable(nullthrows(weakRef))).toBe(true);
293294
});
295+
296+
test('does not retain shadow node after becoming hidden', () => {
297+
const root = Fantom.createRoot();
298+
299+
const [getReferenceCount, childRef] =
300+
createShadowNodeReferenceCountingRef();
301+
const viewRef = createRef<React.RefOf<VirtualView>>();
302+
303+
Fantom.runTask(() => {
304+
root.render(
305+
<VirtualView ref={viewRef}>
306+
<Text ref={childRef}>Child</Text>
307+
</VirtualView>,
308+
);
309+
});
310+
311+
expect(getReferenceCount()).toBeGreaterThan(0);
312+
313+
dispatchModeChangeEvent(viewRef.current, VirtualViewMode.Hidden);
314+
315+
expect(getReferenceCount()).toBe(0);
316+
});
294317
});
295318

296319
/**

private/react-native-fantom/runtime/mocks/ReactNativeInternalFeatureFlags.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@
99
*/
1010

1111
module.exports = {
12-
// When enableEagerAlternateStateNodeCleanup is enabled, alternate.stateNode is proactively
13-
// pointed towards finishedWork's stateNode, releasing resources sooner.
14-
// With enableEagerAlternateStateNodeCleanup enabled, we can remove workarounds in tests
15-
// and have predictable memory model.
16-
// See https://github.com/facebook/react/pull/33161 for details.
17-
enableEagerAlternateStateNodeCleanup: true,
1812
enableFragmentRefs: true,
1913
enableFragmentRefsInstanceHandles: true,
2014
enableFragmentRefsTextNodes: true,

0 commit comments

Comments
 (0)