:app · the cockpit
Performance backlog
The cockpit draws a live Black Rock City map on a Compose Canvas at ~60 fps.
RADAR is the worst case — a withFrameNanos sweep drives 60 fps redraws.
Target hardware is the Amazon Fire HD 10: weak GPU and CPU, GC-sensitive.
These are principled static-analysis wins (allocation, recomposition and overdraw reduction) from a 2026-06-14 render audit — not device-profiled. Confirm the felt improvement on a real tablet before and after. The behaviour-preserving subset of that audit already shipped; this page is what has not been done.
The audit predates the concept rename. The concepts are now RADAR
(MotionTrackerScreen, the sweep scope — the worst case here), MAP
(InstrumentBayScreen) and DRIVER (DriverNightScreen, which did not exist
when the audit was written and is not covered by any item below). The old A
CRTVectorScreen and B PerspectiveScreen were deleted,
so any item that referred to them has lost that half.
Tier 1 — cache the map's pixels, not just its geometry
The audit's central insight: the geometry pipeline is already well cached
(ProjectedMap, viewport, label layouts), but nothing caches the rasterised
pixels. Under the RADAR sweep, and in TILT mode, the entire CRT Skia call list —
halo pair ×4 + 4 stroke paths + point batches + ~50 art circles + endpoint dots —
replays every frame, even though the base map only changes at the 2 Hz GPS cadence. The
2026-06-14 pass removed the recomposition cost; the drawing cost remains.
The fix family is GPU layer promotion: render the static base map into a cached layer keyed so it only re-rasterises on camera change, then blit one texture per frame instead of replaying the call list.
| # | Where | What | Risk |
|---|---|---|---|
| 1.1 | PlayaMapPanel.mapBaseCanvas | Promote the base map to a cached layer; re-rasterise only on viewport change. Dominates 1.2. | Behaviour-preserving in principle, but offscreen-compositing the translucent CRT halos changes the blend order — needs a visual sanity check on-device. |
| 1.2 | PlayaMapPanel.drawSweptProjectedMap | The RADAR “ping” re-blits the whole map clipped to the rotating wedge, every frame. Cache the lit map once and run only clipPath(wedge){ drawLayer } per frame. | Same compositing caveat; antialiasing at stroke edges may differ subtly from a live re-stroke. |
| 1.3 | clipCircular (Modifier.clip(CircleShape)) | A non-rectangular clip forces render-to-texture + masked composite for the entire stacked subtree on each invalidation. If 1.1 lands, apply the circular clip to that single cached layer instead. | Behaviour-preserving. Memory-bandwidth bound. |
| 1.4 | mapBaseCanvas TILT branch | In TILT the graphicsLayer is used purely for the 3D transform, so it gets the worst of both worlds — an offscreen buffer and a full re-record every frame. | Behaviour-preserving. Medium impact, TILT only. |
| 1.5 | PlayaMapPanel.egoOverlayCanvas | The ego marker is a function of inputs that all move at ≤2 Hz, yet its full-screen sibling Canvas re-invalidates at sweep cadence. | Behaviour-preserving. Low impact. Pairs with 1.1. |
Do not land this cluster blind — it is the one that can shift the tuned CRT look. Prototype 1.1 behind an on-device A/B, eyeball the halo blending against the current build, then extend.
Tier 2 — behaviour-preserving, pixel-identical
Verified behaviour-preserving and left for a focused pass. None need sign-off.
- Reuse the wedge / cone
Pathobjects — both allocate a freshPathplus a 24-point trig loop inside the draw lambda every frame. The geometry depends onsweepDegso it must re-trace per frame, but the allocation can go. - Reuse the ego-marker
Path— same pattern. Compose draw is single-threaded, so a function-scoped reusedPathis safe. - Narrow the RADAR format scope —
MotionTrackerScreenreads the whole state at top scope for itsString.formats, so the input slice buys nothing for those. Hoist the formatted strings into a child composable that takes only the fields it reads. - Batch major art — ~50 hollow
drawCircles in DOT mode could batch into a singlePathofaddOvals. (Hollow stroke preventsdrawPoints; a Path works.) CockpitUiStatestability — the data class embedsPlayaMap(which holdsDoubleArrays) andNavigationCue, so the Compose compiler treats it as unstable and full-state child composables cannot smart-skip even when the reference is unchanged. Care:@Immutableis a correctness promise — getting it wrong causes missed recompositions that unit tests will not catch.TextMeasurerhygiene — mostly allocation hygiene; lowest priority in this tier.
Tier 3 — changes the rendered look, needs sign-off
crtBeam = falseonTrackerLitPalettedrops 8 halodrawPaths and 3 endpointdrawPointsfrom the lit re-blit inside the wedge. The wedge still brightens features via the lit core strokes, so the M41A ping still reads — but it loses its doubled phosphor bloom and white corner dots. One-line change, biggest cost/effort ratio of the re-blit cuts. The cleaner alternative is the 1.2 layer cache, with no visual change. Pick one after seeing both on-device.
Investigated and dismissed — do not re-chase
| Suspicion | Verdict |
|---|---|
| Parked-GPS 2 Hz state churn | False. LocationSourceState.Active and GpsFix are data classes, so MutableStateFlow already conflates identical fixes to the collector; a stationary vehicle does not drive CockpitUiState.copy(). A dedup was implemented and then reverted as a no-op. |
| The retro grid (TILT) | Already path-cached and viewport-keyed; no per-frame rebuild. |
| Projection inner loop | Confirmed allocation-free and cached; no boxing. |
navCueBar / vectorText allocations | Flagged but not on the hot path once the sweepDeg deferral stopped 60 fps recomposition. |
| MAP full-state read / throttle-trace array | Real allocations but not hot — MAP has no animation loop and recomposes at 2 Hz. |
Measuring on device
Before and after any of the above, on a real Fire HD 10:
- Jank percentiles:
adb shell dumpsys gfxinfo org.pureagave.zodiac.control framestats. Reset withdumpsys gfxinfo <pkg> reset, exercise RADAR for ~30 s, dump. - Recomposition counts: Android Studio Layout Inspector while the sweep runs — the header and stat composables should tick at ~2 Hz, not 60 fps.
- Compose stability: build with
-Pandroidx.enableComposeCompilerMetrics=trueand-Pandroidx.enableComposeCompilerReports=true. - Frame timing: a Macrobenchmark with
FrameTimingMetricover a scripted RADAR session gives a repeatable P50 / P90 / P99. - GC pressure: Android Studio Profiler → Memory, watching allocation rate while RADAR runs.
The Fire is on the bench, so this whole backlog is unblocked. It is a profiling campaign, worth scoping before starting.
Converted fromdesign/PERFORMANCE.md · tasks/open.md (private dev repo)