perf: build unshown run-detail tabs after the route transition; interaction bench

FadeThroughStack(lazy: true) builds only the shown page first and the rest
one per frame once no animation runs. Opening a run detail no longer lays out
Timeline, Artifacts and Changes offstage during the route transition
(transition build 62-103 ms -> 38-59 ms); first tab switches are unchanged.

Adds tool/perf/interaction_bench.mjs (FrameTiming per interaction over the
full-app fixture, CPU profiles mapped to Dart files), fixture options for
hits/chats/graph, and notes/perf-round3.md with the survey.
This commit is contained in:
2026-11-02 13:54:56 +00:00
parent ec619234c2
commit f1ac647125
10 changed files with 720 additions and 11 deletions
+52 -10
View File
@@ -34,17 +34,19 @@ class _PageState extends State<_Page> {
final tapped = <String>[];
Widget _host(int index, {bool reduced = false}) => MaterialApp(
home: MediaQuery(
data: MediaQueryData(disableAnimations: reduced),
child: Scaffold(
body: FadeThroughStack(
index: index,
children: const [_Page('a'), _Page('b'), _Page('c')],
Widget _host(int index, {bool reduced = false, bool lazy = false}) =>
MaterialApp(
home: MediaQuery(
data: MediaQueryData(disableAnimations: reduced),
child: Scaffold(
body: FadeThroughStack(
index: index,
lazy: lazy,
children: const [_Page('a'), _Page('b'), _Page('c')],
),
),
),
),
),
);
);
double _opacityOf(WidgetTester tester, String name) => tester
.widget<Opacity>(
@@ -129,4 +131,44 @@ void main() {
await tester.pump();
expect(_opacityOf(tester, 'b'), 1.0);
});
testWidgets('a lazy stack builds the shown page, then the rest when idle', (
tester,
) async {
await tester.pumpWidget(_host(0, lazy: true));
expect(find.text('page a'), findsOneWidget);
expect(find.text('page b', skipOffstage: false), findsNothing);
expect(find.text('page c', skipOffstage: false), findsNothing);
// One page per idle frame: b first, then c in a later frame.
var frames = 0;
Future<void> frameUntil(String page) async {
while (find.text(page, skipOffstage: false).evaluate().isEmpty) {
expect(frames++, lessThan(20));
await tester.pump(const Duration(milliseconds: 16));
}
}
await frameUntil('page b');
expect(find.text('page c', skipOffstage: false), findsNothing);
await frameUntil('page c');
expect(_onstage(tester, 'b'), isFalse);
expect(_onstage(tester, 'c'), isFalse);
});
testWidgets('a lazy stack keeps each page and its state', (tester) async {
await tester.pumpWidget(_host(0, lazy: true));
await tester.enterText(find.byKey(const Key('field a')), 'draft');
final first = tester.state(find.byType(_Page).first);
await tester.pumpWidget(_host(2, lazy: true));
await tester.pump(Motion.tabFadeThrough * 2);
expect(find.text('page c'), findsOneWidget);
expect(_opacityOf(tester, 'c'), 1.0);
await tester.pumpWidget(_host(0, lazy: true));
await tester.pumpAndSettle();
expect(tester.state(find.byType(_Page).first), same(first));
expect(find.text('draft'), findsOneWidget);
});
}