Skip to content

test(rn-tester): Playground reproducer for unmounted ShadowNodeWrapper retention (#60210) - #60215

Open
john-stalvern wants to merge 1 commit into
react:mainfrom
john-stalvern:repro/60210-shadownode-retention
Open

john-stalvern wants to merge 1 commit into
react:mainfrom
john-stalvern:repro/60210-shadownode-retention

Conversation

@john-stalvern

Copy link
Copy Markdown

Summary

Adds a self-contained reproducer to packages/rn-tester/js/examples/Playground/RNTesterPlayground.js for react-native#60210: host components that have been unmounted keep their ShadowNodeWrapper entries alive, so native memory grows on every navigation/mount-unmount cycle and never returns to its previous floor.

The Playground now renders a "Run 20 mount/unmount cycles" button. Pressing it repeatedly mounts and unmounts a nontrivial tree built only from stock primitives — nested Views, Text, and a local Image — with a new generation key on every mount so fresh host nodes are created each cycle. No third-party dependencies, so this runs on a stock RNTester build. A "GC" button calls global.gc() (Hermes dev builds), matching DevTools' "Collect garbage", so the same loop can be measured with and without a manual collection.

Motivation

Issue #60210 currently carries the react-native-bot Missing reproducer warning; issues without a valid reproducer are auto-staled. This Playground change is the reproducer — it exercises the same push/pop-style unmount path that retains ~1.0–1.5 MB of native heap per cycle on 0.83.6 with the New Architecture and Bridgeless enabled.

Test plan

Build RNTester with the New Architecture enabled and open Playground:

yarn install
yarn --cwd packages/react-native-codegen build
yarn android
cd packages/rn-tester/android && ./gradlew :app:assembleDebug

In the Playground, tap Run 20 mount/unmount cycles and sample native heap before and after:

adb shell dumpsys meminfo com.facebook.react.uiapp | grep -i "Native Heap"

Repeat with GC tapped before each sample. Expected on the affected version: Native Heap rises monotonically across the 20 cycles and, after a GC, does not fall back to the pre-loop baseline — the "sawtooth that never descends" signature. On a fixed build the post-GC heap should return to approximately the starting value.

To observe the retention directly, use the React Native DevTools heap profiler and search for ShadowNodeWrapper instances after the loop completes.

No production code is changed; this is an rn-tester-only reproducer. Changelog: [Internal]

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant