Files
pipelines/app/notes/mobile-chat-text-profile.md
T

95 lines
4.9 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 chat text profile
## Scope
Diagnostic-only profile of the real `ChatThreadView` with its isolated fake
`ApiGateway` (`tool/chat_composer_probe_entry.dart`). The synthetic transcript
contains prose, headings, inline emphasis/code, fenced Dart, links, lists and a
3-column Markdown table; the stream adds 80 incremental text updates. This is a
focused widget fixture rather than a full shell/session-list capture. Runs used an isolated worktree on release web, headless Chrome at 560x1000 with
software rasterisation. These are Chrome wheel/software-raster comparison
numbers, not Android FPS; no authorized Android device was connected.
## Reproduction
From `app/` (for a reproducible follow-up, first verify and record that no
competing Flutter build, test or capture is running):
```sh
/Users/alan/development/flutter/bin/flutter build web --release \
--target tool/chat_composer_probe_entry.dart \
--output build/mobile-chat-text-profile
node --check tool/chat_perf_probe.mjs
node tool/chat_perf_probe.mjs build/mobile-chat-text-profile 20 80 3 \
> build/mobile-chat-text-profile-short.json
node tool/chat_perf_probe.mjs build/mobile-chat-text-profile 300 80 3 \
> build/mobile-chat-text-profile-long.json
```
Each repetition uses fresh pages for open, 120 wheel gestures (60 up/60 down),
and streaming. The JSON reports are in the ignored build directory. The probe
was changed only to make the phone-width/repeat count explicit; the fixture was
extended with the table above.
## Measurements
Values below are medians across three repetitions. Frame timings are Flutter
`FrameTiming` values. `over16` is the count of measured frames over 16 ms in the
software Chrome harness, not a device refresh-rate assertion.
| workload | frames | build p50 / p90 ms | raster p50 ms | total p50 / p90 ms | over16 |
| --- | ---: | ---: | ---: | ---: | ---: |
| open, 20 messages | 13 | 2.6 / 4.3 | 26.2 | 29.6 / 31.8 | 13 |
| open, 300 messages | 15 | 2.5 / 4.3 | 25.7 | 29.3 / 32.5 | 15 |
| scroll, 20 messages | 120 | 1.4 / 6.7 | 25.0 | 28.0 / 36.0 | 120 |
| scroll, 300 messages | 245 | 1.5 / 6.8 | 24.7 | 27.6 / 35.9 | 245 |
| stream, 20 messages | 165 | 1.3 / 3.7 | 24.7 | 27.6 / 30.1 | 165 |
| stream, 300 messages | 160 | 4.8 / 5.8 | 24.8 | 29.4 / 32.0 | 160 |
## Ranked findings
1. **Measured: raster dominates this scrolling harness.** Build p50 is 1.4–1.5
ms while raster p50 is about 25 ms. These numbers cannot identify whether
text, tables, selection, or CanvasKit compositing owns the raster cost, so
they do not justify a Markdown rewrite.
2. **Measured: the same streamed reply costs more build time with longer
history.** Stream build p50 is 4.8 ms for 300 history messages versus 1.3 ms
for 20. Both workloads append the same 80 short word deltas to a new reply;
answer length is controlled. This is correlation with history size, not
evidence of a longer answer or of Markdown parsing as the cause. Per-update
transcript/row projection, cache lookup and text/selection layout are next
candidates to isolate.
3. **Measured: opening history is not strongly message-count-sensitive here.**
Open build and total medians are effectively unchanged from 20 to 300 rows.
The transcript uses the existing row construction and `ChatMarkdownCache`;
this does not prove all native-device layout costs are equivalent.
4. **Evidence-backed next candidate, not a defect finding:**
`ChatMarkdownView` renders tables with `IntrinsicColumnWidth`, so a focused
visible-table A/B profile is warranted. It was included in this workload but
not isolated from the rest of rich Markdown.
## Next small experiment
Use the existing full-app `tool/perf/perf_fixture.dart` rich-chat fixture to
isolate table-free versus table-rich visible answers, repeating touch and wheel
separately at 560px. Then compare the same workload on an authorized native
Android device before making a mobile performance claim. A diagnostic selection
on/off comparison may follow only if the table experiment does not explain the
raster cost; selection behavior must remain unchanged.
No production code or behavior was changed. Selection/copy, rich Markdown,
scroll anchors and drafts remain unchanged. No app tests were run because this
visit changed only profiling fixture/probe code and a note; `node --check` and
the release build succeeded.
## Manager evidence qualification
The collected samples are directional. The original handoff did not retain a
resource-contention log for every sample, and other project work was active
during this session; isolated worktrees alone do not establish a quiet CPU.
Do not treat these values as a fully isolated native performance diagnosis.
A follow-up should save contention checks with raw sample reports and use CPU
attribution to distinguish row projection, text layout and raster/compositing.
The full-app touch capture validates scrolling interaction separately; the
timing table above measures wheel input in the isolated ChatThreadView fixture.