Repository navigation
fix(mobile): collect UI runtime garbage on iOS memory warnings - #16296
Conversation
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — This is a small, self-contained mobile memory-management fix that only schedules UI-runtime garbage collection during memory-warning events, leaving normal app behavior and product defaults unchanged. The listener has a guarded fallback and is removed on cleanup. No code changes detected at You can add or adjust custom eligibility rules. Learn more. |
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Baseline: unavailable · PR result: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
|
Important Review skippedWe couldn't safely recover the incremental review. No full review was started, and the last reviewed checkpoint was preserved. Retry later, or explicitly request a full review by commenting You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review. 📝 WalkthroughWalkthroughThe mobile app now registers a hook that listens for AppState memory warnings and schedules guarded garbage collection on the UI runtime. ChangesMobile memory warning garbage collection
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~8 minutes Change: Bug fix Sequence Diagram(s)sequenceDiagram
participant AppState
participant useUiRuntimeMemoryWarningGc
participant UI runtime
participant globalThis.gc
AppState->>useUiRuntimeMemoryWarningGc: memoryWarning event
useUiRuntimeMemoryWarningGc->>UI runtime: schedule garbage-collection worklet
UI runtime->>globalThis.gc: call if it is a function
Merge Risk: ⚪ Minimal · up to The change adds a guarded UI-runtime collection attempt on iOS memory warnings. No actionable merge-blocking risk is established; the PR appears mergeable with normal checks. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
|
Reviewed the docstring-coverage warning. No code change is needed: the hook already documents why the separate UI runtime needs collection, and the worklet comments explain its guarded runtime lookup. Additional comments describing the effect callback and cleanup would repeat the code, contrary to this repository’s documentation guidance. The review reports no actionable correctness findings. |
6e13d8f to
d102bef
Compare
198aecc to
0c56b90
Compare
0c56b90 to
3bd9287
Compare
React Native only collects the main Hermes runtime when iOS posts a memory warning. The worklets UI runtime is a separate heap that keeps native shadow nodes and synchronizables alive until its own GC runs. Schedule a UI-runtime GC on the same AppState memoryWarning event. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
3bd9287 to
f190ecf
Compare
## What's Changed * chore(review): remove the custom Approvability check by @esthor in pingdotgg/t3code#17018 * perf(mobile): show the cached thread list sooner and stop the freeze after it by @juliusmarminge in pingdotgg/t3code#16713 * fix(server): replaying a command no longer freezes the server by @SunkenInTime in pingdotgg/t3code#17041 * fix(server): opening a long thread no longer blocks the server for a second by @SunkenInTime in pingdotgg/t3code#17029 * fix(server,web,mobile): thread links reference the thread id, not a baked title by @juliusmarminge in pingdotgg/t3code#17017 * fix(web): messages with quotes or links no longer collapse when short by @flamboh in pingdotgg/t3code#16624 * refactor(web): PR loading skeleton shares the detail panel's layout by @flamboh in pingdotgg/t3code#15583 * fix(web): PR file headers keep the file name in narrow panels by @flamboh in pingdotgg/t3code#15562 * fix(web): PR timeline no longer shifts when its scrollbar appears by @flamboh in pingdotgg/t3code#15588 * fix(server): held queued wakes no longer keep delegated tasks running by @juliusmarminge in pingdotgg/t3code#17028 * fix(server): a message sent during a rollback no longer undoes it by @t3dotgg in pingdotgg/t3code#17079 * fix(web): PR file stats ignore the hide-whitespace toggle by @flamboh in pingdotgg/t3code#16162 * perf(mobile): omit duplicated turn items from bounded thread snapshots by @juliusmarminge in pingdotgg/t3code#15385 * perf(mobile): pause elapsed-time timers on hidden thread screens by @juliusmarminge in pingdotgg/t3code#15397 * fix(mobile): pause hidden home thread list updates by @juliusmarminge in pingdotgg/t3code#15705 * fix(mobile): restore file viewer insets and glass header by @juliusmarminge in pingdotgg/t3code#17073 * fix(web): PR code toolbar no longer overlaps in narrow panels by @flamboh in pingdotgg/t3code#15561 * fix(web): PR commit menu no longer stretches across the window by @flamboh in pingdotgg/t3code#15560 * fix(web): command palette scrollbar no longer clipped at the top by @flamboh in pingdotgg/t3code#17035 * fix(web): Usage breadcrumb stays centered on small viewports by @flamboh in pingdotgg/t3code#15552 * fix(mobile): stop refreshing Git status on streamed thread updates by @juliusmarminge in pingdotgg/t3code#15893 * fix(mobile): skip move indexes for empty and single-thread sections by @juliusmarminge in pingdotgg/t3code#16115 * perf(mobile): reuse encoded rows in shell cache saves by @juliusmarminge in pingdotgg/t3code#16129 * perf(mobile): skip showcase subscriptions in normal builds by @juliusmarminge in pingdotgg/t3code#16131 * perf(mobile): remove unused Home project sorting by @juliusmarminge in pingdotgg/t3code#16177 * perf(mobile): reduce move-menu index allocations by @juliusmarminge in pingdotgg/t3code#16256 * perf(mobile): skip impossible thread-key lookups by @juliusmarminge in pingdotgg/t3code#16263 * fix(mobile): collect UI runtime garbage on iOS memory warnings by @juliusmarminge in pingdotgg/t3code#16296 * fix(mobile): stop Git sheet refresh loop by @juliusmarminge in pingdotgg/t3code#16305 * fix(mobile): refresh Git status after reconnect by @juliusmarminge in pingdotgg/t3code#16329 * fix(mobile): update the iOS Git header menu when status changes by @juliusmarminge in pingdotgg/t3code#16330 * perf(mobile): reuse the settled sort when settled rows are unchanged by @juliusmarminge in pingdotgg/t3code#16369 * perf(mobile): highlight source files in small batches that keep grammar state by @juliusmarminge in pingdotgg/t3code#16729 * feat(web): quote chips show what you said about the quote by @flamboh in pingdotgg/t3code#15703 * feat(web): projectless threads show their machine in the sidebar by @flamboh in pingdotgg/t3code#17022 * fix(lineage): keep agent effort and speed after completion by @Bil0000 in pingdotgg/t3code#16925 * fix(mobile): align diff scrolling with glass headers by @juliusmarminge in pingdotgg/t3code#17085 * fix(web): workspace page headers can no longer grow past the top-bar height by @maria-rcks in pingdotgg/t3code#17086 * feat(mobile): redesign the Add environment sheet by @juliusmarminge in pingdotgg/t3code#17092 **Full Changelog**: pingdotgg/t3code@v0.0.46-nightly.20261008.2801...v0.0.46-nightly.20261008.2813 Upstream release: https://github.com/pingdotgg/t3code/releases/tag/v0.0.46-nightly.20261008.2813
## What's Changed * chore(review): remove the custom Approvability check by @esthor in pingdotgg/t3code#17018 * perf(mobile): show the cached thread list sooner and stop the freeze after it by @juliusmarminge in pingdotgg/t3code#16713 * fix(server): replaying a command no longer freezes the server by @SunkenInTime in pingdotgg/t3code#17041 * fix(server): opening a long thread no longer blocks the server for a second by @SunkenInTime in pingdotgg/t3code#17029 * fix(server,web,mobile): thread links reference the thread id, not a baked title by @juliusmarminge in pingdotgg/t3code#17017 * fix(web): messages with quotes or links no longer collapse when short by @flamboh in pingdotgg/t3code#16624 * refactor(web): PR loading skeleton shares the detail panel's layout by @flamboh in pingdotgg/t3code#15583 * fix(web): PR file headers keep the file name in narrow panels by @flamboh in pingdotgg/t3code#15562 * fix(web): PR timeline no longer shifts when its scrollbar appears by @flamboh in pingdotgg/t3code#15588 * fix(server): held queued wakes no longer keep delegated tasks running by @juliusmarminge in pingdotgg/t3code#17028 * fix(server): a message sent during a rollback no longer undoes it by @t3dotgg in pingdotgg/t3code#17079 * fix(web): PR file stats ignore the hide-whitespace toggle by @flamboh in pingdotgg/t3code#16162 * perf(mobile): omit duplicated turn items from bounded thread snapshots by @juliusmarminge in pingdotgg/t3code#15385 * perf(mobile): pause elapsed-time timers on hidden thread screens by @juliusmarminge in pingdotgg/t3code#15397 * fix(mobile): pause hidden home thread list updates by @juliusmarminge in pingdotgg/t3code#15705 * fix(mobile): restore file viewer insets and glass header by @juliusmarminge in pingdotgg/t3code#17073 * fix(web): PR code toolbar no longer overlaps in narrow panels by @flamboh in pingdotgg/t3code#15561 * fix(web): PR commit menu no longer stretches across the window by @flamboh in pingdotgg/t3code#15560 * fix(web): command palette scrollbar no longer clipped at the top by @flamboh in pingdotgg/t3code#17035 * fix(web): Usage breadcrumb stays centered on small viewports by @flamboh in pingdotgg/t3code#15552 * fix(mobile): stop refreshing Git status on streamed thread updates by @juliusmarminge in pingdotgg/t3code#15893 * fix(mobile): skip move indexes for empty and single-thread sections by @juliusmarminge in pingdotgg/t3code#16115 * perf(mobile): reuse encoded rows in shell cache saves by @juliusmarminge in pingdotgg/t3code#16129 * perf(mobile): skip showcase subscriptions in normal builds by @juliusmarminge in pingdotgg/t3code#16131 * perf(mobile): remove unused Home project sorting by @juliusmarminge in pingdotgg/t3code#16177 * perf(mobile): reduce move-menu index allocations by @juliusmarminge in pingdotgg/t3code#16256 * perf(mobile): skip impossible thread-key lookups by @juliusmarminge in pingdotgg/t3code#16263 * fix(mobile): collect UI runtime garbage on iOS memory warnings by @juliusmarminge in pingdotgg/t3code#16296 * fix(mobile): stop Git sheet refresh loop by @juliusmarminge in pingdotgg/t3code#16305 * fix(mobile): refresh Git status after reconnect by @juliusmarminge in pingdotgg/t3code#16329 * fix(mobile): update the iOS Git header menu when status changes by @juliusmarminge in pingdotgg/t3code#16330 * perf(mobile): reuse the settled sort when settled rows are unchanged by @juliusmarminge in pingdotgg/t3code#16369 * perf(mobile): highlight source files in small batches that keep grammar state by @juliusmarminge in pingdotgg/t3code#16729 * feat(web): quote chips show what you said about the quote by @flamboh in pingdotgg/t3code#15703 * feat(web): projectless threads show their machine in the sidebar by @flamboh in pingdotgg/t3code#17022 * fix(lineage): keep agent effort and speed after completion by @Bil0000 in pingdotgg/t3code#16925 * fix(mobile): align diff scrolling with glass headers by @juliusmarminge in pingdotgg/t3code#17085 * fix(web): workspace page headers can no longer grow past the top-bar height by @maria-rcks in pingdotgg/t3code#17086 * feat(mobile): redesign the Add environment sheet by @juliusmarminge in pingdotgg/t3code#17092 **Full Changelog**: pingdotgg/t3code@v0.0.46-nightly.20261008.2801...v0.0.46-nightly.20261008.2813 Upstream release: https://github.com/pingdotgg/t3code/releases/tag/v0.0.46-nightly.20261008.2813
On iOS, React Native's memory-warning handler only collects the main Hermes runtime. The Reanimated/worklets UI runtime is a separate Hermes heap with no memory-pressure handling. Garbage there keeps native objects alive, including view shadow nodes,
ShadowNodeWrappers and workletsSynchronizableFixeds, until that heap happens to collect. In a 40-cycle navigation run, the control build still held 3,098SynchronizableFixedand 1,973ViewShadowNodeobjects after the late memory warning.useUiRuntimeMemoryWarningGc, mounted once at the app root, listens forAppStatememoryWarningand schedules a worklet on the UI runtime that callsglobalThis.gcif Hermes exposes it. Withoutgc, the hook does nothing. The PR adds no polling, timers or state, and changes no visible behavior. React Native emitsmemoryWarningonly on iOS, so the hook does nothing on Android.Release memory measurements
Both runs used iPhone 17 Pro on the iOS 27 simulator, not a physical device. Both used the same optimized Release native executable (UUID
D0C2BDE9-D7DA-3283-9891-83622F94DC12), Hermes-O,dev=falseand no Metro server. Each run did 40 navigation cycles alternating a 30-turn, 70-tools-per-turn history and a 300-turn plain history, with 13 background/resume transitions on a 1,210-thread fixture. A test-only injected dylib postedUIApplicationDidReceiveMemoryWarningNotificationon Home after cycle 6 and after cycle 40. Logs show both deliveries in each run.vmmap -summaryandheap -swere captured on Home.d391d0c5…built from parent 4ff5c69, without the hook.251e775e…built from 4ff5c69 plus this patch (source patch sha25611f5b957…). The source map'ssourcesContentfor both changed files matches this commit exactly. The hook is not instrumented.worklets::SynchronizableFixedViewShadowNodeShadowNodeWrapperworklets::SerializableJSRefWith the hook, the late warning returned the target classes to their early levels. Before the late warning, the run held 2,857
SynchronizableFixed, 5,456ViewShadowNode, 4,818ShadowNodeWrapper, 108.4 MiB malloc allocated in 510,275 allocations, and a 306.2 MiB footprint.Limits: This is one control run and one production run, so no percentage improvement is claimed. Physical footprint still grows +55.4 MiB from c6 to c40 after the warning with the hook, compared with +57.3 MiB in the control. Most of that growth is retained Hermes heap capacity in untagged regions. This PR does not fix overall memory growth.
leaksreports the same 66 blocks (2,112 bytes) in both runs. Neither run measured battery use or latency.UI GC timing: The production run has no timing instrumentation. A separate scratch build with an instrumented probe, which is not shipped, measured UI-runtime
gc()at 2 ms after the early warning (allocated 8.36 → 3.02 MB) and 4 ms after the late warning (16.84 → 3.23 MB). Those numbers come from that diagnostic run, not from this exact hook.Evidence: evidence.json (aggregates, bundle hashes, workload, diagnostic log)
Hook run: c06-home-postwarn-heap.txt · c06-home-postwarn-vmmap.txt · c40-home-postwarn-heap.txt · c40-home-postwarn-leaks.txt · c40-home-postwarn-vmmap.txt · c40-home-pre-heap.txt · c40-home-pre-vmmap.txt
Control run: c06-home-postwarn-heap.txt · c06-home-postwarn-vmmap.txt · c40-home-postwarn-heap.txt · c40-home-postwarn-leaks.txt · c40-home-postwarn-vmmap.txt · c40-home-pre-heap.txt · c40-home-pre-vmmap.txt
App paths and simulator identifiers are redacted from the captures. No source maps, bundles or databases are uploaded.
Verification
Mobile typecheck and targeted lint pass. The hook only runs on a native memory warning, so it has no unit test. The memory runs above are its behavioral proof.
Surfaces: only the iOS mobile client changes behavior. Android, web, desktop, server, providers and contracts are unchanged. Unrelated local widget edits are excluded.
Julius requested one PR per measured issue in this maintainer mobile performance audit.
Implementation and PR preparation: Claude Opus 5.5 through T3 Code. Production run integration and verification: GPT-6 Astra through the Codex harness.
🤖 Generated with Claude Code