Skip to content

Commit 4247e1e

Browse files
Added new gallery benchmark test that forces opengles. (#131796)
fixes flutter/flutter#131782 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [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] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/wiki/Tree-hygiene#overview [Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene [test-exempt]: https://github.com/flutter/flutter/wiki/Tree-hygiene#tests [Flutter Style Guide]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo [Features we expect every widget to implement]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#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/wiki/Tree-hygiene#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/wiki/Chat --------- Co-authored-by: Xilai Zhang <[email protected]>
1 parent 4f9a7e2 commit 4247e1e

File tree

7 files changed

+151
-32
lines changed

7 files changed

+151
-32
lines changed

.ci.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2309,6 +2309,17 @@ targets:
23092309
["devicelab", "android", "linux", "samsung", "s10"]
23102310
task_name: new_gallery_impeller__transition_perf
23112311

2312+
- name: Linux_samsung_s10 new_gallery_opengles_impeller__transition_perf
2313+
bringup: true
2314+
recipe: devicelab/devicelab_drone
2315+
presubmit: false
2316+
timeout: 60
2317+
properties:
2318+
ignore_flakiness: "true"
2319+
tags: >
2320+
["devicelab", "android", "linux", "samsung", "s10"]
2321+
task_name: new_gallery_opengles_impeller__transition_perf
2322+
23122323
- name: Linux_android picture_cache_perf__e2e_summary
23132324
recipe: devicelab/devicelab_drone
23142325
presubmit: false

TESTOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@
137137
/dev/devicelab/bin/tasks/microbenchmarks.dart @zanderso @flutter/engine
138138
/dev/devicelab/bin/tasks/new_gallery__transition_perf.dart @zanderso @flutter/engine
139139
/dev/devicelab/bin/tasks/new_gallery_impeller__transition_perf.dart @zanderso @flutter/engine
140+
/dev/devicelab/bin/tasks/new_gallery_opengles_impeller__transition_perf.dart @gaaclarke @flutter/engine
140141
/dev/devicelab/bin/tasks/picture_cache_perf__timeline_summary.dart @zanderso @flutter/engine
141142
/dev/devicelab/bin/tasks/platform_channel_sample_test.dart @zanderso @flutter/engine
142143
/dev/devicelab/bin/tasks/platform_interaction_test.dart @stuartmorgan @flutter/plugin

dev/bots/pubspec.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ dependencies:
4646
mime: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
4747
node_preamble: 2.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
4848
package_config: 2.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
49+
petitparser: 5.4.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
4950
pool: 1.5.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
5051
pub_semver: 2.1.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
5152
pubspec_parse: 1.2.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
@@ -68,9 +69,10 @@ dependencies:
6869
web: 0.1.4-beta # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
6970
web_socket_channel: 2.4.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
7071
webkit_inspection_protocol: 1.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
72+
xml: 6.3.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
7173
yaml: 3.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
7274

7375
dev_dependencies:
7476
test_api: 0.6.1
7577

76-
# PUBSPEC CHECKSUM: e586
78+
# PUBSPEC CHECKSUM: 7431
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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 'dart:io';
6+
7+
import 'package:flutter_devicelab/framework/devices.dart';
8+
import 'package:flutter_devicelab/framework/framework.dart';
9+
import 'package:flutter_devicelab/framework/utils.dart';
10+
import 'package:flutter_devicelab/tasks/new_gallery.dart';
11+
import 'package:path/path.dart' as path;
12+
13+
Future<void> main() async {
14+
deviceOperatingSystem = DeviceOperatingSystem.android;
15+
16+
final Directory galleryParentDir = Directory.systemTemp.createTempSync('flutter_new_gallery_test.');
17+
final Directory galleryDir = Directory(path.join(galleryParentDir.path, 'gallery'));
18+
19+
try {
20+
await task(NewGalleryPerfTest(galleryDir, enableImpeller: true, forceOpenGLES: true).run);
21+
} finally {
22+
rmTree(galleryParentDir);
23+
}
24+
}

dev/devicelab/lib/tasks/new_gallery.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class NewGalleryPerfTest extends PerfTest {
1616
String dartDefine = '',
1717
super.enableImpeller,
1818
super.timeoutSeconds,
19+
super.forceOpenGLES,
1920
}) : super(
2021
galleryDir.path,
2122
'test_driver/transitions_perf.dart',

dev/devicelab/lib/tasks/perf_tests.dart

Lines changed: 108 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import 'dart:math' as math;
99

1010
import 'package:meta/meta.dart';
1111
import 'package:path/path.dart' as path;
12+
import 'package:xml/xml.dart';
1213

1314
import '../framework/devices.dart';
1415
import '../framework/framework.dart';
@@ -691,6 +692,63 @@ Map<String, dynamic> _average(List<Map<String, dynamic>> results, int iterations
691692
return tally;
692693
}
693694

695+
/// Opens the file at testDirectory + 'android/app/src/main/AndroidManifest.xml'
696+
/// and adds the following entry to the application.
697+
/// <meta-data
698+
/// android:name="io.flutter.embedding.android.ImpellerBackend"
699+
/// android:value="opengles" />
700+
void _addOpenGLESToManifest(String testDirectory) {
701+
final String manifestPath = path.join(
702+
testDirectory, 'android', 'app', 'src', 'main', 'AndroidManifest.xml');
703+
final File file = File(manifestPath);
704+
705+
if (!file.existsSync()) {
706+
throw Exception('AndroidManifest.xml not found at $manifestPath');
707+
}
708+
709+
final String xmlStr = file.readAsStringSync();
710+
final XmlDocument xmlDoc = XmlDocument.parse(xmlStr);
711+
const String key = 'io.flutter.embedding.android.ImpellerBackend';
712+
const String value = 'opengles';
713+
714+
final XmlElement applicationNode =
715+
xmlDoc.findAllElements('application').first;
716+
717+
// Check if the meta-data node already exists.
718+
final Iterable<XmlElement> existingMetaData = applicationNode
719+
.findAllElements('meta-data')
720+
.where((XmlElement node) => node.getAttribute('android:name') == key);
721+
722+
if (existingMetaData.isNotEmpty) {
723+
final XmlElement existingEntry = existingMetaData.first;
724+
existingEntry.setAttribute('android:value', value);
725+
} else {
726+
final XmlElement metaData = XmlElement(
727+
XmlName('meta-data'),
728+
<XmlAttribute>[
729+
XmlAttribute(XmlName('android:name'), key),
730+
XmlAttribute(XmlName('android:value'), value)
731+
],
732+
);
733+
734+
applicationNode.children.add(metaData);
735+
}
736+
737+
file.writeAsStringSync(xmlDoc.toXmlString(pretty: true, indent: ' '));
738+
}
739+
740+
Future<void> _resetManifest(String testDirectory) async {
741+
final String manifestPath = path.join(
742+
testDirectory, 'android', 'app', 'src', 'main', 'AndroidManifest.xml');
743+
final File file = File(manifestPath);
744+
745+
if (!file.existsSync()) {
746+
throw Exception('AndroidManifest.xml not found at $manifestPath');
747+
}
748+
749+
await exec('git', <String>['checkout', file.path]);
750+
}
751+
694752
/// Measure application startup performance.
695753
class StartupTest {
696754
const StartupTest(this.testDirectory, { this.reportMetrics = true, this.target = 'lib/main.dart' });
@@ -978,6 +1036,7 @@ class PerfTest {
9781036
this.flutterDriveCallback,
9791037
this.timeoutSeconds,
9801038
this.enableImpeller,
1039+
this.forceOpenGLES,
9811040
}): _resultFilename = resultFilename;
9821041

9831042
const PerfTest.e2e(
@@ -995,6 +1054,7 @@ class PerfTest {
9951054
this.flutterDriveCallback,
9961055
this.timeoutSeconds,
9971056
this.enableImpeller,
1057+
this.forceOpenGLES,
9981058
}) : saveTraceFile = false, timelineFileName = null, _resultFilename = resultFilename;
9991059

10001060
/// The directory where the app under test is defined.
@@ -1031,6 +1091,9 @@ class PerfTest {
10311091
/// Whether the perf test should enable Impeller.
10321092
final bool? enableImpeller;
10331093

1094+
/// Whether the perf test force Impeller's OpenGLES backend.
1095+
final bool? forceOpenGLES;
1096+
10341097
/// Number of seconds to time out the test after, allowing debug callbacks to run.
10351098
final int? timeoutSeconds;
10361099

@@ -1079,40 +1142,55 @@ class PerfTest {
10791142
final String? localEngine = localEngineFromEnv;
10801143
final String? localEngineSrcPath = localEngineSrcPathFromEnv;
10811144

1082-
final List<String> options = <String>[
1083-
if (localEngine != null)
1084-
...<String>['--local-engine', localEngine],
1085-
if (localEngineSrcPath != null)
1086-
...<String>['--local-engine-src-path', localEngineSrcPath],
1087-
'--no-dds',
1088-
'--no-android-gradle-daemon',
1089-
'-v',
1090-
'--verbose-system-logs',
1091-
'--profile',
1092-
if (timeoutSeconds != null)
1093-
...<String>[
1145+
Future<void> Function()? manifestReset;
1146+
if (forceOpenGLES ?? false) {
1147+
assert(enableImpeller!);
1148+
_addOpenGLESToManifest(testDirectory);
1149+
manifestReset = () => _resetManifest(testDirectory);
1150+
}
1151+
1152+
try {
1153+
final List<String> options = <String>[
1154+
if (localEngine != null) ...<String>['--local-engine', localEngine],
1155+
if (localEngineSrcPath != null) ...<String>[
1156+
'--local-engine-src-path',
1157+
localEngineSrcPath
1158+
],
1159+
'--no-dds',
1160+
'--no-android-gradle-daemon',
1161+
'-v',
1162+
'--verbose-system-logs',
1163+
'--profile',
1164+
if (timeoutSeconds != null) ...<String>[
10941165
'--timeout',
10951166
timeoutSeconds.toString(),
10961167
],
1097-
if (needsFullTimeline)
1098-
'--trace-startup', // Enables "endless" timeline event buffering.
1099-
'-t', testTarget,
1100-
if (testDriver != null)
1101-
...<String>['--driver', testDriver!],
1102-
if (existingApp != null)
1103-
...<String>['--use-existing-app', existingApp],
1104-
if (dartDefine.isNotEmpty)
1105-
...<String>['--dart-define', dartDefine],
1106-
if (enableImpeller != null && enableImpeller!) '--enable-impeller',
1107-
if (enableImpeller != null && !enableImpeller!) '--no-enable-impeller',
1108-
'-d',
1109-
deviceId,
1110-
];
1111-
if (flutterDriveCallback != null) {
1112-
flutterDriveCallback!(options);
1113-
} else {
1114-
await flutter('drive', options: options);
1168+
if (needsFullTimeline)
1169+
'--trace-startup', // Enables "endless" timeline event buffering.
1170+
'-t', testTarget,
1171+
if (testDriver != null) ...<String>['--driver', testDriver!],
1172+
if (existingApp != null) ...<String>[
1173+
'--use-existing-app',
1174+
existingApp
1175+
],
1176+
if (dartDefine.isNotEmpty) ...<String>['--dart-define', dartDefine],
1177+
if (enableImpeller != null && enableImpeller!) '--enable-impeller',
1178+
if (enableImpeller != null && !enableImpeller!)
1179+
'--no-enable-impeller',
1180+
'-d',
1181+
deviceId,
1182+
];
1183+
if (flutterDriveCallback != null) {
1184+
flutterDriveCallback!(options);
1185+
} else {
1186+
await flutter('drive', options: options);
1187+
}
1188+
} finally {
1189+
if (manifestReset != null) {
1190+
await manifestReset();
1191+
}
11151192
}
1193+
11161194
final Map<String, dynamic> data = json.decode(
11171195
file('${_testOutputDirectory(testDirectory)}/$resultFilename.json').readAsStringSync(),
11181196
) as Map<String, dynamic>;

dev/devicelab/pubspec.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ dependencies:
2323
vm_service: 11.8.0
2424
web: 0.1.4-beta
2525
webkit_inspection_protocol: 1.2.0
26+
xml: 6.3.0
2627

2728
_discoveryapis_commons: 1.0.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
2829
async: 2.11.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
@@ -37,6 +38,7 @@ dependencies:
3738
js: 0.6.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
3839
json_annotation: 4.8.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
3940
mime: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
41+
petitparser: 5.4.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
4042
pub_semver: 2.1.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
4143
retry: 3.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
4244
source_span: 1.10.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
@@ -71,4 +73,4 @@ dev_dependencies:
7173
watcher: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
7274
web_socket_channel: 2.4.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
7375

74-
# PUBSPEC CHECKSUM: a9f3
76+
# PUBSPEC CHECKSUM: 289e

0 commit comments

Comments
 (0)