From df83398687b63762c742e35fbb608d16fee50a7a Mon Sep 17 00:00:00 2001 From: "Ming Lyu (CareF)" Date: Mon, 31 Aug 2020 20:23:06 -0400 Subject: [PATCH] Reland #61998 and update complex_layout ios files (#64885) --- .../complex_layout/android/settings.gradle | 10 + dev/benchmarks/complex_layout/ios/.gitignore | 32 ++ .../complex_layout/ios/Flutter/Debug.xcconfig | 2 + .../ios/Flutter/Release.xcconfig | 2 + dev/benchmarks/complex_layout/ios/Podfile | 41 +++ .../xcshareddata/WorkspaceSettings.xcsettings | 8 + .../xcshareddata/xcschemes/Runner.xcscheme | 91 ++++++ .../contents.xcworkspacedata | 7 + .../xcshareddata/IDEWorkspaceChecks.plist | 8 + .../xcshareddata/WorkspaceSettings.xcsettings | 8 + .../ios/Runner/AppDelegate.swift | 17 + .../Icon-App-1024x1024@1x.png | Bin 0 -> 10932 bytes .../AppIcon.appiconset/Icon-App-20x20@1x.png | Bin 0 -> 564 bytes .../AppIcon.appiconset/Icon-App-20x20@2x.png | Bin 0 -> 1283 bytes .../AppIcon.appiconset/Icon-App-20x20@3x.png | Bin 0 -> 1588 bytes .../LaunchImage.imageset/Contents.json | 23 ++ .../LaunchImage.imageset/LaunchImage.png | Bin 0 -> 68 bytes .../LaunchImage.imageset/LaunchImage@2x.png | Bin 0 -> 68 bytes .../LaunchImage.imageset/LaunchImage@3x.png | Bin 0 -> 68 bytes .../LaunchImage.imageset/README.md | 5 + .../ios/Runner/Runner-Bridging-Header.h | 5 + dev/benchmarks/complex_layout/lib/main.dart | 1 + dev/benchmarks/complex_layout/pubspec.yaml | 5 +- .../test/measure_scroll_smoothness.dart | 296 ++++++++++++++++++ .../measure_scroll_smoothness_test.dart | 17 + ...lex_layout_android__scroll_smoothness.dart | 14 + dev/devicelab/lib/tasks/perf_tests.dart | 48 +++ dev/devicelab/manifest.yaml | 8 + packages/flutter_test/lib/src/binding.dart | 1 - 29 files changed, 646 insertions(+), 3 deletions(-) create mode 100644 dev/benchmarks/complex_layout/ios/.gitignore create mode 100644 dev/benchmarks/complex_layout/ios/Flutter/Debug.xcconfig create mode 100644 dev/benchmarks/complex_layout/ios/Flutter/Release.xcconfig create mode 100644 dev/benchmarks/complex_layout/ios/Podfile create mode 100644 dev/benchmarks/complex_layout/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings create mode 100644 dev/benchmarks/complex_layout/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme create mode 100644 dev/benchmarks/complex_layout/ios/Runner.xcworkspace/contents.xcworkspacedata create mode 100644 dev/benchmarks/complex_layout/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 dev/benchmarks/complex_layout/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings create mode 100644 dev/benchmarks/complex_layout/ios/Runner/AppDelegate.swift create mode 100644 dev/benchmarks/complex_layout/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png create mode 100644 dev/benchmarks/complex_layout/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png create mode 100644 dev/benchmarks/complex_layout/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png create mode 100644 dev/benchmarks/complex_layout/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png create mode 100644 dev/benchmarks/complex_layout/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json create mode 100644 dev/benchmarks/complex_layout/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png create mode 100644 dev/benchmarks/complex_layout/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png create mode 100644 dev/benchmarks/complex_layout/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png create mode 100644 dev/benchmarks/complex_layout/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md create mode 100644 dev/benchmarks/complex_layout/ios/Runner/Runner-Bridging-Header.h create mode 100644 dev/benchmarks/complex_layout/test/measure_scroll_smoothness.dart create mode 100644 dev/benchmarks/complex_layout/test_driver/measure_scroll_smoothness_test.dart create mode 100644 dev/devicelab/bin/tasks/complex_layout_android__scroll_smoothness.dart diff --git a/dev/benchmarks/complex_layout/android/settings.gradle b/dev/benchmarks/complex_layout/android/settings.gradle index 663db3adba..d3b6a4013d 100644 --- a/dev/benchmarks/complex_layout/android/settings.gradle +++ b/dev/benchmarks/complex_layout/android/settings.gradle @@ -3,3 +3,13 @@ // found in the LICENSE file. include ':app' + +def localPropertiesFile = new File(rootProject.projectDir, "local.properties") +def properties = new Properties() + +assert localPropertiesFile.exists() +localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } + +def flutterSdkPath = properties.getProperty("flutter.sdk") +assert flutterSdkPath != null, "flutter.sdk not set in local.properties" +apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" diff --git a/dev/benchmarks/complex_layout/ios/.gitignore b/dev/benchmarks/complex_layout/ios/.gitignore new file mode 100644 index 0000000000..e96ef602b8 --- /dev/null +++ b/dev/benchmarks/complex_layout/ios/.gitignore @@ -0,0 +1,32 @@ +*.mode1v3 +*.mode2v3 +*.moved-aside +*.pbxuser +*.perspectivev3 +**/*sync/ +.sconsign.dblite +.tags* +**/.vagrant/ +**/DerivedData/ +Icon? +**/Pods/ +**/.symlinks/ +profile +xcuserdata +**/.generated/ +Flutter/App.framework +Flutter/Flutter.framework +Flutter/Flutter.podspec +Flutter/Generated.xcconfig +Flutter/app.flx +Flutter/app.zip +Flutter/flutter_assets/ +Flutter/flutter_export_environment.sh +ServiceDefinitions.json +Runner/GeneratedPluginRegistrant.* + +# Exceptions to above rules. +!default.mode1v3 +!default.mode2v3 +!default.pbxuser +!default.perspectivev3 diff --git a/dev/benchmarks/complex_layout/ios/Flutter/Debug.xcconfig b/dev/benchmarks/complex_layout/ios/Flutter/Debug.xcconfig new file mode 100644 index 0000000000..e8efba1146 --- /dev/null +++ b/dev/benchmarks/complex_layout/ios/Flutter/Debug.xcconfig @@ -0,0 +1,2 @@ +#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" +#include "Generated.xcconfig" diff --git a/dev/benchmarks/complex_layout/ios/Flutter/Release.xcconfig b/dev/benchmarks/complex_layout/ios/Flutter/Release.xcconfig new file mode 100644 index 0000000000..399e9340e6 --- /dev/null +++ b/dev/benchmarks/complex_layout/ios/Flutter/Release.xcconfig @@ -0,0 +1,2 @@ +#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" +#include "Generated.xcconfig" diff --git a/dev/benchmarks/complex_layout/ios/Podfile b/dev/benchmarks/complex_layout/ios/Podfile new file mode 100644 index 0000000000..1e8c3c90a5 --- /dev/null +++ b/dev/benchmarks/complex_layout/ios/Podfile @@ -0,0 +1,41 @@ +# Uncomment this line to define a global platform for your project +# platform :ios, '9.0' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_ios_podfile_setup + +target 'Runner' do + use_frameworks! + use_modular_headers! + + flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_ios_build_settings(target) + end +end diff --git a/dev/benchmarks/complex_layout/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/dev/benchmarks/complex_layout/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 0000000000..f9b0d7c5ea --- /dev/null +++ b/dev/benchmarks/complex_layout/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/dev/benchmarks/complex_layout/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/dev/benchmarks/complex_layout/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 0000000000..a28140cfdb --- /dev/null +++ b/dev/benchmarks/complex_layout/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/benchmarks/complex_layout/ios/Runner.xcworkspace/contents.xcworkspacedata b/dev/benchmarks/complex_layout/ios/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000000..1d526a16ed --- /dev/null +++ b/dev/benchmarks/complex_layout/ios/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/dev/benchmarks/complex_layout/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/dev/benchmarks/complex_layout/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000000..18d981003d --- /dev/null +++ b/dev/benchmarks/complex_layout/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/dev/benchmarks/complex_layout/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/dev/benchmarks/complex_layout/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 0000000000..f9b0d7c5ea --- /dev/null +++ b/dev/benchmarks/complex_layout/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/dev/benchmarks/complex_layout/ios/Runner/AppDelegate.swift b/dev/benchmarks/complex_layout/ios/Runner/AppDelegate.swift new file mode 100644 index 0000000000..d815fed684 --- /dev/null +++ b/dev/benchmarks/complex_layout/ios/Runner/AppDelegate.swift @@ -0,0 +1,17 @@ +// 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 UIKit +import Flutter + +@UIApplicationMain +@objc class AppDelegate: FlutterAppDelegate { + override func application( + _ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? + ) -> Bool { + GeneratedPluginRegistrant.register(with: self) + return super.application(application, didFinishLaunchingWithOptions: launchOptions) + } +} diff --git a/dev/benchmarks/complex_layout/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png b/dev/benchmarks/complex_layout/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png new file mode 100644 index 0000000000000000000000000000000000000000..dc9ada4725e9b0ddb1deab583e5b5102493aa332 GIT binary patch literal 10932 zcmeAS@N?(olHy`uVBq!ia0y~yU||4Z4kiW$h7a|7u7G&yj=qiz3>*8o|0J?9Ffb@2 zdj$D1FjT2AFf_CEYZQ`Nj$7&&r-9tv@bzJN?=JpBk$!-MM9JoV9=dW8?pwu7NBJ3<|t6y+Q6`U|>jKAb}wP z@+Bh!0|T)Pl1v9FZXm^Uuwph+JwYdHhz%mJCqRlp?qVRtH*lRKG3a0ov7XqFZ91Ky zp=-yFYtOcR=f2*kwYysJ-=qE$>O2e#H@0)<=fu^epDtZ+>1(~szd!s}W7(I@b#Gt@ z_`hNGum4BdrH|jWKFYwr@U{OJJ2L~r75i86JPZs0|5wx-fT#uk4l*z}{A~tH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ff --git a/dev/benchmarks/complex_layout/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png b/dev/benchmarks/complex_layout/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png new file mode 100644 index 0000000000000000000000000000000000000000..28c6bf03016f6c994b70f38d1b7346e5831b531f GIT binary patch literal 564 zcmeAS@N?(olHy`uVBq!ia0y~yU=RUe4mJh`hTcwDUIqpR#^NA%Cx&(BWL`2bFuwD2 zaSX8#TsvjAw@jeOvGY5>_q|>h+1u6fBdexi<)tM8-3iJOH-6e{csS^|t`^`h%M4z^ zvrUsp%yCUni-1dr!HteCeu1-6sf(@4&z-gOX8TrnJhnM~hPD2_`!&xEoBNpM46ZP5 z>RM6Fs4Du%wQt&V4?nF#Au;N4dCxlREhFOs+Q*8UNIXwA$#oIyO8|+tqV&R#9*$ zUnSd|Hw&5HJe-|^3yuFWnr2?uxcNuK(*U^*-n;k6AAGamV&=3x zQTjVJM+cmBEL?H-jDy2s*;QO>QThRLANE|lxz@Sy?+%4F#V^}4%*``0mhkR1xTsnd zsl4K{bVpgeu!#g~y%YEC?D&;me>Lr&{KSK$>&ee#llSpUG=!hMOnEB&rtbEo$NBpo ze0#XwfU{CPz~%7UQ+uQ}ChR*S%%W*wac<_u>)Jc^mA`9MySCxd!B^Kd#zy?>WBq3t zA?x*4_ W$LnK$#EXG}fx*+&&t;ucLK6TGg!*^@ literal 0 HcmV?d00001 diff --git a/dev/benchmarks/complex_layout/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png b/dev/benchmarks/complex_layout/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..2ccbfd967d9697cd4b83225558af2911e9571c9b GIT binary patch literal 1283 zcmeAS@N?(olHy`uVBq!ia0y~yV9)?z4mJh`hMs>rav2y{PIR?dBvs;g z{d;TUyFpPJ%eF4Kv7n|^zp=ULn1t;EM$XP7l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}ey z)$1FVT(;b{_T{serM4|X+iVsv?@3bGd0_hizGsX6s!a`EBIo^}j%A+F$3@YdzmBZj z*|cUF%e7fvr+yyrOFrYjRQJK&Nt+6#ztwGP_&n*`Q6J-9SNuJG)iEwe+w485%%@SC z)0^p~ht+}=x9!*b3^nYjoiqK*szo(3n7-R@emEuiR&Q1|0|Nttr>mdKI;Vst04OMA Ap8x;= literal 0 HcmV?d00001 diff --git a/dev/benchmarks/complex_layout/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/dev/benchmarks/complex_layout/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..f091b6b0bca859a3f474b03065bef75ba58a9e4c GIT binary patch literal 1588 zcmeAS@N?(olHy`uVBq!ia0y~yV6XvU4mJh`2CF|eix?PKe|x$(hGg8kJ3Br{#8u|_ z_r9dgjs8-qSv*|RE-Crj{anx)sHw2EzMm;qaVooM=);5T@;xrShAOR6jo*@1hGhwO z*Bn?RA+_;(9Jkc0h_1C6OiM+)8lAkW@7{ZN=luOQXSY;ezx(#?+xhn_PnvIj`}XeJ z^!>*B=l;CgqmUuO5V6FnP9n7P7vI(PUCpz+gzmb2UA)izt%L5>BmwRAzjvSyiSyI*IpJk#T4b1F!2XiIK3GC99kKERz# z#llXd+2zr$^&!bCj%$9Ht@T@0)2LZ?29M*>nVA(Yw`)dRH)Gvt71bSeUv1N8mlwNS z4~cv<&5bGxdhmFUwk2P6nbfCSt~c(e9$MyCd+~brAEhae3h!HZF0uY#ctl^M;=oEh z(YHFSOC65Z)mDD^`iD=@>%)&j5}iNhupByS+SuzUe&ptiL~GxJZZT~WzMM zs3oO+Z-U~Qw+BwLWovJkY4`eL^zEKpb~Dihf4*5{OBWa&j^dNy)Yi)|*(PgYMMC%(TgB=f_)>F?(i-{Lt}{cgTc64|8SnG>gdgv-0M z(1s<|VnxMTTb{`)Ht(^kpRVzIUFuFP+oy}nez;V8{4%BJUwpF4!=7ZH11hhWxUG8{ zA2;g0;CQ~u#_FdI|LM$&=U4x!m1<*B4F0*|#%z<{ZT|`v#dz%F+j3FFpSx_|G^hRD zW%J)k7_+H6FI!yg@DykaiKnaiTRan`fRnej^uRO`~` zZcTY`aN)}6R;!CM4$pJE5o*tx@U-)Q&jsxwiEEP794E+$s2TE$tVcc1Hf{mdn7 z8>DtsPdQ-Bv3rs0ZqMKwZ-R|d*iW(@%W-2Az}rFP|(+}bujN=5dCfllL@XNex?Z}U36Q-AR7O5^Gy z+?mm@1b6B25oJSg3m9 zMild*)AOC8jwTjNm7B#Z%@~`p_p(StiPChHi3NR!uAB2nKJDc?v*_&CT?fn@g}G`% zlc!`Tn<#uKJ+Z*R_1=vIXU+4^nK?E3H#MK0_T%Wb@BHT-?zi_ZIV!PG{PF$b7V{L( zNah{gdpB&^Bv`esXVdfAn12GtDrPagf7I{4JZP!Rt@aE20WV798$P_M6EKs|c+bGG zzGhv+_IdI_L4Jh}#oNAXeh^+!{ounTXTG=lE0|a9v8#B#+HXbHhwN9mVf%02V9md> z?clp-#R^_UYqURFgfncNvwr)U=hq*m1lgQRoB3gH>eoa*@9F&d$>k1g?bp48c~Y*t ztx!2`H}}!TOsTC+n^uW;>_6(qb?E={f@!f;s~^1%QD63HRmIn=A8nSua&8CSRP@!*%Y!T_y$w1_n=8 KKbLh*2~7ZftovC2 literal 0 HcmV?d00001 diff --git a/dev/benchmarks/complex_layout/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json b/dev/benchmarks/complex_layout/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json new file mode 100644 index 0000000000..0bedcf2fd4 --- /dev/null +++ b/dev/benchmarks/complex_layout/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "LaunchImage.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "LaunchImage@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "LaunchImage@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/dev/benchmarks/complex_layout/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png b/dev/benchmarks/complex_layout/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png new file mode 100644 index 0000000000000000000000000000000000000000..9da19eacad3b03bb08bbddbbf4ac48dd78b3d838 GIT binary patch literal 68 zcmeAS@N?(olHy`uVBq!ia0y~yU|@r242}Q* literal 0 HcmV?d00001 diff --git a/dev/benchmarks/complex_layout/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png b/dev/benchmarks/complex_layout/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..9da19eacad3b03bb08bbddbbf4ac48dd78b3d838 GIT binary patch literal 68 zcmeAS@N?(olHy`uVBq!ia0y~yU|@r242}Q* literal 0 HcmV?d00001 diff --git a/dev/benchmarks/complex_layout/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png b/dev/benchmarks/complex_layout/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..9da19eacad3b03bb08bbddbbf4ac48dd78b3d838 GIT binary patch literal 68 zcmeAS@N?(olHy`uVBq!ia0y~yU|@r242}Q* literal 0 HcmV?d00001 diff --git a/dev/benchmarks/complex_layout/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md b/dev/benchmarks/complex_layout/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md new file mode 100644 index 0000000000..89c2725b70 --- /dev/null +++ b/dev/benchmarks/complex_layout/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md @@ -0,0 +1,5 @@ +# Launch Screen Assets + +You can customize the launch screen with your own desired assets by replacing the image files in this directory. + +You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. \ No newline at end of file diff --git a/dev/benchmarks/complex_layout/ios/Runner/Runner-Bridging-Header.h b/dev/benchmarks/complex_layout/ios/Runner/Runner-Bridging-Header.h new file mode 100644 index 0000000000..95b7baf386 --- /dev/null +++ b/dev/benchmarks/complex_layout/ios/Runner/Runner-Bridging-Header.h @@ -0,0 +1,5 @@ +// 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 "GeneratedPluginRegistrant.h" diff --git a/dev/benchmarks/complex_layout/lib/main.dart b/dev/benchmarks/complex_layout/lib/main.dart index 4496bdd56a..69d6b133f7 100644 --- a/dev/benchmarks/complex_layout/lib/main.dart +++ b/dev/benchmarks/complex_layout/lib/main.dart @@ -109,6 +109,7 @@ class ComplexLayoutState extends State { Expanded( child: ListView.builder( key: const Key('complex-scroll'), // this key is used by the driver test + controller: ScrollController(), // So that the scroll offset can be tracked itemBuilder: (BuildContext context, int index) { if (index % 2 == 0) return FancyImageItem(index, key: PageStorageKey(index)); diff --git a/dev/benchmarks/complex_layout/pubspec.yaml b/dev/benchmarks/complex_layout/pubspec.yaml index 8d204706ea..8d52efdecc 100644 --- a/dev/benchmarks/complex_layout/pubspec.yaml +++ b/dev/benchmarks/complex_layout/pubspec.yaml @@ -3,7 +3,7 @@ description: A benchmark of a relatively complex layout. environment: # The pub client defaults to an <2.0.0 sdk constraint which we need to explicitly overwrite. - sdk: ">=2.0.0-dev.68.0 <3.0.0" + sdk: ">=2.2.2 <3.0.0" dependencies: flutter: @@ -46,6 +46,7 @@ dev_dependencies: flutter_test: sdk: flutter test: 1.16.0-nullsafety.1 + e2e: 0.7.0 _fe_analyzer_shared: 7.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" analyzer: 0.39.17 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" @@ -90,4 +91,4 @@ flutter: - packages/flutter_gallery_assets/people/square/ali.png - packages/flutter_gallery_assets/places/india_chettinad_silk_maker.png -# PUBSPEC CHECKSUM: 6832 +# PUBSPEC CHECKSUM: 047d diff --git a/dev/benchmarks/complex_layout/test/measure_scroll_smoothness.dart b/dev/benchmarks/complex_layout/test/measure_scroll_smoothness.dart new file mode 100644 index 0000000000..05c5107bfd --- /dev/null +++ b/dev/benchmarks/complex_layout/test/measure_scroll_smoothness.dart @@ -0,0 +1,296 @@ +// 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. + +// This test is a use case of flutter/flutter#60796 +// the test should be run as: +// flutter drive -t test/using_array.dart --driver test_driver/scrolling_test_e2e_test.dart + +import 'dart:ui' as ui; + +import 'package:flutter/gestures.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:e2e/e2e.dart'; + +import 'package:complex_layout/main.dart' as app; + +class PointerDataTestBinding extends E2EWidgetsFlutterBinding { + // PointerData injection would usually be considered device input and therefore + // blocked by [TestWidgetsFlutterBinding]. Override this behavior + // to help events go into widget tree. + @override + void dispatchEvent( + PointerEvent event, + HitTestResult hitTestResult, { + TestBindingEventSource source = TestBindingEventSource.device, + }) { + super.dispatchEvent(event, hitTestResult, source: TestBindingEventSource.test); + } +} + +/// A union of [ui.PointerDataPacket] and the time it should be sent. +class PointerDataRecord { + PointerDataRecord(this.timeStamp, List data) + : data = ui.PointerDataPacket(data: data); + final ui.PointerDataPacket data; + final Duration timeStamp; +} + +/// Generates the [PointerDataRecord] to simulate a drag operation from +/// `center - totalMove/2` to `center + totalMove/2`. +Iterable dragInputDatas( + final Duration epoch, + final Offset center, { + final Offset totalMove = const Offset(0, -400), + final Duration totalTime = const Duration(milliseconds: 2000), + final double frequency = 90, +}) sync* { + final Offset startLocation = (center - totalMove / 2) * ui.window.devicePixelRatio; + // The issue is about 120Hz input on 90Hz refresh rate device. + // We test 90Hz input on 60Hz device here, which shows similar pattern. + final int moveEventCount = totalTime.inMicroseconds * frequency ~/ const Duration(seconds: 1).inMicroseconds; + final Offset movePerEvent = totalMove / moveEventCount.toDouble() * ui.window.devicePixelRatio; + yield PointerDataRecord(epoch, [ + ui.PointerData( + timeStamp: epoch, + change: ui.PointerChange.add, + physicalX: startLocation.dx, + physicalY: startLocation.dy, + ), + ui.PointerData( + timeStamp: epoch, + change: ui.PointerChange.down, + physicalX: startLocation.dx, + physicalY: startLocation.dy, + pointerIdentifier: 1, + ), + ]); + for (int t = 0; t < moveEventCount + 1; t++) { + final Offset position = startLocation + movePerEvent * t.toDouble(); + yield PointerDataRecord( + epoch + totalTime * t ~/ moveEventCount, + [ui.PointerData( + timeStamp: epoch + totalTime * t ~/ moveEventCount, + change: ui.PointerChange.move, + physicalX: position.dx, + physicalY: position.dy, + // Scrolling behavior depends on this delta rather + // than the position difference. + physicalDeltaX: movePerEvent.dx, + physicalDeltaY: movePerEvent.dy, + pointerIdentifier: 1, + )], + ); + } + final Offset position = startLocation + totalMove; + yield PointerDataRecord(epoch + totalTime, [ui.PointerData( + timeStamp: epoch + totalTime, + change: ui.PointerChange.up, + physicalX: position.dx, + physicalY: position.dy, + pointerIdentifier: 1, + )]); +} + +enum TestScenario { + resampleOn90Hz, + resampleOn59Hz, + resampleOff90Hz, + resampleOff59Hz, +} + +class ResampleFlagVariant extends TestVariant { + ResampleFlagVariant(this.binding); + final E2EWidgetsFlutterBinding binding; + + @override + final Set values = Set.from(TestScenario.values); + + TestScenario currentValue; + bool get resample { + switch(currentValue) { + case TestScenario.resampleOn90Hz: + case TestScenario.resampleOn59Hz: + return true; + case TestScenario.resampleOff90Hz: + case TestScenario.resampleOff59Hz: + return false; + } + throw ArgumentError; + } + double get frequency { + switch(currentValue) { + case TestScenario.resampleOn90Hz: + case TestScenario.resampleOff90Hz: + return 90.0; + case TestScenario.resampleOn59Hz: + case TestScenario.resampleOff59Hz: + return 59.0; + } + throw ArgumentError; + } + + Map result; + + @override + String describeValue(TestScenario value) { + switch(value) { + case TestScenario.resampleOn90Hz: + return 'resample on with 90Hz input'; + case TestScenario.resampleOn59Hz: + return 'resample on with 59Hz input'; + case TestScenario.resampleOff90Hz: + return 'resample off with 90Hz input'; + case TestScenario.resampleOff59Hz: + return 'resample off with 59Hz input'; + } + throw ArgumentError; + } + + @override + Future setUp(TestScenario value) async { + currentValue = value; + final bool original = binding.resamplingEnabled; + binding.resamplingEnabled = resample; + return original; + } + + @override + Future tearDown(TestScenario value, bool memento) async { + binding.resamplingEnabled = memento; + binding.reportData[describeValue(value)] = result; + } +} + +Future main() async { + final PointerDataTestBinding binding = PointerDataTestBinding(); + assert(WidgetsBinding.instance == binding); + binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.benchmarkLive; + binding.reportData ??= {}; + final ResampleFlagVariant variant = ResampleFlagVariant(binding); + testWidgets('Smoothness test', (WidgetTester tester) async { + app.main(); + await tester.pumpAndSettle(); + final Finder scrollerFinder = find.byKey(const ValueKey('complex-scroll')); + final ListView scroller = tester.widget(scrollerFinder); + final ScrollController controller = scroller.controller; + final List frameTimestamp = []; + final List scrollOffset = []; + final List delays = []; + binding.addPersistentFrameCallback((Duration timeStamp) { + if (controller.hasClients) { + // This if is necessary because by the end of the test the widget tree + // is destroyed. + frameTimestamp.add(timeStamp.inMicroseconds); + scrollOffset.add(controller.offset); + } + }); + + Duration now() => binding.currentSystemFrameTimeStamp; + Future scroll() async { + // Extra 50ms to avoid timeouts. + final Duration startTime = const Duration(milliseconds: 500) + now(); + for (final PointerDataRecord record in dragInputDatas( + startTime, + tester.getCenter(scrollerFinder), + frequency: variant.frequency, + )) { + await tester.binding.delayed(record.timeStamp - now()); + // This now measures how accurate the above delayed is. + final Duration delay = now() - record.timeStamp; + if (delays.length < frameTimestamp.length) { + while (delays.length < frameTimestamp.length - 1) { + delays.add(Duration.zero); + } + delays.add(delay); + } else if (delays.last < delay) { + delays.last = delay; + } + ui.window.onPointerDataPacket(record.data); + } + } + + for (int n = 0; n < 5; n++) { + await scroll(); + } + variant.result = scrollSummary(scrollOffset, delays, frameTimestamp); + await tester.pumpAndSettle(); + scrollOffset.clear(); + delays.clear(); + await tester.idle(); + }, semanticsEnabled: false, variant: variant); +} + +/// Calculates the smoothness measure from `scrollOffset` and `delays` list. +/// +/// Smoothness (`abs_jerk`) is measured by the absolute value of the discrete +/// 2nd derivative of the scroll offset. +/// +/// It was experimented that jerk (3rd derivative of the position) is a good +/// measure the smoothness. +/// Here we are using 2nd derivative instead because the input is completely +/// linear and the expected acceleration should be strictly zero. +/// Observed acceleration is jumping from positive to negative within +/// adjacent frames, meaning mathematically the discrete 3-rd derivative +/// (`f[3] - 3*f[2] + 3*f[1] - f[0]`) is not a good approximation of jerk +/// (continuous 3-rd derivative), while discrete 2nd +/// derivative (`f[2] - 2*f[1] + f[0]`) on the other hand is a better measure +/// of how the scrolling deviate away from linear, and given the acceleration +/// should average to zero within two frames, it's also a good approximation +/// for jerk in terms of physics. +/// We use abs rather than square because square (2-norm) amplifies the +/// effect of the data point that's relatively large, but in this metric +/// we prefer smaller data point to have similar effect. +/// This is also why we count the number of data that's larger than a +/// threshold (and the result is tested not sensitive to this threshold), +/// which is effectively a 0-norm. +/// +/// Frames that are too slow to build (longer than 40ms) or with input delay +/// longer than 16ms (1/60Hz) is filtered out to separate the janky due to slow +/// response. +/// +/// The returned map has keys: +/// `average_abs_jerk`: average for the overall smoothness. +/// `janky_count`: number of frames with `abs_jerk` larger than 0.5. +/// `dropped_frame_count`: number of frames that are built longer than 40ms and +/// are not used for smoothness measurement. +/// `frame_timestamp`: the list of the timestamp for each frame, in the time +/// order. +/// `scroll_offset`: the scroll offset for each frame. Its length is the same as +/// `frame_timestamp`. +/// `input_delay`: the list of maximum delay time of the input simulation during +/// a frame. Its length is the same as `frame_timestamp` +Map scrollSummary( + List scrollOffset, + List delays, + List frameTimestamp, +) { + double jankyCount = 0; + double absJerkAvg = 0; + int lostFrame = 0; + for (int i = 1; i < scrollOffset.length-1; i += 1) { + if (frameTimestamp[i+1] - frameTimestamp[i-1] > 40E3 || + (i >= delays.length || delays[i] > const Duration(milliseconds: 16))) { + // filter data points from slow frame building or input simulation artifact + lostFrame += 1; + continue; + } + // + final double absJerk = (scrollOffset[i-1] + scrollOffset[i+1] - 2*scrollOffset[i]).abs(); + absJerkAvg += absJerk; + if (absJerk > 0.5) + jankyCount += 1; + } + // expect(lostFrame < 0.1 * frameTimestamp.length, true); + absJerkAvg /= frameTimestamp.length - lostFrame; + + return { + 'janky_count': jankyCount, + 'average_abs_jerk': absJerkAvg, + 'dropped_frame_count': lostFrame, + 'frame_timestamp': List.from(frameTimestamp), + 'scroll_offset': List.from(scrollOffset), + 'input_delay': delays.map((Duration data) => data.inMicroseconds).toList(), + }; +} diff --git a/dev/benchmarks/complex_layout/test_driver/measure_scroll_smoothness_test.dart b/dev/benchmarks/complex_layout/test_driver/measure_scroll_smoothness_test.dart new file mode 100644 index 0000000000..fd29ebe6a9 --- /dev/null +++ b/dev/benchmarks/complex_layout/test_driver/measure_scroll_smoothness_test.dart @@ -0,0 +1,17 @@ +// 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:e2e/e2e_driver.dart' as driver; + +Future main() => driver.e2eDriver( + timeout: const Duration(minutes: 5), + responseDataCallback: (Map data) async { + await driver.writeResponseData( + data, + testOutputFilename: 'scroll_smoothness_test', + ); + } +); diff --git a/dev/devicelab/bin/tasks/complex_layout_android__scroll_smoothness.dart b/dev/devicelab/bin/tasks/complex_layout_android__scroll_smoothness.dart new file mode 100644 index 0000000000..960965e2a7 --- /dev/null +++ b/dev/devicelab/bin/tasks/complex_layout_android__scroll_smoothness.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(createsScrollSmoothnessPerfTest()); +} diff --git a/dev/devicelab/lib/tasks/perf_tests.dart b/dev/devicelab/lib/tasks/perf_tests.dart index e26f4e1425..94193499e1 100644 --- a/dev/devicelab/lib/tasks/perf_tests.dart +++ b/dev/devicelab/lib/tasks/perf_tests.dart @@ -298,6 +298,54 @@ TaskFunction createsMultiWidgetConstructPerfE2ETest() { ).run; } +TaskFunction createsScrollSmoothnessPerfTest() { + final String testDirectory = + '${flutterDirectory.path}/dev/benchmarks/complex_layout'; + const String testTarget = 'test/measure_scroll_smoothness.dart'; + return () { + return inDirectory(testDirectory, () async { + final Device device = await devices.workingDevice; + await device.unlock(); + final String deviceId = device.deviceId; + await flutter('packages', options: ['get']); + + await flutter('drive', options: [ + '-v', + '--verbose-system-logs', + '--profile', + '-t', testTarget, + '-d', + deviceId, + ]); + final Map data = json.decode( + file('$testDirectory/build/scroll_smoothness_test.json').readAsStringSync(), + ) as Map; + + final Map result = {}; + void addResult(dynamic data, String suffix) { + assert(data is Map); + const List metricKeys = [ + 'janky_count', + 'average_abs_jerk', + 'dropped_frame_count', + ]; + for (final String key in metricKeys) { + result[key+suffix] = data[key]; + } + } + addResult(data['resample on with 90Hz input'], '_with_resampler_90Hz'); + addResult(data['resample on with 59Hz input'], '_with_resampler_59Hz'); + addResult(data['resample off with 90Hz input'], '_without_resampler_90Hz'); + addResult(data['resample off with 59Hz input'], '_without_resampler_59Hz'); + + return TaskResult.success( + result, + benchmarkScoreKeys: result.keys.toList(), + ); + }); + }; +} + TaskFunction createFramePolicyIntegrationTest() { final String testDirectory = '${flutterDirectory.path}/dev/benchmarks/macrobenchmarks'; diff --git a/dev/devicelab/manifest.yaml b/dev/devicelab/manifest.yaml index e045899ce2..fe54f5cce7 100644 --- a/dev/devicelab/manifest.yaml +++ b/dev/devicelab/manifest.yaml @@ -114,6 +114,14 @@ tasks: # Android on-device tests + complex_layout_android__scroll_smoothness: + description: > + Measures the smoothness of scrolling of the Complex Layout sample app on + Android. + stage: devicelab + required_agent_capabilities: ["linux/android"] + flaky: true + complex_layout_scroll_perf__timeline_summary: description: > Measures the runtime performance of the Complex Layout sample app on diff --git a/packages/flutter_test/lib/src/binding.dart b/packages/flutter_test/lib/src/binding.dart index fe65b2de26..dad55ba775 100644 --- a/packages/flutter_test/lib/src/binding.dart +++ b/packages/flutter_test/lib/src/binding.dart @@ -1504,7 +1504,6 @@ class LiveTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding { renderView._pointers[event.pointer].decay = _kPointerDecay; _handleViewNeedsPaint(); } else if (event.down) { - assert(event is PointerDownEvent); renderView._pointers[event.pointer] = _LiveTestPointerRecord( event.pointer, event.position,