ECLIPTIC :app — the cockpit Performance backlog

: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.

Caveat for every item on this page

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.

Naming note

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.

#WhereWhatRisk
1.1PlayaMapPanel.mapBaseCanvasPromote 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.2PlayaMapPanel.drawSweptProjectedMapThe 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.3clipCircular (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.4mapBaseCanvas TILT branchIn 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.5PlayaMapPanel.egoOverlayCanvasThe 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 Path objects — both allocate a fresh Path plus a 24-point trig loop inside the draw lambda every frame. The geometry depends on sweepDeg so 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 reused Path is safe.
  • Narrow the RADAR format scope — MotionTrackerScreen reads the whole state at top scope for its String.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 single Path of addOvals. (Hollow stroke prevents drawPoints; a Path works.)
  • CockpitUiState stability — the data class embeds PlayaMap (which holds DoubleArrays) and NavigationCue, so the Compose compiler treats it as unstable and full-state child composables cannot smart-skip even when the reference is unchanged. Care: @Immutable is a correctness promise — getting it wrong causes missed recompositions that unit tests will not catch.
  • TextMeasurer hygiene — mostly allocation hygiene; lowest priority in this tier.

Tier 3 — changes the rendered look, needs sign-off

  • crtBeam = false on TrackerLitPalette drops 8 halo drawPaths and 3 endpoint drawPoints from 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

SuspicionVerdict
Parked-GPS 2 Hz state churnFalse. 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 loopConfirmed allocation-free and cached; no boxing.
navCueBar / vectorText allocationsFlagged but not on the hot path once the sweepDeg deferral stopped 60 fps recomposition.
MAP full-state read / throttle-trace arrayReal 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 with dumpsys 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=true and -Pandroidx.enableComposeCompilerReports=true.
  • Frame timing: a Macrobenchmark with FrameTimingMetric over 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 from
design/PERFORMANCE.md · tasks/open.md (private dev repo)