Reduce quick switch layout churn and flatten planar depth transforms

This commit is contained in:
2026-11-07 19:44:42 +00:00
parent 53a9cc78a3
commit ef0571c562
10 changed files with 284 additions and 17 deletions
+71
View File
@@ -0,0 +1,71 @@
# Mobile quick-switch frame profile
Measured 2026-11-07 using the real full-app fixture, rich 120-message chats,
560×1000 touch input, Flutter profile web build with source maps, private
headless Chrome, CanvasKit software rasterization, semantics enabled and no CPU
throttle. Never used production chats. No Android device was connected. The
managed Pipelines_Fold_A .ini points to a missing .avd directory; no emulator
was created and the personal Fold was not used. These are comparative browser
measurements, not Android hardware FPS claims.
## Diagnosis and bounded changes
Each animation tick resized two real transcript viewports and changed the
header/composer occupied height. This repeatedly laid out expensive chat
content. The previous Card stack's perspective/hinge motion also had much
higher software-raster cost than a flat swap. CPU samples were dominated by
CanvasKit raster/surface work; eliminating layout alone cannot remove that tail.
Non-tape exchanges now lay out the incoming transcript at its destination
viewport and retain the outgoing source viewport until settling. ClipRect and
OverflowBox animate only the painted rectangle; the actual resting preview
still receives its real small constraints, so its final content remains
reachable. Chrome keeps its occupied layout height during the exchange while
its existing fade/slide still paints. The final layout applies once at rest.
Tape remains unchanged because its continuous loop uses a separate picture.
A flat card at constant depth projects to a uniform 2D scale. The shared pose
helper now uses the mathematically equivalent affine transform for these cards,
while actual Flip/Rolodex rotations keep perspective. Regression verifies the
same projected points instead of requiring an unnecessary perspective matrix.
## Quiet before/after confirmation
Two repetitions × six warmed touch switches per build, same fixture and 850 ms
cadence. Root paused other builds/tests/captures for this comparison. Before is
the new true Card deck library without the performance patch; after includes
fixed viewports/chrome and affine flat-depth projection. Values below are the
benchmark's upper median across the two repetitions.
| Metric | Before | After |
| --- | ---: | ---: |
| Flutter build p50 | 8.6 ms | 1.6 ms |
| Flutter build sum | 902.9 ms | 531.1 ms |
| Total frame p50 | 41.8 ms | 32.9 ms |
| Flutter frames recorded | 94 | 115 |
| Browser rAF interval p95 | 66.7 ms | 50.1 ms |
| Long tasks (>50 ms) | 35 | 16 |
| Raster p95 | 47.6 ms | 50.9 ms |
| Total frame p95 | 65.7 ms | 68.2 ms |
Typical build cost and cadence improved, but raster p95 and total-frame p95
**did not improve**. This does not establish 60 FPS or eliminate Android jank.
The remaining renderer/filter cost needs a real authorized Android device to
characterize accurately. Browser rAF p50 includes idle gaps and should not be
used as the animation FPS.
Reports, raw Flutter timings, V8 CPU samples and rAF/long-task arrays:
- /tmp/mobile-motion-quiet-before/report.json
- /tmp/mobile-motion-quiet-after/report.json
- Per repetition: run-N.cpuprofile, run-N-cpu.json, run-N-frames.json.
Exploratory three-repeat baseline (overlapped other development work, so not a
strict quiet comparison): Tape total p95 69.9 ms; Swap 45.3 ms; old Card stack
88.2 ms with raster p95 75.5 ms. New Card deck before this patch had total p95
64.8 ms/raster p95 49.6 ms. The shape change itself therefore helps, but the
quiet pair above is the defensible comparison for the performance patch.
Tests cover no repeated child-constraint layout as painted height changes,
fixed occupied chrome during a fade, actual resting peek height, retained
chat drafts for every style and equivalent affine projection. Integration
browser review remains with the parent task.