Skip to content

Commit da7fe06

Browse files
Adds benchmark for windows shadow text. (flutter#190861)
issue flutter#190395 ## test results on macos Metric | Stock Engine (host_profile) | Patched Engine (text-shadow-cache-by-content) | Improvement --------------------------------------------|--------------------------------------------|-----------------------------------------------|------------------------------------------- Average Raster Time | 6.82 ms | 1.11 ms | ~6.1x faster 90th Percentile Raster Time | 8.66 ms | 1.72 ms | ~5.0x faster 99th Percentile Raster Time | 9.73 ms | 2.53 ms | ~3.8x faster Worst Frame Raster Time | 10.14 ms | 2.67 ms | ~3.8x faster The patch is from flutter#190681 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [AI contribution guidelines]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
1 parent 8d047a7 commit da7fe06

8 files changed

Lines changed: 197 additions & 0 deletions

File tree

‎.ci.yaml‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7261,6 +7261,20 @@ targets:
72617261
]
72627262
task_name: windows_home_scroll_perf__timeline_summary
72637263

7264+
- name: Windows windows_text_shadow_perf__timeline_summary
7265+
recipe: devicelab/devicelab_drone
7266+
presubmit: false
7267+
bringup: true
7268+
timeout: 60
7269+
properties:
7270+
tags: >
7271+
["devicelab", "hostonly", "windows"]
7272+
dependencies: >-
7273+
[
7274+
{"dependency": "vs_build", "version": "version:vs2019"}
7275+
]
7276+
task_name: windows_text_shadow_perf__timeline_summary
7277+
72647278
- name: Windows_arm64 windows_home_scroll_perf__timeline_summary
72657279
recipe: devicelab/devicelab_drone
72667280
presubmit: false

‎TESTOWNERS‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@
333333
/dev/devicelab/bin/tasks/windows_desktop_impeller.dart @jonahwilliams @flutter/engine
334334
/dev/devicelab/bin/tasks/windows_engine_integration_golden_test.dart @b-luk @flutter/engine
335335
/dev/devicelab/bin/tasks/windows_home_scroll_perf__timeline_summary.dart @jonahwilliams @flutter/engine
336+
/dev/devicelab/bin/tasks/windows_text_shadow_perf__timeline_summary.dart @gaaclarke @flutter/engine
336337
/dev/devicelab/bin/tasks/windows_startup_test.dart @loic-sharma @flutter/desktop
337338

338339
## Host only framework tests

‎dev/benchmarks/macrobenchmarks/lib/common.dart‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ const String kDrawAtlasPageRouteName = '/draw_atlas';
4545
const String kAnimatedAdvancedBlend = '/animated_advanced_blend';
4646
const String kRRectBlurRouteName = '/rrect_blur';
4747
const String kRSuperellipseBlurRouteName = '/rsuperellipse_blur';
48+
const String kTextShadowPerfRouteName = '/text_shadow_perf';
4849

4950
const String kOpacityPeepholeOneRectRouteName = '$kOpacityPeepholeRouteName/one_big_rect';
5051
const String kOpacityPeepholeColumnOfOpacityRouteName =

‎dev/benchmarks/macrobenchmarks/lib/main.dart‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import 'src/simple_animation.dart';
4444
import 'src/simple_scroll.dart';
4545
import 'src/sliders.dart';
4646
import 'src/text.dart';
47+
import 'src/text_shadow_perf.dart';
4748
import 'src/very_long_picture_scrolling.dart';
4849

4950
const String kMacrobenchmarks = 'Macrobenchmarks';
@@ -118,6 +119,7 @@ class MacrobenchmarksApp extends StatelessWidget {
118119
const DrawArcsPage(paintStyle: PaintingStyle.fill),
119120
kDrawArcsAllStrokeStylesPageRouteName: (BuildContext context) =>
120121
const DrawArcsPage(paintStyle: PaintingStyle.stroke),
122+
kTextShadowPerfRouteName: (BuildContext context) => const TextShadowPerfPage(),
121123
},
122124
);
123125
}
@@ -429,6 +431,13 @@ class HomePage extends StatelessWidget {
429431
Navigator.pushNamed(context, kDrawArcsAllStrokeStylesPageRouteName);
430432
},
431433
),
434+
ElevatedButton(
435+
key: const Key(kTextShadowPerfRouteName),
436+
child: const Text('Text Shadow Performance'),
437+
onPressed: () {
438+
Navigator.pushNamed(context, kTextShadowPerfRouteName);
439+
},
440+
),
432441
],
433442
),
434443
);
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
// Copyright 2014 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import 'package:flutter/material.dart';
6+
7+
/// Macrobenchmark page reproducing the text shadow scrolling workload from
8+
/// https://github.com/flutter/flutter/issues/190395.
9+
class TextShadowPerfPage extends StatefulWidget {
10+
const TextShadowPerfPage({super.key});
11+
12+
@override
13+
State<TextShadowPerfPage> createState() => _TextShadowPerfPageState();
14+
}
15+
16+
class _TextShadowPerfPageState extends State<TextShadowPerfPage>
17+
with SingleTickerProviderStateMixin {
18+
late final ScrollController _scrollController;
19+
late final AnimationController _animationController;
20+
21+
@override
22+
void initState() {
23+
super.initState();
24+
_scrollController = ScrollController();
25+
_animationController = AnimationController(vsync: this, duration: const Duration(seconds: 10))
26+
..repeat(reverse: true);
27+
_animationController.addListener(_onAnimationTick);
28+
}
29+
30+
void _onAnimationTick() {
31+
if (_scrollController.hasClients && _scrollController.position.maxScrollExtent > 0) {
32+
_scrollController.jumpTo(
33+
_animationController.value * _scrollController.position.maxScrollExtent,
34+
);
35+
}
36+
}
37+
38+
@override
39+
void dispose() {
40+
_animationController.removeListener(_onAnimationTick);
41+
_animationController.dispose();
42+
_scrollController.dispose();
43+
super.dispose();
44+
}
45+
46+
@override
47+
Widget build(BuildContext context) {
48+
const columnCount = 7;
49+
const groupsPerColumn = 28;
50+
51+
return Scaffold(
52+
backgroundColor: const Color(0xff080808),
53+
body: ScrollConfiguration(
54+
behavior: ScrollConfiguration.of(context).copyWith(scrollbars: false),
55+
child: SingleChildScrollView(
56+
controller: _scrollController,
57+
child: Row(
58+
crossAxisAlignment: CrossAxisAlignment.start,
59+
children: List<Widget>.generate(columnCount, (int column) {
60+
return Expanded(
61+
child: Padding(
62+
padding: const EdgeInsets.all(6),
63+
child: Column(
64+
crossAxisAlignment: CrossAxisAlignment.stretch,
65+
children: List<Widget>.generate(groupsPerColumn, (int row) {
66+
return _TextShadowGroup(index: column * groupsPerColumn + row);
67+
}),
68+
),
69+
),
70+
);
71+
}),
72+
),
73+
),
74+
),
75+
);
76+
}
77+
}
78+
79+
class _TextShadowGroup extends StatelessWidget {
80+
const _TextShadowGroup({required this.index});
81+
82+
final int index;
83+
84+
static const List<Shadow> _shadows = <Shadow>[Shadow(blurRadius: 1.0)];
85+
86+
@override
87+
Widget build(BuildContext context) {
88+
return SizedBox(
89+
height: 230,
90+
child: Align(
91+
alignment: Alignment.bottomLeft,
92+
child: Padding(
93+
padding: const EdgeInsets.all(12),
94+
child: Column(
95+
mainAxisSize: MainAxisSize.min,
96+
crossAxisAlignment: CrossAxisAlignment.start,
97+
children: <Widget>[
98+
Text(
99+
'Synthetic text item $index',
100+
maxLines: 2,
101+
overflow: TextOverflow.ellipsis,
102+
style: const TextStyle(
103+
color: Colors.white,
104+
fontSize: 10,
105+
fontWeight: FontWeight.bold,
106+
shadows: _shadows,
107+
),
108+
),
109+
Row(
110+
children: <Widget>[
111+
Text(
112+
'${8 + index % 14}:30',
113+
style: const TextStyle(
114+
color: Color(0xff43ddff),
115+
fontSize: 9,
116+
fontWeight: FontWeight.bold,
117+
shadows: _shadows,
118+
),
119+
),
120+
const Spacer(),
121+
Text(
122+
'Ep ${1 + index % 24}',
123+
style: const TextStyle(color: Colors.white70, fontSize: 9, shadows: _shadows),
124+
),
125+
],
126+
),
127+
],
128+
),
129+
),
130+
),
131+
);
132+
}
133+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2014 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import 'package:macrobenchmarks/common.dart';
6+
7+
import 'util.dart';
8+
9+
void main() {
10+
macroPerfTest(
11+
'text_shadow_perf',
12+
kTextShadowPerfRouteName,
13+
pageDelay: const Duration(seconds: 1),
14+
duration: const Duration(seconds: 10),
15+
);
16+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright 2014 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import 'package:flutter_devicelab/framework/devices.dart';
6+
import 'package:flutter_devicelab/framework/framework.dart';
7+
import 'package:flutter_devicelab/tasks/perf_tests.dart';
8+
9+
Future<void> main() async {
10+
deviceOperatingSystem = DeviceOperatingSystem.windows;
11+
await task(createTextShadowPerfTest());
12+
}

‎dev/devicelab/lib/tasks/perf_tests.dart‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,17 @@ TaskFunction createTextfieldPerfE2ETest() {
376376
).run;
377377
}
378378

379+
/// Creates a task that runs the text shadow performance benchmark.
380+
TaskFunction createTextShadowPerfTest({bool? enableImpeller}) {
381+
return PerfTest(
382+
'${flutterDirectory.path}/dev/benchmarks/macrobenchmarks',
383+
'test_driver/run_app.dart',
384+
'text_shadow_perf',
385+
testDriver: 'test_driver/text_shadow_perf_test.dart',
386+
enableImpeller: enableImpeller,
387+
).run;
388+
}
389+
379390
TaskFunction createVeryLongPictureScrollingPerfE2ETest({required bool enableImpeller}) {
380391
return PerfTest.e2e(
381392
'${flutterDirectory.path}/dev/benchmarks/macrobenchmarks',

0 commit comments

Comments
 (0)