diff --git a/dev/devicelab/bin/tasks/flutter_gallery_sksl_warmup__transition_perf.dart b/dev/devicelab/bin/tasks/flutter_gallery_sksl_warmup__transition_perf.dart new file mode 100644 index 0000000000..3bf7240f2b --- /dev/null +++ b/dev/devicelab/bin/tasks/flutter_gallery_sksl_warmup__transition_perf.dart @@ -0,0 +1,14 @@ +// 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:async'; + +import 'package:flutter_devicelab/tasks/perf_tests.dart'; +import 'package:flutter_devicelab/framework/adb.dart'; +import 'package:flutter_devicelab/framework/framework.dart'; + +Future main() async { + deviceOperatingSystem = DeviceOperatingSystem.android; + await task(createFlutterGalleryTransitionsPerfSkSLWarmupTest()); +} diff --git a/dev/devicelab/bin/tasks/flutter_gallery_sksl_warmup_ios32__transition_perf.dart b/dev/devicelab/bin/tasks/flutter_gallery_sksl_warmup_ios32__transition_perf.dart new file mode 100644 index 0000000000..2b680c719a --- /dev/null +++ b/dev/devicelab/bin/tasks/flutter_gallery_sksl_warmup_ios32__transition_perf.dart @@ -0,0 +1,14 @@ +// 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:async'; + +import 'package:flutter_devicelab/tasks/perf_tests.dart'; +import 'package:flutter_devicelab/framework/adb.dart'; +import 'package:flutter_devicelab/framework/framework.dart'; + +Future main() async { + deviceOperatingSystem = DeviceOperatingSystem.ios; + await task(createFlutterGalleryTransitionsPerfSkSLWarmupTest()); +} diff --git a/dev/devicelab/lib/tasks/perf_tests.dart b/dev/devicelab/lib/tasks/perf_tests.dart index 5f443cf4db..bb22c710b7 100644 --- a/dev/devicelab/lib/tasks/perf_tests.dart +++ b/dev/devicelab/lib/tasks/perf_tests.dart @@ -91,6 +91,14 @@ TaskFunction createCubicBezierPerfSkSLWarmupTest() { ).run; } +TaskFunction createFlutterGalleryTransitionsPerfSkSLWarmupTest() { + return PerfTestWithSkSL( + '${flutterDirectory.path}/dev/integration_tests/flutter_gallery', + 'test_driver/transitions_perf.dart', + 'transitions', + ).run; +} + TaskFunction createBackdropFilterPerfTest({bool needsMeasureCpuGpu = false}) { return PerfTest( '${flutterDirectory.path}/dev/benchmarks/macrobenchmarks', @@ -296,8 +304,8 @@ class PerfTest { @protected Future internalRun({ - bool keepRunning = false, bool cacheSkSL = false, + bool noBuild = false, String existingApp, String writeSkslFileName, }) { @@ -309,10 +317,11 @@ class PerfTest { await flutter('drive', options: [ '-v', + '--verbose-system-logs', '--profile', '--trace-startup', // Enables "endless" timeline event buffering. - '-t', - testTarget, + '-t', testTarget, + if (noBuild) '--no-build', if (testDriver != null) ...['--driver', testDriver], if (existingApp != null) @@ -320,7 +329,6 @@ class PerfTest { if (writeSkslFileName != null) ...['--write-sksl-on-exit', writeSkslFileName], if (cacheSkSL) '--cache-sksl', - if (keepRunning) '--keep-app-running', '-d', deviceId, ]); @@ -401,23 +409,29 @@ class PerfTestWithSkSL extends PerfTest { } Future _generateSkSL() async { + // `flutter drive` without `flutter run`, and `flutter drive --existing-app` + // with `flutter run` may generate different SkSLs. Hence we run both + // versions to generate as many SkSLs as possible. + // + // 1st, `flutter drive --existing-app` with `flutter run`. The + // `--write-sksl-on-exit` option doesn't seem to be compatible with + // `flutter drive --existing-app` as it will complain web socket connection + // issues. + final String observatoryUri = await _runApp(cacheSkSL: true); + await super.internalRun(cacheSkSL: true, existingApp: observatoryUri); + _runProcess.kill(); + await _runProcess.exitCode; + + // 2nd, `flutter drive` without `flutter run`. The --no-build option ensures + // that we won't remove the SkSLs generated earlier. await super.internalRun( - keepRunning: true, cacheSkSL: true, + noBuild: true, writeSkslFileName: _skslJsonFileName, ); } - // Return the VMService URI. - Future _buildAndRun() async { - await flutter('build', options: [ - // TODO(liyuqian): also supports iOS once https://github.com/flutter/flutter/issues/53115 is fully closed. - 'apk', - '--profile', - '--bundle-sksl-path', _skslJsonFileName, - '-t', testTarget, - ]); - + Future _runApp({String appBinary, bool cacheSkSL = false}) async { if (File(_vmserviceFileName).existsSync()) { File(_vmserviceFileName).deleteSync(); } @@ -427,12 +441,13 @@ class PerfTestWithSkSL extends PerfTest { [ 'run', '--verbose', + '--verbose-system-logs', '--profile', + if (cacheSkSL) '--cache-sksl', '-d', _device.deviceId, '-t', testTarget, '--endless-trace-buffer', - '--use-application-binary', - '$testDirectory/build/app/outputs/flutter-apk/app-profile.apk', + if (appBinary != null) ...['--use-application-binary', _appBinary], '--vmservice-out-file', _vmserviceFileName, ], ); @@ -445,9 +460,35 @@ class PerfTestWithSkSL extends PerfTest { return file.readAsStringSync(); } + // Return the VMService URI. + Future _buildAndRun() async { + await flutter('build', options: [ + if (_isAndroid) 'apk' else 'ios', + '--profile', + '--bundle-sksl-path', _skslJsonFileName, + '-t', testTarget, + ]); + + return _runApp(appBinary: _appBinary); + } + String get _skslJsonFileName => '$testDirectory/flutter_01.sksl.json'; String get _vmserviceFileName => '$testDirectory/$_kVmserviceOutFileName'; + bool get _isAndroid => deviceOperatingSystem == DeviceOperatingSystem.android; + + String get _appBinary { + if (_isAndroid) { + return '$testDirectory/build/app/outputs/flutter-apk/app-profile.apk'; + } + for (final FileSystemEntity entry in Directory('$testDirectory/build/ios/iphoneos/').listSync()) { + if (entry.path.endsWith('.app')) { + return entry.path; + } + } + throw 'No app found.'; + } + Stream _transform(Stream> stream) => stream.transform(utf8.decoder).transform(const LineSplitter()); diff --git a/dev/devicelab/manifest.yaml b/dev/devicelab/manifest.yaml index 5dd1a43790..8021231872 100644 --- a/dev/devicelab/manifest.yaml +++ b/dev/devicelab/manifest.yaml @@ -175,6 +175,14 @@ tasks: stage: devicelab required_agent_capabilities: ["mac/android"] + flutter_gallery_sksl_warmup_ios32__transition_perf: + description: > + Measures the runtime performance of Flutter gallery transitions on iPhone4s + with SkSL shader warm-up. + stage: devicelab + required_agent_capabilities: ["mac/ios32"] + flaky: true + backdrop_filter_perf__timeline_summary: description: > Measures the runtime performance of backdrop filter blurs on Android. @@ -739,6 +747,14 @@ tasks: stage: devicelab required_agent_capabilities: ["linux/android"] + flutter_gallery_sksl_warmup__transition_perf: + description: > + Measures the runtime performance of Flutter gallery transitions on Android + with SkSL shader warm-up. + stage: devicelab + required_agent_capabilities: ["linux/android"] + flaky: true + flutter_gallery__transition_perf_with_semantics: description: > Measures the delta in performance of screen transitions without and