From 1ff82af54029f7bb1299030a266585a56ef31088 Mon Sep 17 00:00:00 2001 From: gaaclarke <30870216+gaaclarke@users.noreply.github.com> Date: Wed, 9 Aug 2023 10:57:35 -0700 Subject: [PATCH] [Impeller] Adds advanced blend benchmark (#131893) issue: https://github.com/flutter/flutter/issues/131784 ## 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]. [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 --- .ci.yaml | 32 +++++++ TESTOWNERS | 3 + .../ios/Runner.xcodeproj/project.pbxproj | 18 +++- .../xcshareddata/xcschemes/Runner.xcscheme | 11 +-- .../macrobenchmarks/lib/common.dart | 1 + dev/benchmarks/macrobenchmarks/lib/main.dart | 9 ++ .../lib/src/animated_advanced_blend.dart | 83 +++++++++++++++++++ .../animated_advanced_blend_perf_test.dart | 16 ++++ ...advanced_blend_perf__timeline_summary.dart | 14 ++++ ...nced_blend_perf_ios__timeline_summary.dart | 14 ++++ ...blend_perf_opengles__timeline_summary.dart | 15 ++++ dev/devicelab/lib/tasks/perf_tests.dart | 15 ++++ 12 files changed, 219 insertions(+), 12 deletions(-) create mode 100644 dev/benchmarks/macrobenchmarks/lib/src/animated_advanced_blend.dart create mode 100644 dev/benchmarks/macrobenchmarks/test_driver/animated_advanced_blend_perf_test.dart create mode 100644 dev/devicelab/bin/tasks/animated_advanced_blend_perf__timeline_summary.dart create mode 100644 dev/devicelab/bin/tasks/animated_advanced_blend_perf_ios__timeline_summary.dart create mode 100644 dev/devicelab/bin/tasks/animated_advanced_blend_perf_opengles__timeline_summary.dart diff --git a/.ci.yaml b/.ci.yaml index 1e5874e72e..65067287e2 100644 --- a/.ci.yaml +++ b/.ci.yaml @@ -2613,6 +2613,38 @@ targets: ["devicelab", "android", "linux", "samsung", "s10"] task_name: animated_blur_backdrop_filter_perf__timeline_summary + - name: Linux_samsung_s10 animated_advanced_blend_perf_opengles__timeline_summary + recipe: devicelab/devicelab_drone + presubmit: false + bringup: true + timeout: 60 + properties: + ignore_flakiness: "true" + tags: > + ["devicelab", "android", "linux", "samsung", "s10"] + task_name: animated_advanced_blend_perf_opengles__timeline_summary + + - name: Linux_samsung_s10 animated_advanced_blend_perf__timeline_summary + recipe: devicelab/devicelab_drone + presubmit: false + bringup: true + timeout: 60 + properties: + ignore_flakiness: "true" + tags: > + ["devicelab", "android", "linux", "samsung", "s10"] + task_name: animated_advanced_blend_perf__timeline_summary + + - name: Mac_ios animated_advanced_blend_perf_ios__timeline_summary + recipe: devicelab/devicelab_drone + presubmit: false + timeout: 60 + bringup: true + properties: + tags: > + ["devicelab", "ios", "mac"] + task_name: animated_advanced_blend_perf_ios__timeline_summary + - name: Linux_samsung_s10 animated_blur_backdrop_filter_perf_opengles__timeline_summary recipe: devicelab/devicelab_drone presubmit: false diff --git a/TESTOWNERS b/TESTOWNERS index cb1a439ef9..11a3dc6eb9 100644 --- a/TESTOWNERS +++ b/TESTOWNERS @@ -91,6 +91,9 @@ /dev/devicelab/bin/tasks/textfield_perf__e2e_summary.dart @zanderso @flutter/engine /dev/devicelab/bin/tasks/web_size__compile_test.dart @yjbanov @flutter/web /dev/devicelab/bin/tasks/wide_gamut_ios.dart @gaaclarke @flutter/engine +/dev/devicelab/bin/tasks/animated_advanced_blend_perf__timeline_summary.dart @gaaclarke @flutter/engine +/dev/devicelab/bin/tasks/animated_advanced_blend_perf_ios__timeline_summary.dart @gaaclarke @flutter/engine +/dev/devicelab/bin/tasks/animated_advanced_blend_perf_opengles__timeline_summary.dart @gaaclarke @flutter/engine /dev/devicelab/bin/tasks/animated_blur_backdrop_filter_perf__timeline_summary.dart @jonahwilliams @flutter/engine /dev/devicelab/bin/tasks/animated_blur_backdrop_filter_perf_opengles__timeline_summary.dart @gaaclarke @flutter/engine /dev/devicelab/bin/tasks/slider_perf_android.dart @tahatesser @flutter/framework diff --git a/dev/benchmarks/macrobenchmarks/ios/Runner.xcodeproj/project.pbxproj b/dev/benchmarks/macrobenchmarks/ios/Runner.xcodeproj/project.pbxproj index e319fa8e46..4cdd00ac38 100644 --- a/dev/benchmarks/macrobenchmarks/ios/Runner.xcodeproj/project.pbxproj +++ b/dev/benchmarks/macrobenchmarks/ios/Runner.xcodeproj/project.pbxproj @@ -132,7 +132,6 @@ 1842E3C5134E282C88C541B8 /* Pods-Runner.release.xcconfig */, F269DC09D76325C7B7334781 /* Pods-Runner.profile.xcconfig */, ); - name = Pods; path = Pods; sourceTree = ""; }; @@ -351,7 +350,10 @@ DEVELOPMENT_TEAM = S8QB4VV633; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); PRODUCT_BUNDLE_IDENTIFIER = com.example.macrobenchmarks; PRODUCT_NAME = "$(TARGET_NAME)"; VERSIONING_SYSTEM = "apple-generic"; @@ -464,9 +466,13 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = S8QB4VV633; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); PRODUCT_BUNDLE_IDENTIFIER = com.example.macrobenchmarks; PRODUCT_NAME = "$(TARGET_NAME)"; VERSIONING_SYSTEM = "apple-generic"; @@ -479,9 +485,13 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = S8QB4VV633; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); PRODUCT_BUNDLE_IDENTIFIER = com.example.macrobenchmarks; PRODUCT_NAME = "$(TARGET_NAME)"; VERSIONING_SYSTEM = "apple-generic"; diff --git a/dev/benchmarks/macrobenchmarks/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/dev/benchmarks/macrobenchmarks/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index 9997cfd251..098cec7a29 100644 --- a/dev/benchmarks/macrobenchmarks/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/dev/benchmarks/macrobenchmarks/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -26,10 +26,7 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - language = "" shouldUseLaunchSchemeArgsEnv = "YES"> - - - - + + @@ -63,8 +60,6 @@ ReferencedContainer = "container:Runner.xcodeproj"> - - const DrawPointsPage(), kDrawVerticesPageRouteName: (BuildContext context) => const DrawVerticesPage(), kDrawAtlasPageRouteName: (BuildContext context) => const DrawAtlasPage(), + kAnimatedAdvancedBlend: (BuildContext context) => const AnimatedAdvancedBlend(), }, ); } @@ -364,6 +366,13 @@ class HomePage extends StatelessWidget { Navigator.pushNamed(context, kDrawAtlasPageRouteName); }, ), + ElevatedButton( + key: const Key(kAnimatedAdvancedBlend), + child: const Text('Animated Advanced Blend'), + onPressed: () { + Navigator.pushNamed(context, kAnimatedAdvancedBlend); + }, + ), ], ), ); diff --git a/dev/benchmarks/macrobenchmarks/lib/src/animated_advanced_blend.dart b/dev/benchmarks/macrobenchmarks/lib/src/animated_advanced_blend.dart new file mode 100644 index 0000000000..c3ea0f8217 --- /dev/null +++ b/dev/benchmarks/macrobenchmarks/lib/src/animated_advanced_blend.dart @@ -0,0 +1,83 @@ +// 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 'package:flutter/material.dart'; + +class _MultiplyPainter extends CustomPainter { + _MultiplyPainter(this._color); + + final Color _color; + + @override + void paint(Canvas canvas, Size size) { + const int xDenominator = 2; + const int yDenominator = 10; + final double width = size.width / xDenominator; + final double height = size.height / yDenominator; + + for (int y = 0; y < yDenominator; y++) { + for (int x = 0; x < xDenominator; x++) { + final Rect rect = Offset(x * width, y * height) & Size(width, height); + final Paint basePaint = Paint() + ..color = Color.fromARGB( + (((x + 1) * width) / size.width * 255.0).floor(), + (((y + 1) * height) / size.height * 255.0).floor(), + 255, + 127); + canvas.drawRect(rect, basePaint); + + final Paint multiplyPaint = Paint() + ..color = _color + ..blendMode = BlendMode.multiply; + canvas.drawRect(rect, multiplyPaint); + } + } + } + + @override + bool shouldRepaint(CustomPainter oldDelegate) { + return true; + } +} + +class AnimatedAdvancedBlend extends StatefulWidget { + const AnimatedAdvancedBlend({super.key}); + + @override + State createState() => _AnimatedAdvancedBlendState(); +} + +class _AnimatedAdvancedBlendState extends State with SingleTickerProviderStateMixin { + late final AnimationController controller = AnimationController(vsync: this, duration: const Duration(milliseconds: 5000)); + late final Animation animation = controller.drive(Tween(begin: 0.0, end: 1.0)); + Color _color = const Color.fromARGB(255, 255, 0, 255); + + @override + void initState() { + super.initState(); + controller.repeat(); + animation.addListener(() { + setState(() { + _color = Color.fromARGB((animation.value * 255).floor(), 255, 0, 255); + }); + }); + } + + @override + void dispose() { + controller.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: CustomPaint( + painter: _MultiplyPainter(_color), + child: Container(), + ), + )); + } +} diff --git a/dev/benchmarks/macrobenchmarks/test_driver/animated_advanced_blend_perf_test.dart b/dev/benchmarks/macrobenchmarks/test_driver/animated_advanced_blend_perf_test.dart new file mode 100644 index 0000000000..9a7ad83cfb --- /dev/null +++ b/dev/benchmarks/macrobenchmarks/test_driver/animated_advanced_blend_perf_test.dart @@ -0,0 +1,16 @@ +// 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 'package:macrobenchmarks/common.dart'; + +import 'util.dart'; + +void main() { + macroPerfTest( + 'animated_advanced_blend_perf', + kAnimatedAdvancedBlend, + pageDelay: const Duration(seconds: 1), + duration: const Duration(seconds: 10), + ); +} diff --git a/dev/devicelab/bin/tasks/animated_advanced_blend_perf__timeline_summary.dart b/dev/devicelab/bin/tasks/animated_advanced_blend_perf__timeline_summary.dart new file mode 100644 index 0000000000..9bca1dc045 --- /dev/null +++ b/dev/devicelab/bin/tasks/animated_advanced_blend_perf__timeline_summary.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/framework/devices.dart'; +import 'package:flutter_devicelab/framework/framework.dart'; +import 'package:flutter_devicelab/tasks/perf_tests.dart'; + +Future main() async { + deviceOperatingSystem = DeviceOperatingSystem.android; + await task(createAnimatedAdvancedBlendPerfTest(enableImpeller: true)); +} diff --git a/dev/devicelab/bin/tasks/animated_advanced_blend_perf_ios__timeline_summary.dart b/dev/devicelab/bin/tasks/animated_advanced_blend_perf_ios__timeline_summary.dart new file mode 100644 index 0000000000..5d09c17870 --- /dev/null +++ b/dev/devicelab/bin/tasks/animated_advanced_blend_perf_ios__timeline_summary.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/framework/devices.dart'; +import 'package:flutter_devicelab/framework/framework.dart'; +import 'package:flutter_devicelab/tasks/perf_tests.dart'; + +Future main() async { + deviceOperatingSystem = DeviceOperatingSystem.ios; + await task(createAnimatedAdvancedBlendPerfTest(enableImpeller: true)); +} diff --git a/dev/devicelab/bin/tasks/animated_advanced_blend_perf_opengles__timeline_summary.dart b/dev/devicelab/bin/tasks/animated_advanced_blend_perf_opengles__timeline_summary.dart new file mode 100644 index 0000000000..113a496ac5 --- /dev/null +++ b/dev/devicelab/bin/tasks/animated_advanced_blend_perf_opengles__timeline_summary.dart @@ -0,0 +1,15 @@ +// 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/framework/devices.dart'; +import 'package:flutter_devicelab/framework/framework.dart'; +import 'package:flutter_devicelab/tasks/perf_tests.dart'; + +Future main() async { + deviceOperatingSystem = DeviceOperatingSystem.android; + await task(createAnimatedAdvancedBlendPerfTest( + enableImpeller: true, forceOpenGLES: true)); +} diff --git a/dev/devicelab/lib/tasks/perf_tests.dart b/dev/devicelab/lib/tasks/perf_tests.dart index 680dfc2fb3..ca408a694c 100644 --- a/dev/devicelab/lib/tasks/perf_tests.dart +++ b/dev/devicelab/lib/tasks/perf_tests.dart @@ -628,6 +628,21 @@ TaskFunction createGradientStaticPerfE2ETest() { ).run; } +TaskFunction createAnimatedAdvancedBlendPerfTest({ + bool? enableImpeller, + bool? forceOpenGLES, +}) { + return PerfTest( + '${flutterDirectory.path}/dev/benchmarks/macrobenchmarks', + 'test_driver/run_app.dart', + 'animated_advanced_blend_perf', + enableImpeller: enableImpeller, + forceOpenGLES: forceOpenGLES, + testDriver: 'test_driver/animated_advanced_blend_perf_test.dart', + saveTraceFile: true, + ).run; +} + TaskFunction createAnimatedBlurBackropFilterPerfTest({ bool? enableImpeller, bool? forceOpenGLES,