Unverified Commit 4247e1ef authored by gaaclarke's avatar gaaclarke Committed by GitHub

Added new gallery benchmark test that forces opengles. (#131796)

fixes https://github.com/flutter/flutter/issues/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: 's avatarXilai Zhang <xilaizhang@google.com>
parent 4f9a7e29
......@@ -2309,6 +2309,17 @@ targets:
["devicelab", "android", "linux", "samsung", "s10"]
task_name: new_gallery_impeller__transition_perf
- name: Linux_samsung_s10 new_gallery_opengles_impeller__transition_perf
bringup: true
recipe: devicelab/devicelab_drone
presubmit: false
timeout: 60
properties:
ignore_flakiness: "true"
tags: >
["devicelab", "android", "linux", "samsung", "s10"]
task_name: new_gallery_opengles_impeller__transition_perf
- name: Linux_android picture_cache_perf__e2e_summary
recipe: devicelab/devicelab_drone
presubmit: false
......
......@@ -137,6 +137,7 @@
/dev/devicelab/bin/tasks/microbenchmarks.dart @zanderso @flutter/engine
/dev/devicelab/bin/tasks/new_gallery__transition_perf.dart @zanderso @flutter/engine
/dev/devicelab/bin/tasks/new_gallery_impeller__transition_perf.dart @zanderso @flutter/engine
/dev/devicelab/bin/tasks/new_gallery_opengles_impeller__transition_perf.dart @gaaclarke @flutter/engine
/dev/devicelab/bin/tasks/picture_cache_perf__timeline_summary.dart @zanderso @flutter/engine
/dev/devicelab/bin/tasks/platform_channel_sample_test.dart @zanderso @flutter/engine
/dev/devicelab/bin/tasks/platform_interaction_test.dart @stuartmorgan @flutter/plugin
......
......@@ -46,6 +46,7 @@ dependencies:
mime: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
node_preamble: 2.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
package_config: 2.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
petitparser: 5.4.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
pool: 1.5.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
pub_semver: 2.1.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
pubspec_parse: 1.2.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
......@@ -68,9 +69,10 @@ dependencies:
web: 0.1.4-beta # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
web_socket_channel: 2.4.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
webkit_inspection_protocol: 1.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
xml: 6.3.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
yaml: 3.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
dev_dependencies:
test_api: 0.6.1
# PUBSPEC CHECKSUM: e586
# PUBSPEC CHECKSUM: 7431
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:io';
import 'package:flutter_devicelab/framework/devices.dart';
import 'package:flutter_devicelab/framework/framework.dart';
import 'package:flutter_devicelab/framework/utils.dart';
import 'package:flutter_devicelab/tasks/new_gallery.dart';
import 'package:path/path.dart' as path;
Future<void> main() async {
deviceOperatingSystem = DeviceOperatingSystem.android;
final Directory galleryParentDir = Directory.systemTemp.createTempSync('flutter_new_gallery_test.');
final Directory galleryDir = Directory(path.join(galleryParentDir.path, 'gallery'));
try {
await task(NewGalleryPerfTest(galleryDir, enableImpeller: true, forceOpenGLES: true).run);
} finally {
rmTree(galleryParentDir);
}
}
......@@ -16,6 +16,7 @@ class NewGalleryPerfTest extends PerfTest {
String dartDefine = '',
super.enableImpeller,
super.timeoutSeconds,
super.forceOpenGLES,
}) : super(
galleryDir.path,
'test_driver/transitions_perf.dart',
......
......@@ -9,6 +9,7 @@ import 'dart:math' as math;
import 'package:meta/meta.dart';
import 'package:path/path.dart' as path;
import 'package:xml/xml.dart';
import '../framework/devices.dart';
import '../framework/framework.dart';
......@@ -691,6 +692,63 @@ Map<String, dynamic> _average(List<Map<String, dynamic>> results, int iterations
return tally;
}
/// Opens the file at testDirectory + 'android/app/src/main/AndroidManifest.xml'
/// and adds the following entry to the application.
/// <meta-data
/// android:name="io.flutter.embedding.android.ImpellerBackend"
/// android:value="opengles" />
void _addOpenGLESToManifest(String testDirectory) {
final String manifestPath = path.join(
testDirectory, 'android', 'app', 'src', 'main', 'AndroidManifest.xml');
final File file = File(manifestPath);
if (!file.existsSync()) {
throw Exception('AndroidManifest.xml not found at $manifestPath');
}
final String xmlStr = file.readAsStringSync();
final XmlDocument xmlDoc = XmlDocument.parse(xmlStr);
const String key = 'io.flutter.embedding.android.ImpellerBackend';
const String value = 'opengles';
final XmlElement applicationNode =
xmlDoc.findAllElements('application').first;
// Check if the meta-data node already exists.
final Iterable<XmlElement> existingMetaData = applicationNode
.findAllElements('meta-data')
.where((XmlElement node) => node.getAttribute('android:name') == key);
if (existingMetaData.isNotEmpty) {
final XmlElement existingEntry = existingMetaData.first;
existingEntry.setAttribute('android:value', value);
} else {
final XmlElement metaData = XmlElement(
XmlName('meta-data'),
<XmlAttribute>[
XmlAttribute(XmlName('android:name'), key),
XmlAttribute(XmlName('android:value'), value)
],
);
applicationNode.children.add(metaData);
}
file.writeAsStringSync(xmlDoc.toXmlString(pretty: true, indent: ' '));
}
Future<void> _resetManifest(String testDirectory) async {
final String manifestPath = path.join(
testDirectory, 'android', 'app', 'src', 'main', 'AndroidManifest.xml');
final File file = File(manifestPath);
if (!file.existsSync()) {
throw Exception('AndroidManifest.xml not found at $manifestPath');
}
await exec('git', <String>['checkout', file.path]);
}
/// Measure application startup performance.
class StartupTest {
const StartupTest(this.testDirectory, { this.reportMetrics = true, this.target = 'lib/main.dart' });
......@@ -978,6 +1036,7 @@ class PerfTest {
this.flutterDriveCallback,
this.timeoutSeconds,
this.enableImpeller,
this.forceOpenGLES,
}): _resultFilename = resultFilename;
const PerfTest.e2e(
......@@ -995,6 +1054,7 @@ class PerfTest {
this.flutterDriveCallback,
this.timeoutSeconds,
this.enableImpeller,
this.forceOpenGLES,
}) : saveTraceFile = false, timelineFileName = null, _resultFilename = resultFilename;
/// The directory where the app under test is defined.
......@@ -1031,6 +1091,9 @@ class PerfTest {
/// Whether the perf test should enable Impeller.
final bool? enableImpeller;
/// Whether the perf test force Impeller's OpenGLES backend.
final bool? forceOpenGLES;
/// Number of seconds to time out the test after, allowing debug callbacks to run.
final int? timeoutSeconds;
......@@ -1079,40 +1142,55 @@ class PerfTest {
final String? localEngine = localEngineFromEnv;
final String? localEngineSrcPath = localEngineSrcPathFromEnv;
final List<String> options = <String>[
if (localEngine != null)
...<String>['--local-engine', localEngine],
if (localEngineSrcPath != null)
...<String>['--local-engine-src-path', localEngineSrcPath],
'--no-dds',
'--no-android-gradle-daemon',
'-v',
'--verbose-system-logs',
'--profile',
if (timeoutSeconds != null)
...<String>[
Future<void> Function()? manifestReset;
if (forceOpenGLES ?? false) {
assert(enableImpeller!);
_addOpenGLESToManifest(testDirectory);
manifestReset = () => _resetManifest(testDirectory);
}
try {
final List<String> options = <String>[
if (localEngine != null) ...<String>['--local-engine', localEngine],
if (localEngineSrcPath != null) ...<String>[
'--local-engine-src-path',
localEngineSrcPath
],
'--no-dds',
'--no-android-gradle-daemon',
'-v',
'--verbose-system-logs',
'--profile',
if (timeoutSeconds != null) ...<String>[
'--timeout',
timeoutSeconds.toString(),
],
if (needsFullTimeline)
'--trace-startup', // Enables "endless" timeline event buffering.
'-t', testTarget,
if (testDriver != null)
...<String>['--driver', testDriver!],
if (existingApp != null)
...<String>['--use-existing-app', existingApp],
if (dartDefine.isNotEmpty)
...<String>['--dart-define', dartDefine],
if (enableImpeller != null && enableImpeller!) '--enable-impeller',
if (enableImpeller != null && !enableImpeller!) '--no-enable-impeller',
'-d',
deviceId,
];
if (flutterDriveCallback != null) {
flutterDriveCallback!(options);
} else {
await flutter('drive', options: options);
if (needsFullTimeline)
'--trace-startup', // Enables "endless" timeline event buffering.
'-t', testTarget,
if (testDriver != null) ...<String>['--driver', testDriver!],
if (existingApp != null) ...<String>[
'--use-existing-app',
existingApp
],
if (dartDefine.isNotEmpty) ...<String>['--dart-define', dartDefine],
if (enableImpeller != null && enableImpeller!) '--enable-impeller',
if (enableImpeller != null && !enableImpeller!)
'--no-enable-impeller',
'-d',
deviceId,
];
if (flutterDriveCallback != null) {
flutterDriveCallback!(options);
} else {
await flutter('drive', options: options);
}
} finally {
if (manifestReset != null) {
await manifestReset();
}
}
final Map<String, dynamic> data = json.decode(
file('${_testOutputDirectory(testDirectory)}/$resultFilename.json').readAsStringSync(),
) as Map<String, dynamic>;
......
......@@ -23,6 +23,7 @@ dependencies:
vm_service: 11.8.0
web: 0.1.4-beta
webkit_inspection_protocol: 1.2.0
xml: 6.3.0
_discoveryapis_commons: 1.0.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
async: 2.11.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
......@@ -37,6 +38,7 @@ dependencies:
js: 0.6.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
json_annotation: 4.8.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
mime: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
petitparser: 5.4.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
pub_semver: 2.1.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
retry: 3.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
source_span: 1.10.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
......@@ -71,4 +73,4 @@ dev_dependencies:
watcher: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
web_socket_channel: 2.4.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
# PUBSPEC CHECKSUM: a9f3
# PUBSPEC CHECKSUM: 289e
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment