diff --git a/packages/rn-tester/js/examples/Playground/RNTesterPlayground.js b/packages/rn-tester/js/examples/Playground/RNTesterPlayground.js
index 8e6b10479de7..29adb43a5425 100644
--- a/packages/rn-tester/js/examples/Playground/RNTesterPlayground.js
+++ b/packages/rn-tester/js/examples/Playground/RNTesterPlayground.js
@@ -9,17 +9,111 @@
*/
import type {RNTesterModuleExample} from '../../types/RNTesterTypes';
+import type {Node} from 'react';
import RNTesterText from '../../components/RNTesterText';
import * as React from 'react';
-import {StyleSheet, View} from 'react-native';
+import {useEffect, useState} from 'react';
+import {Button, Image, StyleSheet, Text, View} from 'react-native';
-function Playground() {
+// Repro for https://github.com/react/react-native/issues/60210
+// (ShadowNodeWrapper entries for unmounted host components are never released).
+//
+// "Run 20 cycles" repeatedly mounts and unmounts a subtree of ordinary host
+// components (nested Views, Text, and a local Image). Each mount uses a new
+// `generation` key so every cycle creates brand-new host nodes instead of
+// reusing them. On the new architecture / bridgeless, Native Heap grows on
+// every unmount and never returns to its previous floor after a GC.
+//
+// Measurement:
+// adb shell dumpsys meminfo com.facebook.react.uiapp | grep -i "Native Heap"
+// Use the "GC" button (calls Hermes' global.gc(), same as DevTools'
+// "Collect garbage") between samples. Run the loop a second time with a
+// manual GC between cycles: the post-GC Native Heap should keep climbing
+// instead of returning to the baseline.
+
+const CYCLES = 20;
+const STEP_MS = 500;
+const ROWS = 40;
+const THUMB = require('../../assets/uie_thumb_normal.png');
+
+function Leaf({label}: {label: string}): Node {
+ return (
+
+
+
+ {label}
+ row host nodes
+
+
+ );
+}
+
+function HeavySubtree({generation}: {generation: number}): Node {
return (
-
-
- Edit "RNTesterPlayground.js" to change this file
-
+
+ {Array.from({length: ROWS}, (_unused, row) => (
+
+
+
+
+
+
+ ))}
+
+ );
+}
+
+function Playground(): Node {
+ const [running, setRunning] = useState(false);
+ const [cycle, setCycle] = useState(0);
+
+ useEffect(() => {
+ if (!running) {
+ return undefined;
+ }
+ const intervalId = setInterval(() => {
+ setCycle(current => current + 1);
+ }, STEP_MS);
+ return () => clearInterval(intervalId);
+ }, [running]);
+
+ useEffect(() => {
+ if (cycle >= CYCLES * 2) {
+ setRunning(false);
+ }
+ }, [cycle]);
+
+ // Odd steps mount a fresh subtree, even steps unmount it. `generation`
+ // changes on every mount so the unmounted nodes are never reused.
+ const mounted = running && cycle > 0 && cycle % 2 === 1;
+ const generation = Math.floor((cycle + 1) / 2);
+ const completed = Math.min(Math.floor(cycle / 2), CYCLES);
+
+ const start = () => {
+ setCycle(0);
+ setRunning(true);
+ };
+
+ const triggerGC = () => {
+ // Hermes exposes gc() in dev builds; DevTools' "Collect garbage" calls
+ // the same thing over the debugger protocol. No-op on release/JSC.
+ const gc = (global: any).gc;
+ if (typeof gc === 'function') {
+ gc();
+ }
+ };
+
+ return (
+
+ ShadowNodeWrapper unmount retention (#60210)
+ {`Complete cycles: ${completed} / ${CYCLES}`}
+
+
+
+ {mounted ? : null}
);
}
@@ -28,6 +122,42 @@ const styles = StyleSheet.create({
container: {
padding: 10,
},
+ controls: {
+ flexDirection: 'row',
+ gap: 8,
+ marginVertical: 8,
+ },
+ tree: {
+ flexGrow: 1,
+ },
+ group: {
+ marginVertical: 2,
+ },
+ card: {
+ borderWidth: 1,
+ borderColor: '#cccccc',
+ borderRadius: 4,
+ padding: 4,
+ },
+ row: {
+ flexDirection: 'row',
+ alignItems: 'center',
+ },
+ thumb: {
+ width: 24,
+ height: 24,
+ },
+ textColumn: {
+ flex: 1,
+ marginLeft: 6,
+ },
+ label: {
+ fontSize: 12,
+ },
+ subLabel: {
+ fontSize: 10,
+ color: '#666666',
+ },
});
export default {