Construct chat row contents only when slivers mount them
This commit is contained in:
@@ -1094,17 +1094,24 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
|||||||
Padding(
|
Padding(
|
||||||
key: ValueKey<String>(keys[index]),
|
key: ValueKey<String>(keys[index]),
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
child: _entering(
|
// Slivers mount only visible rows. Defer constructing
|
||||||
rows[index],
|
// their chips and checking cached widgets until then,
|
||||||
_transcriptRow(
|
// rather than visiting the entire history per delta.
|
||||||
|
child: Builder(
|
||||||
|
builder: (_) => _entering(
|
||||||
rows[index],
|
rows[index],
|
||||||
keys[index],
|
_transcriptRow(
|
||||||
onDismissCompaction:
|
rows[index],
|
||||||
compactionNotice != null &&
|
keys[index],
|
||||||
chatNoticeActivityCondition(rows[index]) ==
|
onDismissCompaction:
|
||||||
compactionNotice.condition
|
compactionNotice != null &&
|
||||||
? () => _dismiss(compactionNotice)
|
chatNoticeActivityCondition(
|
||||||
: null,
|
rows[index],
|
||||||
|
) ==
|
||||||
|
compactionNotice.condition
|
||||||
|
? () => _dismiss(compactionNotice)
|
||||||
|
: null,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
# Chat visible-row construction
|
||||||
|
|
||||||
|
## Finding and change
|
||||||
|
|
||||||
|
Every transcript delta projected the history and eagerly called `_transcriptRow`
|
||||||
|
for every row, creating permission/question chip inputs and walking cached row
|
||||||
|
content even when the row was far outside the viewport. Sliver layout was
|
||||||
|
already lazy, but this construction work happened before slivers could skip it.
|
||||||
|
A row-local `Builder` defers that construction until the sliver mounts the row.
|
||||||
|
All rows, row keys, split anchors, selection, disclosures and Markdown rendering
|
||||||
|
remain in the existing path. No Markdown subset, font or table layout changed.
|
||||||
|
|
||||||
|
## Controlled comparison
|
||||||
|
|
||||||
|
Release web `tool/chat_composer_probe_entry.dart`, software Chrome at 560x1000,
|
||||||
|
300 history messages, the same 80 streamed text updates, and 120 wheel gestures.
|
||||||
|
Alternating baseline/candidate/baseline/candidate, each with fresh phase pages.
|
||||||
|
Baseline is 7ce4b1e6 (7287ba35 plus the preserved profiling tooling); candidate
|
||||||
|
diff is the row-local Builder only. Other lanes held compiles/tests/captures
|
||||||
|
for the four measured runs. Preliminary contended measurements were excluded.
|
||||||
|
|
||||||
|
Means of the two per-run statistics, milliseconds:
|
||||||
|
|
||||||
|
| phase | baseline build mean / p90 | candidate build mean / p90 | baseline / candidate raster mean |
|
||||||
|
| --- | --- | --- | --- |
|
||||||
|
| open | 2.41 / 4.45 | 2.15 / 3.40 | 25.34 / 26.05 |
|
||||||
|
| wheel scroll | 2.21 / 6.55 | 2.25 / 6.70 | 21.32 / 21.30 |
|
||||||
|
| stream | 3.21 / 5.95 | 2.27 / 3.80 | 21.08 / 21.09 |
|
||||||
|
|
||||||
|
Streaming build mean is about 29% lower and build p90 about 36% lower here.
|
||||||
|
Scroll and software-raster cost are effectively unchanged. This is a focused
|
||||||
|
widget fixture, not full-shell timing or Android FPS evidence. Native hardware
|
||||||
|
was unavailable. The change reduces a measured source of streaming overhead;
|
||||||
|
it does not explain or claim to eliminate all perceived chat heaviness.
|
||||||
|
Raw JSON and summary are in ignored `app/build/perf-evidence/` and the private
|
||||||
|
`/tmp/chat-perf-quiet/` capture output.
|
||||||
|
|
||||||
|
## Checks
|
||||||
|
|
||||||
|
Conversation + transcript suite: 644 passed, one stale narrow Cupertino label
|
||||||
|
assertion failed (`/tmp/memwatch/out.AEK2gT`). That assertion required visible
|
||||||
|
permission text, conflicting with the user's shipped icon-only header. Updated
|
||||||
|
it to require no visible label while retaining current-value semantics and the
|
||||||
|
permission-sheet interaction. Its complete 10-test file passed after the change
|
||||||
|
(`/tmp/memwatch/out.xWOzXj`). Analyzer clean (`flutter-analyze.uyyFoA`).
|
||||||
|
The existing suite covers long-history lazy mounting, paging/anchors, live
|
||||||
|
updates, selection/copy, horizontal code/table scrolling and disclosure retention.
|
||||||
@@ -232,7 +232,7 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
testWidgets(
|
testWidgets(
|
||||||
'Cupertino narrow header displays the current permission value',
|
'Cupertino narrow header exposes the current permission on its icon',
|
||||||
(tester) async {
|
(tester) async {
|
||||||
if (!cupertino) return;
|
if (!cupertino) return;
|
||||||
final semantics = tester.ensureSemantics();
|
final semantics = tester.ensureSemantics();
|
||||||
@@ -254,7 +254,7 @@ void main() {
|
|||||||
expect(mode, findsOneWidget);
|
expect(mode, findsOneWidget);
|
||||||
expect(
|
expect(
|
||||||
find.descendant(of: mode, matching: find.text('Ask for permission')),
|
find.descendant(of: mode, matching: find.text('Ask for permission')),
|
||||||
findsOneWidget,
|
findsNothing,
|
||||||
);
|
);
|
||||||
expect(
|
expect(
|
||||||
tester.getSemantics(mode).label,
|
tester.getSemantics(mode).label,
|
||||||
|
|||||||
Reference in New Issue
Block a user