Repository navigation
Description
Before submitting
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area
apps/mobile
Steps to reproduce
- On an iPad, open a thread in the T3 Code app and let an agent turn stream into it.
- Measure whole-device power from the battery gauge (
PowerTelemetryData.AccumulatedSystemLoadviapymobiledevice3, battery held at its charge limit so it neither charges nor discharges). - Repeat with a minimal Flutter client against the same server, the same thread and the same replayed turn (dev
Replayprovider), alternating the two apps in ABBA blocks.
Expected behavior
Watching a turn stream costs about what it costs in a minimal Flutter client, since the screen content is the same.
Actual behavior
Idle screens cost the same, but streaming costs about 125 mW more, so the app's own cost while streaming is ~2.8x the Flutter client's. In daily use the battery percentage visibly drops minute by minute while a turn runs.
| Phase (2 min each, 2 ABBA blocks) | T3 Code | Flutter client | Difference per block |
|---|---|---|---|
| Thread list, idle | ~980 mW | ~980 mW | −6 / +6 |
| Long thread open, idle | ~981 mW | ~967 mW | −16 / −14 |
| Turn streaming | ~1135 mW | ~1010 mW | −126 / −123 |
| App in background | ~941 mW | ~945 mW | +11 / −5 |
Device floor (Settings app in front) is ~940 mW, so above the floor streaming costs ~195 mW in T3 Code and ~70 mW in the Flutter client. The bench resolves about 25 mW; the same build against itself moves at most 8 mW per block.
Where it goes, largest first:
- Work-row shimmer: measured 55-72 mW. A build without it saved that much while streaming. The native-driver loop steps and clones props on the main thread every frame, and the compositor redraws behind the glass surfaces. A Core Animation version with identical visuals recovers only ~20 mW, so most of the cost is the animation itself.
- The whole growing message is re-parsed and re-laid out on every update (
apps/mobile/src/native/EnrichedMarkdownText.tsx), about 2.5 times a second over an ever-longer string. The Flutter client keeps finished blocks and reparses only the open tail. Not yet measured on its own. - Thread-wide state publication per update (
packages/client-runtime/src/state/threads.ts): each update republishes the thread projection and wakes route and composer subscribers. The JS thread spends ~2.8 s of CPU per minute while streaming, ~77% of it in Promise jobs. Not yet measured on its own. - Liquid Glass composer and Working pill over the moving feed: the render server spends ~8 s more CPU per minute while streaming than at idle. Not yet measured on its own.
Separately, on an idle screen three display links tick every frame: worklets' requestAnimationFrame loop re-requests itself forever, Reanimated's 500 ms props flush keeps React Native's timer display link running, and expo-app-metrics' frame recorders (via expo-observe) run for the app's lifetime. Removing them shows clearly in Instruments, but it stays below 25 mW on this bench.
Related: #24796 (Android battery report, cause unknown) and #9661 (performance audit tracker).
I'd like to fix this with focused, measured PRs, starting with the ones that change nothing visible (2 and 3, then the idle loops). The shimmer's cadence is a product call, so I'd raise it as an Ideas discussion.
Impact
Major degradation or frequent failure
Version or commit
main @ dac8b11 (mobile Release build, personal-team signed, OTA off)
Environment
iPad mini (A17 Pro), iPadOS 26.7.2, Wi-Fi, minimum brightness, server over Tailscale
Method
Same iPad, same isolated server seeded from real data, restored from a snapshot before each trial. The app is driven only by deep links and server CLI calls, never touched during a measured window. Each phase settles 30-40 s, then measures 120 s. Blocks alternate ABBA/BAAB with a floor run between blocks. A run is rejected if the battery charges, discharges or changes temperature. Screenshots after every phase confirm both apps show the same content. Profiles: Instruments Time Profiler, attached and all-process, on Release builds.
Activity
dbxe commentedon Oct 30, 2026
Note
🤖 Claude Opus 5.5 responding on behalf of Daniel Briskin
I measured the issue's other suspects tonight. Only the shimmer clears the bench, so items 2-4 in the issue are smaller than the issue suggests.
Each row is a 2-block streaming trial, in mW per block. The bench resolves about 25 mW.
dac8b11ddcunless noted)So on this bench, rendering the growing text costs nothing measurable. Without the shimmer, a streaming screen still costs ~100 mW more than an idle open thread. Text, glass, haptics and motion don't explain it.
Network traffic is the next lead. I counted the Tailscale extension's bytes on the server host over the same 120 s streaming window, alternating the two clients twice. "Into the tunnel" is the server's outgoing data before encryption; "on the wire" is the encrypted packets, including overhead.
That's ~8x the payload for the same turn. (An earlier edit of this comment called the first column upstream; that was my misreading of the counters.)
Likely cause of the downstream gap (from the code; not yet confirmed on the wire):
permessage-deflatewith context takeover (apps/server/src/server.ts).message.updatedresends the whole growing message on every tick, which compresses very well under that setting.WebSocket.connectnegotiates deflate by default. React Native's iOS WebSocket (RCTWebSocketModuleon SocketRocket) doesn't support it, so the app likely receives every tick uncompressed.A Node client on the bench server, subscribing to the same replay thread with the app's own options, received 343 KB uncompressed vs 19 KB with deflate (18x) in the same 120 s window. Both got identical payloads. That fits the app's ~580 KB (thread plus shell streams), #24931 (a URLSession WebSocket on iOS) fixes the byte gap on the device: 122 KB vs 755 KB. But power read −25 / +7 mW in portrait (−6 / +1 in an earlier landscape run), unchanged, so on Wi-Fi the bytes aren't what costs power. Cellular is untested, and it's where they should matter most. The Flutter client subscribes to no less than the app does: both get the same thread and shell streams, and the app even asks for deduplicated bodies.
One caveat on item 2: this bench's assistant messages are short, about 250 words between tool calls, so it doesn't exercise one very long message.
The shimmer needs a visible change to pay off fully, so I opened #27684 for the direction. I won't open PRs for the candidates that read within noise.