Files
pipelines/app/notes/mobile-quick-switch-profile.md
T

115 lines
6.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 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.
## Intermediate geometry comparison (superseded by final comparison below)
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.
## Final release geometry comparison
Repeated the quiet pair after the final deck polish: the incoming card is already
full-height behind the outgoing opaque front, avoiding a blank gap at the top.
Both builds use exactly that same geometry and opaque surface fill (3daf9ce0).
Only the fixed viewport/chrome layout and affine flat-depth optimization differ.
Two repetitions × six warmed switches each, same rich fixture and 850 ms cadence;
root paused other builds/tests/captures. These final results supersede the earlier
geometry's apparent 25% rAF-tail improvement.
| Metric | Cost fixes disabled | Cost fixes enabled |
| --- | ---: | ---: |
| Flutter build p50 | 9.0 ms | 1.6 ms |
| Flutter build p95 | 39.7 ms | 20.6 ms |
| Flutter build sum | 895.4 ms | 502.8 ms |
| Total frame p50 | 45.7 ms | 39.5 ms |
| Total frame p95 | 79.2 ms | 78.8 ms |
| Raster p95 | 58.4 ms | 71.0 ms |
| Browser rAF interval p95 | 66.7 ms | 66.7 ms |
| Long tasks (>50 ms) | 36 | 23 |
| Flutter frames recorded | 86 | 96 |
The layout fix reduces typical build work by about 82%, and typical total frame
cost by about 14%. **Raster tail worsens, rAF p95 does not improve, and total-frame
p95 is essentially unchanged.** Fixed full-size content behind a changing paint
clip still has renderer/filter cost; this patch does not solve that cost or
prove smooth native-device FPS. The prior quarter-improvement cadence result
must not be presented as the final release result.
Final reports/raw timings/CPU profiles: /tmp/mobile-motion-final-before/ and
/tmp/mobile-motion-final-after/. Both report no browser errors and all 12
selections confirmed. The disabled-cost build used the same widget structure
with fixed sizes disabled, progressive occupied chrome restored and the previous
perspective transform path; source was restored byte-for-byte after building.
All private profiling browser/server processes exited. No Android hardware test
was possible. Parent's final browser capture covers the final geometry and
verifies the resting peek reaches its true content bottom.
Final performance regression checks: 61 workspace/motion tests passed
(/tmp/memwatch/out.Yvac5n), analyzer clean (flutter-analyze.wtLee1). The subsequent
geometry change has its separate parent/animation-lane test evidence.