From fc444aedab1290b510ca85fc4a906e185cd3eaa6 Mon Sep 17 00:00:00 2001 From: Flutter GitHub Bot Date: Thu, 8 Sep 2022 09:01:41 -0700 Subject: [PATCH 01/21] Roll pub packages (#110944) --- dev/benchmarks/multiple_flutters/module/pubspec.yaml | 6 +++--- dev/integration_tests/android_views/pubspec.yaml | 6 +++--- .../gradle_deprecated_settings/pubspec.yaml | 4 ++-- dev/integration_tests/hybrid_android_views/pubspec.yaml | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/dev/benchmarks/multiple_flutters/module/pubspec.yaml b/dev/benchmarks/multiple_flutters/module/pubspec.yaml index 303716c790191..861ff6adb79b6 100644 --- a/dev/benchmarks/multiple_flutters/module/pubspec.yaml +++ b/dev/benchmarks/multiple_flutters/module/pubspec.yaml @@ -31,7 +31,7 @@ dependencies: material_color_utilities: 0.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" meta: 1.8.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" path: 1.8.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - path_provider_windows: 2.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + path_provider_windows: 2.1.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" platform: 3.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" plugin_platform_interface: 2.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" process: 4.2.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" @@ -40,7 +40,7 @@ dependencies: term_glyph: 1.2.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" typed_data: 1.3.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" vector_math: 2.1.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - win32: 2.7.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + win32: 3.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" xdg_directories: 0.2.0+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" flutter: @@ -51,4 +51,4 @@ flutter: androidPackage: com.example.multiple_flutters_module iosBundleIdentifier: com.example.multipleFluttersModule -# PUBSPEC CHECKSUM: 8b9d +# PUBSPEC CHECKSUM: ca98 diff --git a/dev/integration_tests/android_views/pubspec.yaml b/dev/integration_tests/android_views/pubspec.yaml index 7fe09cfde25d1..0fd7dfba14380 100644 --- a/dev/integration_tests/android_views/pubspec.yaml +++ b/dev/integration_tests/android_views/pubspec.yaml @@ -33,7 +33,7 @@ dependencies: path_provider_linux: 2.1.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" path_provider_macos: 2.0.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" path_provider_platform_interface: 2.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - path_provider_windows: 2.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + path_provider_windows: 2.1.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" platform: 3.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" plugin_platform_interface: 2.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" process: 4.2.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" @@ -43,7 +43,7 @@ dependencies: vector_math: 2.1.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" vm_service: 9.3.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" webdriver: 3.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - win32: 2.7.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + win32: 3.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" xdg_directories: 0.2.0+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" dev_dependencies: @@ -92,4 +92,4 @@ dev_dependencies: flutter: uses-material-design: true -# PUBSPEC CHECKSUM: 5c78 +# PUBSPEC CHECKSUM: 0c73 diff --git a/dev/integration_tests/gradle_deprecated_settings/pubspec.yaml b/dev/integration_tests/gradle_deprecated_settings/pubspec.yaml index ea256a1c3e07b..e7bb9e969e708 100644 --- a/dev/integration_tests/gradle_deprecated_settings/pubspec.yaml +++ b/dev/integration_tests/gradle_deprecated_settings/pubspec.yaml @@ -9,7 +9,7 @@ dependencies: sdk: flutter camera: 0.10.0+1 - camera_android: 0.10.0+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + camera_android: 0.10.0+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" camera_avfoundation: 0.9.8+5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" camera_platform_interface: 2.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" camera_web: 0.3.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" @@ -31,4 +31,4 @@ dependencies: flutter: uses-material-design: true -# PUBSPEC CHECKSUM: cb9b +# PUBSPEC CHECKSUM: 919c diff --git a/dev/integration_tests/hybrid_android_views/pubspec.yaml b/dev/integration_tests/hybrid_android_views/pubspec.yaml index a39c97a6c7b20..6ea9e5e88c2f6 100644 --- a/dev/integration_tests/hybrid_android_views/pubspec.yaml +++ b/dev/integration_tests/hybrid_android_views/pubspec.yaml @@ -33,7 +33,7 @@ dependencies: path_provider_linux: 2.1.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" path_provider_macos: 2.0.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" path_provider_platform_interface: 2.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - path_provider_windows: 2.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + path_provider_windows: 2.1.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" platform: 3.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" plugin_platform_interface: 2.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" process: 4.2.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" @@ -43,7 +43,7 @@ dependencies: vector_math: 2.1.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" vm_service: 9.3.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" webdriver: 3.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - win32: 2.7.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + win32: 3.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" xdg_directories: 0.2.0+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" dev_dependencies: @@ -92,4 +92,4 @@ dev_dependencies: flutter: uses-material-design: true -# PUBSPEC CHECKSUM: 5c78 +# PUBSPEC CHECKSUM: 0c73 From eac2329ebf5725192487a62fec285cf294a3c6fb Mon Sep 17 00:00:00 2001 From: Alex Wallen Date: Thu, 8 Sep 2022 09:49:17 -0700 Subject: [PATCH 02/21] Re-land [macOS] Bring up "flutter_gallery" devicelab, start up test for x86. (#110379) --- .ci.yaml | 15 +++++++++++++++ TESTOWNERS | 1 + .../tasks/flutter_gallery_macos__start_up.dart | 12 ++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 dev/devicelab/bin/tasks/flutter_gallery_macos__start_up.dart diff --git a/.ci.yaml b/.ci.yaml index a44ca098bb190..eab3817be2480 100644 --- a/.ci.yaml +++ b/.ci.yaml @@ -2514,6 +2514,21 @@ targets: ["devicelab", "hostonly"] task_name: flutter_gallery_macos__compile + - name: Mac flutter_gallery_macos__start_up + bringup: true # New target https://github.com/flutter/flutter/issues/109633 + presubmit: false + recipe: devicelab/devicelab_drone + timeout: 60 + properties: + dependencies: >- + [ + {"dependency": "xcode", "version": "13f17a"}, + {"dependency": "gems", "version": "v3.3.14"} + ] + tags: > + ["devicelab", "hostonly"] + task_name: flutter_gallery_macos__start_up + - name: Mac framework_tests_libraries recipe: flutter/flutter_drone timeout: 60 diff --git a/TESTOWNERS b/TESTOWNERS index 7f2ef06434acc..8d39fdb63ede4 100644 --- a/TESTOWNERS +++ b/TESTOWNERS @@ -247,6 +247,7 @@ /dev/devicelab/bin/tasks/windows_startup_test.dart @loic-sharma @flutter/desktop /dev/devicelab/bin/tasks/complex_layout_macos__compile.dart @a-wallen @flutter/desktop /dev/devicelab/bin/tasks/flutter_gallery_macos__compile.dart @a-wallen @flutter/desktop +/dev/devicelab/bin/tasks/flutter_gallery_macos__start_up.dart @a-wallen @flutter/desktop ## Host only framework tests # Linux analyze diff --git a/dev/devicelab/bin/tasks/flutter_gallery_macos__start_up.dart b/dev/devicelab/bin/tasks/flutter_gallery_macos__start_up.dart new file mode 100644 index 0000000000000..cef65ffbcfc76 --- /dev/null +++ b/dev/devicelab/bin/tasks/flutter_gallery_macos__start_up.dart @@ -0,0 +1,12 @@ +// 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_devicelab/framework/devices.dart'; +import 'package:flutter_devicelab/framework/framework.dart'; +import 'package:flutter_devicelab/tasks/perf_tests.dart'; + +Future main() async { + deviceOperatingSystem = DeviceOperatingSystem.macos; + await task(createFlutterGalleryStartupTest()); +} From 5cd37788754de351b52bc5263bff040cea3ca4b0 Mon Sep 17 00:00:00 2001 From: engine-flutter-autoroll Date: Thu, 8 Sep 2022 12:53:06 -0400 Subject: [PATCH 03/21] Roll Plugins from c6b2f8a84439 to fd03cdeffa4e (26 revisions) (#111196) --- bin/internal/flutter_plugins.version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/internal/flutter_plugins.version b/bin/internal/flutter_plugins.version index cea1db002fcb7..c806ef404ace9 100644 --- a/bin/internal/flutter_plugins.version +++ b/bin/internal/flutter_plugins.version @@ -1 +1 @@ -c6b2f8a844394f522d634a253c050537ea0252ac +fd03cdeffa4e332d8fa97defcac4dd1e7b000af3 From dc6ab62696388e4ea8c778e7bcaeab3f1241ccd0 Mon Sep 17 00:00:00 2001 From: Hans Muller Date: Thu, 8 Sep 2022 10:20:32 -0700 Subject: [PATCH 04/21] Fixed one-frame InkWell overlay color problem on unhover (#111112) --- .../flutter/lib/src/material/ink_well.dart | 54 +++++++++++++------ .../flutter/test/material/ink_well_test.dart | 38 +++++++++++++ 2 files changed, 75 insertions(+), 17 deletions(-) diff --git a/packages/flutter/lib/src/material/ink_well.dart b/packages/flutter/lib/src/material/ink_well.dart index d343605e6a2db..50560379738ff 100644 --- a/packages/flutter/lib/src/material/ink_well.dart +++ b/packages/flutter/lib/src/material/ink_well.dart @@ -857,22 +857,6 @@ class _InkResponseState extends State<_InkResponseStateWidget> @override bool get wantKeepAlive => highlightsExist || (_splashes != null && _splashes!.isNotEmpty); - Color getHighlightColorForType(_HighlightType type) { - final ThemeData theme = Theme.of(context); - final Color? resolvedOverlayColor = widget.overlayColor?.resolve(statesController.value); - switch (type) { - // The pressed state triggers a ripple (ink splash), per the current - // Material Design spec. A separate highlight is no longer used. - // See https://material.io/design/interaction/states.html#pressed - case _HighlightType.pressed: - return resolvedOverlayColor ?? widget.highlightColor ?? theme.highlightColor; - case _HighlightType.focus: - return resolvedOverlayColor ?? widget.focusColor ?? theme.focusColor; - case _HighlightType.hover: - return resolvedOverlayColor ?? widget.hoverColor ?? theme.hoverColor; - } - } - Duration getFadeDurationForType(_HighlightType type) { switch (type) { case _HighlightType.pressed: @@ -911,13 +895,30 @@ class _InkResponseState extends State<_InkResponseStateWidget> if (value == (highlight != null && highlight.active)) { return; } + if (value) { if (highlight == null) { + Color? resolvedOverlayColor = widget.overlayColor?.resolve(statesController.value); + if (resolvedOverlayColor == null) { + // Use the backwards compatible defaults + final ThemeData theme = Theme.of(context); + switch (type) { + case _HighlightType.pressed: + resolvedOverlayColor = widget.highlightColor ?? theme.highlightColor; + break; + case _HighlightType.focus: + resolvedOverlayColor = widget.focusColor ?? theme.focusColor; + break; + case _HighlightType.hover: + resolvedOverlayColor = widget.hoverColor ?? theme.hoverColor; + break; + } + } final RenderBox referenceBox = context.findRenderObject()! as RenderBox; _highlights[type] = InkHighlight( controller: Material.of(context)!, referenceBox: referenceBox, - color: getHighlightColorForType(type), + color: resolvedOverlayColor, shape: widget.highlightShape, radius: widget.radius, borderRadius: widget.borderRadius, @@ -1159,6 +1160,25 @@ class _InkResponseState extends State<_InkResponseStateWidget> Widget build(BuildContext context) { assert(widget.debugCheckContext(context)); super.build(context); // See AutomaticKeepAliveClientMixin. + + Color getHighlightColorForType(_HighlightType type) { + const Set pressed = {MaterialState.pressed}; + const Set focused = {MaterialState.focused}; + const Set hovered = {MaterialState.hovered}; + + final ThemeData theme = Theme.of(context); + switch (type) { + // The pressed state triggers a ripple (ink splash), per the current + // Material Design spec. A separate highlight is no longer used. + // See https://material.io/design/interaction/states.html#pressed + case _HighlightType.pressed: + return widget.overlayColor?.resolve(pressed) ?? widget.highlightColor ?? theme.highlightColor; + case _HighlightType.focus: + return widget.overlayColor?.resolve(focused) ?? widget.focusColor ?? theme.focusColor; + case _HighlightType.hover: + return widget.overlayColor?.resolve(hovered) ?? widget.hoverColor ?? theme.hoverColor; + } + } for (final _HighlightType type in _highlights.keys) { _highlights[type]?.color = getHighlightColorForType(type); } diff --git a/packages/flutter/test/material/ink_well_test.dart b/packages/flutter/test/material/ink_well_test.dart index 113d72e060c58..9f3cd2ba23b38 100644 --- a/packages/flutter/test/material/ink_well_test.dart +++ b/packages/flutter/test/material/ink_well_test.dart @@ -1556,4 +1556,42 @@ void main() { expect(tapCount, 3); expect(pressedCount, 2); }); + + testWidgets('ink well overlayColor opacity fades from 0xff when hover ends', (WidgetTester tester) async { + // Regression test for https://github.com/flutter/flutter/issues/110266 + await tester.pumpWidget(Material( + child: Directionality( + textDirection: TextDirection.ltr, + child: Center( + child: SizedBox( + width: 100, + height: 100, + child: InkWell( + overlayColor: MaterialStateProperty.resolveWith((Set states) { + if (states.contains(MaterialState.hovered)) { + return const Color(0xff00ff00); + } + return null; + }), + onTap: () { }, + onLongPress: () { }, + onHover: (bool hover) { }, + ), + ), + ), + ), + )); + final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); + await gesture.addPointer(); + await gesture.moveTo(tester.getCenter(find.byType(SizedBox))); + await tester.pumpAndSettle(); + await gesture.moveTo(const Offset(10, 10)); // fade out the overlay + await tester.pump(); // trigger the fade out animation + final RenderObject inkFeatures = tester.allRenderObjects.firstWhere((RenderObject object) => object.runtimeType.toString() == '_RenderInkFeatures'); + // Fadeout begins with the MaterialStates.hovered overlay color + expect(inkFeatures, paints..rect(rect: const Rect.fromLTRB(350.0, 250.0, 450.0, 350.0), color: const Color(0xff00ff00))); + // 50ms fadeout is 50% complete, overlay color alpha goes from 0xff to 0x80 + await tester.pump(const Duration(milliseconds: 25)); + expect(inkFeatures, paints..rect(rect: const Rect.fromLTRB(350.0, 250.0, 450.0, 350.0), color: const Color(0x8000ff00))); + }); } From 5f2d730f1f5a1e96be4ee46a58ece8460f85ff29 Mon Sep 17 00:00:00 2001 From: Kate Lovett Date: Thu, 8 Sep 2022 12:43:54 -0500 Subject: [PATCH 05/21] Revert Ballistic & Clamping simulation updates (#111201) --- dev/tools/generate_android_spline_data.dart | 61 ----- .../src/animation/animation_controller.dart | 9 - .../lib/src/widgets/nested_scroll_view.dart | 12 - .../lib/src/widgets/scroll_activity.dart | 32 +-- .../scroll_position_with_single_context.dart | 24 -- .../lib/src/widgets/scroll_simulation.dart | 209 ++++-------------- .../test/widgets/scroll_activity_test.dart | 114 ---------- .../test/widgets/scroll_simulation_test.dart | 17 -- .../test/widgets/scrollable_fling_test.dart | 4 +- .../widgets/scrollable_semantics_test.dart | 6 +- .../flutter/test/widgets/scrollable_test.dart | 16 +- .../slivers_appbar_floating_pinned_test.dart | 2 +- 12 files changed, 58 insertions(+), 448 deletions(-) delete mode 100644 dev/tools/generate_android_spline_data.dart diff --git a/dev/tools/generate_android_spline_data.dart b/dev/tools/generate_android_spline_data.dart deleted file mode 100644 index 12e79d5866096..0000000000000 --- a/dev/tools/generate_android_spline_data.dart +++ /dev/null @@ -1,61 +0,0 @@ -// 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. - -const int _nbSamples = 100; -final List _splinePosition = List.filled(_nbSamples + 1, 0.0); -final List _splineTime = List.filled(_nbSamples + 1, 0.0); -const double _startTension = 0.5; -const double _endTension = 1.0; -const double _inflexion = 0.35; - -// Generate the spline data used in ClampingScrollSimulation. -// -// This logic is a translation of the 2-dimensional logic found in -// https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/widget/Scroller.java. -// -// The output of this program should be copied over to [_splinePosition] in -// flutter/packages/flutter/lib/src/widgets/scroll_simulation.dart. -void main() { - const double p1 = _startTension * _inflexion; - const double p2 = 1.0 - _endTension * (1.0 - _inflexion); - double xMin = 0.0; - double yMin = 0.0; - for (int i = 0; i < _nbSamples; i++) { - final double alpha = i / _nbSamples; - double xMax = 1.0; - double x, tx, coef; - while (true) { - x = xMin + (xMax - xMin) / 2.0; - coef = 3.0 * x * (1.0 - x); - tx = coef * ((1.0 - x) * p1 + x * p2) + x * x * x; - if ((tx - alpha).abs() < 1e-5) { - break; - } - if (tx > alpha) { - xMax = x; - } else { - xMin = x; - } - } - _splinePosition[i] = coef * ((1.0 - x) * _startTension + x) + x * x * x; - double yMax = 1.0; - double y, dy; - while (true) { - y = yMin + (yMax - yMin) / 2.0; - coef = 3.0 * y * (1.0 - y); - dy = coef * ((1.0 - y) * _startTension + y) + y * y * y; - if ((dy - alpha).abs() < 1e-5) { - break; - } - if (dy > alpha) { - yMax = y; - } else { - yMin = y; - } - } - _splineTime[i] = coef * ((1.0 - y) * p1 + y * p2) + y * y * y; - } - _splinePosition[_nbSamples] = _splineTime[_nbSamples] = 1.0; - print(_splinePosition); -} diff --git a/packages/flutter/lib/src/animation/animation_controller.dart b/packages/flutter/lib/src/animation/animation_controller.dart index 25b5c04194466..da359a0780e23 100644 --- a/packages/flutter/lib/src/animation/animation_controller.dart +++ b/packages/flutter/lib/src/animation/animation_controller.dart @@ -757,15 +757,6 @@ class AnimationController extends Animation return result; } - /// Update the simulation without restarting the animation. - /// - /// The current simulation will be replaced with the provided [Simulation]. - /// It is only valid to call this when an animation is currently underway. - void updateSimulation(Simulation simulation) { - assert(isAnimating); - _simulation = simulation; - } - /// Stops running this animation. /// /// This does not trigger any notifications. The animation stops in its diff --git a/packages/flutter/lib/src/widgets/nested_scroll_view.dart b/packages/flutter/lib/src/widgets/nested_scroll_view.dart index 46f5277a5133f..93f302980d721 100644 --- a/packages/flutter/lib/src/widgets/nested_scroll_view.dart +++ b/packages/flutter/lib/src/widgets/nested_scroll_view.dart @@ -686,12 +686,6 @@ class _NestedScrollCoordinator implements ScrollActivityDelegate, ScrollHoldCont ); } - // TODO(Piinks): https://github.com/flutter/flutter/issues/100748 - @override - Simulation? updateBallisticAnimation(double initVelocity, double initPosition) { - return null; - } - ScrollActivity createOuterBallisticScrollActivity(double velocity) { // This function creates a ballistic scroll for the outer scrollable. // @@ -1367,12 +1361,6 @@ class _NestedScrollPosition extends ScrollPosition implements ScrollActivityDele )); } - // TODO(Piinks): see https://github.com/flutter/flutter/issues/100748 - @override - Simulation? updateBallisticAnimation(double initVelocity, double initPosition) { - return null; - } - ScrollActivity createBallisticScrollActivity( Simulation? simulation, { required _NestedBallisticScrollActivityMode mode, diff --git a/packages/flutter/lib/src/widgets/scroll_activity.dart b/packages/flutter/lib/src/widgets/scroll_activity.dart index 96f63798dea10..b8b7b1fbee23b 100644 --- a/packages/flutter/lib/src/widgets/scroll_activity.dart +++ b/packages/flutter/lib/src/widgets/scroll_activity.dart @@ -47,16 +47,6 @@ abstract class ScrollActivityDelegate { /// Terminate the current activity and start a ballistic activity with the /// given velocity. void goBallistic(double velocity); - - /// Update the ballistic animation instead of restarting it, for example as - /// the result of a layout change after a flinging gesture. - /// - /// The [initVelocity] and [initPosition] refer to the starting values of the - /// new ballistic animation. - /// - /// Can return null if the current [ScrollPhysics.createBallisticSimulation] - /// returns null, which will trigger an [IdleScrollActivity] instead. - Simulation? updateBallisticAnimation(double initVelocity, double initPosition); } /// Base class for scrolling activities like dragging and flinging. @@ -534,17 +524,13 @@ class DragScrollActivity extends ScrollActivity { class BallisticScrollActivity extends ScrollActivity { /// Creates an activity that animates a scroll view based on a [simulation]. /// - /// The [delegate], [simulation], and [vsync] arguments must not be null. The - /// [initVelocity] and [initPosition] arguments allow the ballistic activity - /// to update the simulation instead of restarting it. + /// The [delegate], [simulation], and [vsync] arguments must not be null. BallisticScrollActivity( super.delegate, Simulation simulation, TickerProvider vsync, - this.shouldIgnorePointer, { - double initVelocity = 0.0, - double initPosition = 0.0, - }) : _initVelocity = initVelocity, _initPosition = initPosition { + this.shouldIgnorePointer, + ) { _controller = AnimationController.unbounded( debugLabel: kDebugMode ? objectRuntimeType(this, 'BallisticScrollActivity') : null, vsync: vsync, @@ -556,10 +542,6 @@ class BallisticScrollActivity extends ScrollActivity { late AnimationController _controller; - final double _initVelocity; - - final double _initPosition; - @override void resetActivity() { delegate.goBallistic(velocity); @@ -567,13 +549,7 @@ class BallisticScrollActivity extends ScrollActivity { @override void applyNewDimensions() { - final Simulation? newSimulation = delegate.updateBallisticAnimation( - _initVelocity, - _initPosition, - ); - if (newSimulation != null) { - _controller.updateSimulation(newSimulation); - } + delegate.goBallistic(velocity); } void _tick() { diff --git a/packages/flutter/lib/src/widgets/scroll_position_with_single_context.dart b/packages/flutter/lib/src/widgets/scroll_position_with_single_context.dart index 68b838a6c234e..c1a1666ec6050 100644 --- a/packages/flutter/lib/src/widgets/scroll_position_with_single_context.dart +++ b/packages/flutter/lib/src/widgets/scroll_position_with_single_context.dart @@ -12,7 +12,6 @@ import 'basic.dart'; import 'framework.dart'; import 'scroll_activity.dart'; import 'scroll_context.dart'; -import 'scroll_metrics.dart'; import 'scroll_notification.dart'; import 'scroll_physics.dart'; import 'scroll_position.dart'; @@ -147,35 +146,12 @@ class ScrollPositionWithSingleContext extends ScrollPosition implements ScrollAc simulation, context.vsync, activity?.shouldIgnorePointer ?? true, - initVelocity: velocity, - initPosition: pixels, )); } else { goIdle(); } } - @override - Simulation? updateBallisticAnimation(double initVelocity, double initPosition) { - assert(hasPixels); - final FixedScrollMetrics initScrollMetrics = FixedScrollMetrics( - minScrollExtent: minScrollExtent, - maxScrollExtent: maxScrollExtent, - pixels: initPosition, - viewportDimension: viewportDimension, - axisDirection: axisDirection, - ); - final Simulation? simulation = physics.createBallisticSimulation( - initScrollMetrics, - initVelocity, - ); - if (simulation == null) { - goIdle(); - return null; - } - return simulation; - } - @override ScrollDirection get userScrollDirection => _userScrollDirection; ScrollDirection _userScrollDirection = ScrollDirection.idle; diff --git a/packages/flutter/lib/src/widgets/scroll_simulation.dart b/packages/flutter/lib/src/widgets/scroll_simulation.dart index 2d54d6ffa3004..eb12592b79e78 100644 --- a/packages/flutter/lib/src/widgets/scroll_simulation.dart +++ b/packages/flutter/lib/src/widgets/scroll_simulation.dart @@ -146,13 +146,11 @@ class ClampingScrollSimulation extends Simulation { required this.velocity, this.friction = 0.015, super.tolerance, - }) { - _duration = _splineFlingDuration(velocity); - _distance = _splineFlingDistance(velocity); + }) : assert(_flingVelocityPenetration(0.0) == _initialVelocityPenetration) { + _duration = _flingDuration(velocity); + _distance = (velocity * _duration / _initialVelocityPenetration).abs(); } - final double _inflexion = 0.35; - /// The position of the particle at the beginning of the simulation. final double position; @@ -165,7 +163,7 @@ class ClampingScrollSimulation extends Simulation { /// The more friction the particle experiences, the sooner it stops. final double friction; - late int _duration; + late double _duration; late double _distance; // See DECELERATION_RATE. @@ -173,186 +171,59 @@ class ClampingScrollSimulation extends Simulation { // See computeDeceleration(). static double _decelerationForFriction(double friction) { - return 9.80665 * - 39.37 * - friction * - 1.0 * // Flutter operates on logical pixels so the DPI should be 1.0. - 160.0; + return friction * 61774.04968; } - // See getSplineDeceleration(). - double _splineDeceleration(double velocity) { - return math.log(_inflexion * - velocity.abs() / - (friction * _decelerationForFriction(0.84))); + // See getSplineFlingDuration(). Returns a value in seconds. + double _flingDuration(double velocity) { + // See mPhysicalCoeff + final double scaledFriction = friction * _decelerationForFriction(0.84); + + // See getSplineDeceleration(). + final double deceleration = math.log(0.35 * velocity.abs() / scaledFriction); + + return math.exp(deceleration / (_kDecelerationRate - 1.0)); } - // See getSplineFlingDuration(). - int _splineFlingDuration(double velocity) { - final double deceleration = _splineDeceleration(velocity); - return (1000 * math.exp(deceleration / (_kDecelerationRate - 1.0))).round(); + // Based on a cubic curve fit to the Scroller.computeScrollOffset() values + // produced for an initial velocity of 4000. The value of Scroller.getDuration() + // and Scroller.getFinalY() were 686ms and 961 pixels respectively. + // + // Algebra courtesy of Wolfram Alpha. + // + // f(x) = scrollOffset, x is time in milliseconds + // f(x) = 3.60882×10^-6 x^3 - 0.00668009 x^2 + 4.29427 x - 3.15307 + // f(x) = 3.60882×10^-6 x^3 - 0.00668009 x^2 + 4.29427 x, so f(0) is 0 + // f(686ms) = 961 pixels + // Scale to f(0 <= t <= 1.0), x = t * 686 + // f(t) = 1165.03 t^3 - 3143.62 t^2 + 2945.87 t + // Scale f(t) so that 0.0 <= f(t) <= 1.0 + // f(t) = (1165.03 t^3 - 3143.62 t^2 + 2945.87 t) / 961.0 + // = 1.2 t^3 - 3.27 t^2 + 3.065 t + static const double _initialVelocityPenetration = 3.065; + static double _flingDistancePenetration(double t) { + return (1.2 * t * t * t) - (3.27 * t * t) + (_initialVelocityPenetration * t); } - // See getSplineFlingDistance(). - double _splineFlingDistance(double velocity) { - final double l = _splineDeceleration(velocity); - final double decelMinusOne = _kDecelerationRate - 1.0; - return friction * - _decelerationForFriction(0.84) * - math.exp(_kDecelerationRate / decelMinusOne * l); + // The derivative of the _flingDistancePenetration() function. + static double _flingVelocityPenetration(double t) { + return (3.6 * t * t) - (6.54 * t) + _initialVelocityPenetration; } @override double x(double time) { - if (time == 0) { - return position; - } - final _NBSample sample = _NBSample(time, _duration); - return position + (sample.distanceCoef * _distance) * velocity.sign; + final double t = clampDouble(time / _duration, 0.0, 1.0); + return position + _distance * _flingDistancePenetration(t) * velocity.sign; } @override double dx(double time) { - if (time == 0) { - return velocity; - } - final _NBSample sample = _NBSample(time, _duration); - return sample.velocityCoef * _distance / _duration * velocity.sign * 1000.0; + final double t = clampDouble(time / _duration, 0.0, 1.0); + return _distance * _flingVelocityPenetration(t) * velocity.sign / _duration; } @override bool isDone(double time) { - return time * 1000.0 >= _duration; + return time >= _duration; } } - -class _NBSample { - _NBSample(double time, int duration) { - // See computeScrollOffset(). - final double t = time * 1000.0 / duration; - final int index = (_nbSamples * t).clamp(0, _nbSamples).round(); // ignore_clamp_double_lint - _distanceCoef = 1.0; - _velocityCoef = 0.0; - if (index < _nbSamples) { - final double tInf = index / _nbSamples; - final double tSup = (index + 1) / _nbSamples; - final double dInf = _splinePosition[index]; - final double dSup = _splinePosition[index + 1]; - _velocityCoef = (dSup - dInf) / (tSup - tInf); - _distanceCoef = dInf + (t - tInf) * _velocityCoef; - } - } - - late double _velocityCoef; - double get velocityCoef => _velocityCoef; - - late double _distanceCoef; - double get distanceCoef => _distanceCoef; - - static const int _nbSamples = 100; - - // Generated from dev/tools/generate_android_spline_data.dart. - static const List _splinePosition = [ - 0.000022888183591973643, - 0.028561000304762274, - 0.05705195792956655, - 0.08538917797618413, - 0.11349556286812107, - 0.14129881694635613, - 0.16877157254923383, - 0.19581093511175632, - 0.22239649722992452, - 0.24843841866631658, - 0.2740024733220569, - 0.298967680744136, - 0.32333234658228116, - 0.34709556909569184, - 0.3702249257894571, - 0.39272483400399893, - 0.41456988647721615, - 0.43582889025419114, - 0.4564192786416, - 0.476410299013587, - 0.4957560715637827, - 0.5145493169954743, - 0.5327205670880077, - 0.5502846891191615, - 0.5673274324802855, - 0.583810881323224, - 0.5997478744397482, - 0.615194045299478, - 0.6301165005270208, - 0.6445484042257972, - 0.6585198219185201, - 0.6720397744233084, - 0.6850997688076114, - 0.6977281404741683, - 0.7099506591298411, - 0.7217749311525871, - 0.7331784038850426, - 0.7442308394229518, - 0.7549087205105974, - 0.7652471277371271, - 0.7752251637549381, - 0.7848768260203478, - 0.7942056937103814, - 0.8032299679689082, - 0.8119428702388629, - 0.8203713516576219, - 0.8285187880808974, - 0.8363794492831295, - 0.8439768562813565, - 0.851322799855549, - 0.8584111051351724, - 0.8652534074722162, - 0.8718525580962131, - 0.8782333271742155, - 0.8843892099362031, - 0.8903155590440985, - 0.8960465359221951, - 0.9015574505919048, - 0.9068736766459904, - 0.9119951682409297, - 0.9169321898723632, - 0.9216747065581234, - 0.9262420604674766, - 0.9306331858366086, - 0.9348476990715433, - 0.9389007110754832, - 0.9427903495057521, - 0.9465220679845756, - 0.9500943036519721, - 0.9535176728088761, - 0.9567898524767604, - 0.959924306623116, - 0.9629127700159108, - 0.9657622101750765, - 0.9684818726275105, - 0.9710676079044347, - 0.9735231939498, - 0.9758514437576309, - 0.9780599066560445, - 0.9801485715370128, - 0.9821149805689633, - 0.9839677526782791, - 0.9857085499421516, - 0.9873347811966005, - 0.9888547171706613, - 0.9902689443512227, - 0.9915771042095881, - 0.9927840651641069, - 0.9938913963715834, - 0.9948987305580712, - 0.9958114963810524, - 0.9966274782266875, - 0.997352148697352, - 0.9979848677523623, - 0.9985285021374979, - 0.9989844084453229, - 0.9993537595844986, - 0.999638729860106, - 0.9998403888004533, - 0.9999602810470701, - 1.0 - ]; -} diff --git a/packages/flutter/test/widgets/scroll_activity_test.dart b/packages/flutter/test/widgets/scroll_activity_test.dart index 673e4af274b81..f6dd3235d0f9e 100644 --- a/packages/flutter/test/widgets/scroll_activity_test.dart +++ b/packages/flutter/test/widgets/scroll_activity_test.dart @@ -129,64 +129,6 @@ void main() { expect(find.text('Page 9'), findsOneWidget); }); - List childrenSizeIncrease(int n) { - return List.generate(n, (int i) { - return SizedBox(height: 40.0 + i * 3, child: Text('$i')); - }); - } - - testWidgets('Check for duplicate pixels with ClampingScrollPhysics', (WidgetTester tester) async { - final List scrollSimulationXList = []; - final TestScrollPhysics testScrollPhysics = TestScrollPhysics( - scrollSimulationXList, - parent: const ClampingScrollPhysics(), - ); - await tester.pumpWidget( - MaterialApp( - home: ListView( - physics: testScrollPhysics, - children: childrenSizeIncrease(100), - ), - ), - ); - await tester.fling(find.byType(ListView), const Offset(0.0, -4000.0), 4000.0); - await tester.pumpAndSettle(); - final Set checkSet = {}; - checkSet.addAll(scrollSimulationXList); - /// checkSet.length + 1 is because: - /// simulation.x(0.0) will be called in _startSimulation. - /// The first frame of the animation will also call simulation.x(0.0). - /// It can be tolerated that it has at most one duplicate value. - final bool hasOnlyOneDuplicate = scrollSimulationXList.length == checkSet.length + 1; - expect(true, hasOnlyOneDuplicate); // and ends up at the end - }); - - testWidgets('Check for duplicate pixels with BouncingScrollPhysics', (WidgetTester tester) async { - final List scrollSimulationXList = []; - final TestScrollPhysics testScrollPhysics = TestScrollPhysics( - scrollSimulationXList, - parent: const BouncingScrollPhysics(), - ); - await tester.pumpWidget( - MaterialApp( - home: ListView( - physics: testScrollPhysics, - children: childrenSizeIncrease(100), - ), - ), - ); - await tester.fling(find.byType(ListView), const Offset(0.0, -4000.0), 4000.0); - await tester.pumpAndSettle(); - final Set checkSet = {}; - checkSet.addAll(scrollSimulationXList); - /// checkSet.length + 1 is because: - /// simulation.x(0.0) will be call in _startSimulation. - /// The first frame of the animation will also call simulation.x(0.0). - /// It can be tolerated that it has at most one duplicate value. - final bool noDuplicate = scrollSimulationXList.length == checkSet.length + 1; - expect(true, noDuplicate); // and ends up at the end - }); - testWidgets('Pointer is not ignored during trackpad scrolling.', (WidgetTester tester) async { final ScrollController controller = ScrollController(); int? lastTapped; @@ -268,62 +210,6 @@ void main() { }); } -class TestScrollPhysics extends ScrollPhysics { - const TestScrollPhysics(this.scrollSimulationXList, { super.parent }); - - final List scrollSimulationXList; - - @override - Simulation? createBallisticSimulation( - ScrollMetrics position, - double velocity, - ) { - final Simulation? scrollSimulation = super.createBallisticSimulation( - position, - velocity, - ); - if (scrollSimulation != null && scrollSimulationXList != null) { - return TestScrollScrollSimulation( - scrollSimulation, - scrollSimulationXList, - ); - } - return scrollSimulation; - } - - @override - TestScrollPhysics applyTo(ScrollPhysics? ancestor) { - return TestScrollPhysics( - scrollSimulationXList, - parent: buildParent(ancestor), - ); - } -} - -class TestScrollScrollSimulation extends Simulation { - TestScrollScrollSimulation(this.innerScrollSimulation, - this.scrollSimulationXList,); - - final Simulation innerScrollSimulation; - - final List scrollSimulationXList; - - @override - double dx(double time) => innerScrollSimulation.dx(time); - - @override - bool isDone(double time) => innerScrollSimulation.isDone(time); - - @override - double x(double time) { - final double simulationX = innerScrollSimulation.x(time); - if (scrollSimulationXList != null) { - scrollSimulationXList.add(simulationX); - } - return simulationX; - } -} - class PageView62209 extends StatefulWidget { const PageView62209({super.key}); diff --git a/packages/flutter/test/widgets/scroll_simulation_test.dart b/packages/flutter/test/widgets/scroll_simulation_test.dart index 99738be6e84ae..69958f91e31ec 100644 --- a/packages/flutter/test/widgets/scroll_simulation_test.dart +++ b/packages/flutter/test/widgets/scroll_simulation_test.dart @@ -23,21 +23,4 @@ void main() { checkInitialConditions(75.0, 614.2093); checkInitialConditions(5469.0, 182.114534); }); - - test('ClampingScrollSimulation velocity eventually reaches zero', () { - void checkFinalConditions(double position, double velocity) { - final ClampingScrollSimulation simulation = ClampingScrollSimulation(position: position, velocity: velocity); - expect(simulation.dx(10.0), equals(0.0)); - } - - checkFinalConditions(51.0, 2000.0); - checkFinalConditions(584.0, 2617.294734); - checkFinalConditions(345.0, 1982.785934); - checkFinalConditions(0.0, 1831.366634); - checkFinalConditions(-156.2, 1541.57665); - checkFinalConditions(4.0, 1139.250439); - checkFinalConditions(4534.0, 1073.553798); - checkFinalConditions(75.0, 614.2093); - checkFinalConditions(5469.0, 182.114534); - }); } diff --git a/packages/flutter/test/widgets/scrollable_fling_test.dart b/packages/flutter/test/widgets/scrollable_fling_test.dart index bb20ccad067d2..1d34b11fe0ba2 100644 --- a/packages/flutter/test/widgets/scrollable_fling_test.dart +++ b/packages/flutter/test/widgets/scrollable_fling_test.dart @@ -48,7 +48,7 @@ void main() { // Before changing these values, ensure the fling results in a distance that // makes sense. See issue for more context. expect(androidResult, greaterThan(394.0)); - expect(androidResult, lessThan(408.2)); + expect(androidResult, lessThan(395.0)); await pumpTest(tester, TargetPlatform.linux); await tester.fling(find.byType(ListView), const Offset(0.0, -dragOffset), 1000.0); @@ -152,6 +152,6 @@ void main() { expect(log, equals(['tap 21'])); await tester.tap(find.byType(Scrollable)); await tester.pump(const Duration(milliseconds: 50)); - expect(log, equals(['tap 21', 'tap 49'])); + expect(log, equals(['tap 21', 'tap 48'])); }); } diff --git a/packages/flutter/test/widgets/scrollable_semantics_test.dart b/packages/flutter/test/widgets/scrollable_semantics_test.dart index 5307fc7a6d73e..1c8f7ea44dde2 100644 --- a/packages/flutter/test/widgets/scrollable_semantics_test.dart +++ b/packages/flutter/test/widgets/scrollable_semantics_test.dart @@ -231,7 +231,7 @@ void main() { expect(semantics, includesNodeWith( scrollExtentMin: 0.0, - scrollPosition: 394.3, + scrollPosition: 380.2, scrollExtentMax: 520.0, actions: [ SemanticsAction.scrollUp, @@ -280,7 +280,7 @@ void main() { expect(semantics, includesNodeWith( scrollExtentMin: 0.0, - scrollPosition: 394.3, + scrollPosition: 380.2, scrollExtentMax: double.infinity, actions: [ SemanticsAction.scrollUp, @@ -292,7 +292,7 @@ void main() { expect(semantics, includesNodeWith( scrollExtentMin: 0.0, - scrollPosition: 788.6, + scrollPosition: 760.4, scrollExtentMax: double.infinity, actions: [ SemanticsAction.scrollUp, diff --git a/packages/flutter/test/widgets/scrollable_test.dart b/packages/flutter/test/widgets/scrollable_test.dart index 1a276518c936f..6cdea4f8817b1 100644 --- a/packages/flutter/test/widgets/scrollable_test.dart +++ b/packages/flutter/test/widgets/scrollable_test.dart @@ -946,8 +946,8 @@ void main() { expect(find.byKey(const ValueKey('Box 0')), findsNothing); expect(find.byKey(const ValueKey('Box 52')), findsOneWidget); - expect(expensiveWidgets, 40); - expect(cheapWidgets, 21); + expect(expensiveWidgets, 38); + expect(cheapWidgets, 20); }); testWidgets('Can recommendDeferredLoadingForContext - override heuristic', (WidgetTester tester) async { @@ -989,9 +989,9 @@ void main() { expect(find.byKey(const ValueKey('Box 0')), findsNothing); expect(find.byKey(const ValueKey('Cheap box 52')), findsOneWidget); - expect(expensiveWidgets, 17); - expect(cheapWidgets, 44); - expect(physics.count, 44 + 17); + expect(expensiveWidgets, 18); + expect(cheapWidgets, 40); + expect(physics.count, 40 + 18); }); testWidgets('Can recommendDeferredLoadingForContext - override heuristic and always return true', (WidgetTester tester) async { @@ -1032,7 +1032,7 @@ void main() { expect(find.byKey(const ValueKey('Cheap box 52')), findsOneWidget); expect(expensiveWidgets, 0); - expect(cheapWidgets, 61); + expect(cheapWidgets, 58); }); testWidgets('ensureVisible does not move PageViews', (WidgetTester tester) async { @@ -1439,9 +1439,9 @@ void main() { await tester.sendEventToBinding(testPointer.hover(tester.getCenter(find.byType(Scrollable)))); await tester.sendEventToBinding(testPointer.scrollInertiaCancel()); // Cancel partway through. await tester.pump(); - expect(getScrollOffset(tester), closeTo(342.5439, 0.0001)); + expect(getScrollOffset(tester), closeTo(333.2944, 0.0001)); await tester.pump(const Duration(milliseconds: 4800)); - expect(getScrollOffset(tester), closeTo(342.5439, 0.0001)); + expect(getScrollOffset(tester), closeTo(333.2944, 0.0001)); }); } diff --git a/packages/flutter/test/widgets/slivers_appbar_floating_pinned_test.dart b/packages/flutter/test/widgets/slivers_appbar_floating_pinned_test.dart index 7ce68427447e8..5306450e898ad 100644 --- a/packages/flutter/test/widgets/slivers_appbar_floating_pinned_test.dart +++ b/packages/flutter/test/widgets/slivers_appbar_floating_pinned_test.dart @@ -151,7 +151,7 @@ void main() { ); expect(semantics, hasSemantics(expectedSemantics, ignoreTransform: true, ignoreId: true, ignoreRect: true)); - await tester.fling(find.text('Tile 2'), const Offset(0, -600), 1950); + await tester.fling(find.text('Tile 2'), const Offset(0, -600), 2000); await tester.pumpAndSettle(); expectedSemantics = TestSemantics.root( From 7e1e840999a10c3607f13d16db99bca180a4107a Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Thu, 8 Sep 2022 11:33:23 -0700 Subject: [PATCH 06/21] [framework] revert removal of opacity (#111202) --- packages/flutter/lib/src/rendering/proxy_box.dart | 9 ++------- packages/flutter/test/rendering/proxy_box_test.dart | 8 ++++---- packages/flutter/test/rendering/proxy_sliver_test.dart | 5 +++-- .../test/widgets/animated_opacity_repaint_test.dart | 6 +++--- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/packages/flutter/lib/src/rendering/proxy_box.dart b/packages/flutter/lib/src/rendering/proxy_box.dart index 32b699003f8ab..cea9b3e107601 100644 --- a/packages/flutter/lib/src/rendering/proxy_box.dart +++ b/packages/flutter/lib/src/rendering/proxy_box.dart @@ -883,7 +883,7 @@ class RenderOpacity extends RenderProxyBox { super(child); @override - bool get alwaysNeedsCompositing => child != null && (_alpha > 0 && _alpha < 255); + bool get alwaysNeedsCompositing => child != null && _alpha > 0; int _alpha; @@ -949,11 +949,6 @@ class RenderOpacity extends RenderProxyBox { layer = null; return; } - if (_alpha == 255) { - // No need to keep the layer. We'll create a new one if necessary. - layer = null; - return super.paint(context, offset); - } assert(needsCompositing); layer = context.pushOpacity(offset, _alpha, super.paint, oldLayer: layer as OpacityLayer?); @@ -1060,7 +1055,7 @@ mixin RenderAnimatedOpacityMixin on RenderObjectWithChil _alpha = ui.Color.getAlphaFromOpacity(opacity.value); if (oldAlpha != _alpha) { final bool? wasRepaintBoundary = _currentlyIsRepaintBoundary; - _currentlyIsRepaintBoundary = _alpha! > 0 && _alpha! < 255; + _currentlyIsRepaintBoundary = _alpha! > 0; if (child != null && wasRepaintBoundary != _currentlyIsRepaintBoundary) { markNeedsCompositingBitsUpdate(); } diff --git a/packages/flutter/test/rendering/proxy_box_test.dart b/packages/flutter/test/rendering/proxy_box_test.dart index 95ab5166fa35d..b397a7eeb6105 100644 --- a/packages/flutter/test/rendering/proxy_box_test.dart +++ b/packages/flutter/test/rendering/proxy_box_test.dart @@ -328,13 +328,13 @@ void main() { expect(renderOpacity.needsCompositing, false); }); - test('RenderOpacity does not composite if it is opaque', () { + test('RenderOpacity does composite if it is opaque', () { final RenderOpacity renderOpacity = RenderOpacity( child: RenderSizedBox(const Size(1.0, 1.0)), // size doesn't matter ); layout(renderOpacity, phase: EnginePhase.composite); - expect(renderOpacity.needsCompositing, false); + expect(renderOpacity.needsCompositing, true); }); test('RenderOpacity does composite if it is partially opaque', () { @@ -370,7 +370,7 @@ void main() { expect(renderAnimatedOpacity.needsCompositing, false); }); - test('RenderAnimatedOpacity does not composite if it is opaque', () { + test('RenderAnimatedOpacity does composite if it is opaque', () { final Animation opacityAnimation = AnimationController( vsync: FakeTickerProvider(), )..value = 1.0; @@ -381,7 +381,7 @@ void main() { ); layout(renderAnimatedOpacity, phase: EnginePhase.composite); - expect(renderAnimatedOpacity.needsCompositing, false); + expect(renderAnimatedOpacity.needsCompositing, true); }); test('RenderAnimatedOpacity does composite if it is partially opaque', () { diff --git a/packages/flutter/test/rendering/proxy_sliver_test.dart b/packages/flutter/test/rendering/proxy_sliver_test.dart index c4c7e1ddaf370..bb83fd8c756cf 100644 --- a/packages/flutter/test/rendering/proxy_sliver_test.dart +++ b/packages/flutter/test/rendering/proxy_sliver_test.dart @@ -47,6 +47,7 @@ void main() { layout(root, phase: EnginePhase.composite); expect(renderSliverOpacity.needsCompositing, true); }); + test('RenderSliverOpacity reuses its layer', () { final RenderSliverOpacity renderSliverOpacity = RenderSliverOpacity( opacity: 0.5, @@ -121,7 +122,7 @@ void main() { expect(renderSliverAnimatedOpacity.needsCompositing, true); }); - test('RenderSliverAnimatedOpacity does not composite if it is opaque', () { + test('RenderSliverAnimatedOpacity does composite if it is opaque', () { final Animation opacityAnimation = AnimationController( vsync: FakeTickerProvider(), )..value = 1.0; @@ -141,7 +142,7 @@ void main() { ); layout(root, phase: EnginePhase.composite); - expect(renderSliverAnimatedOpacity.needsCompositing, false); + expect(renderSliverAnimatedOpacity.needsCompositing, true); }); test('RenderSliverAnimatedOpacity reuses its layer', () { diff --git a/packages/flutter/test/widgets/animated_opacity_repaint_test.dart b/packages/flutter/test/widgets/animated_opacity_repaint_test.dart index 555ee521951a8..425ab6bca6f2a 100644 --- a/packages/flutter/test/widgets/animated_opacity_repaint_test.dart +++ b/packages/flutter/test/widgets/animated_opacity_repaint_test.dart @@ -7,7 +7,7 @@ import 'package:flutter/rendering.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { - testWidgets('RenderAnimatedOpacityMixin drops layer when animating to 1', (WidgetTester tester) async { + testWidgets('RenderAnimatedOpacityMixin does not drop layer when animating to 1', (WidgetTester tester) async { RenderTestObject.paintCount = 0; final AnimationController controller = AnimationController(vsync: const TestVSync(), duration: const Duration(seconds: 1)); final Tween opacityTween = Tween(begin: 0, end: 1); @@ -32,12 +32,12 @@ void main() { await tester.pump(); await tester.pump(const Duration(milliseconds: 500)); - expect(RenderTestObject.paintCount, 2); + expect(RenderTestObject.paintCount, 1); controller.stop(); await tester.pump(); - expect(RenderTestObject.paintCount, 2); + expect(RenderTestObject.paintCount, 1); }); testWidgets('RenderAnimatedOpacityMixin avoids repainting child as it animates', (WidgetTester tester) async { From 652ff7a5e6684fb3fe94f89cfd23a8445f5943e5 Mon Sep 17 00:00:00 2001 From: Alex Wallen Date: Thu, 8 Sep 2022 12:35:20 -0700 Subject: [PATCH 07/21] [macOS] Add `platform_view_macos__start_up` tests devicelab test suite. (#111041) --- .ci.yaml | 10 ++++++++++ TESTOWNERS | 1 + .../bin/tasks/platform_view_macos__start_up.dart | 12 ++++++++++++ 3 files changed, 23 insertions(+) create mode 100644 dev/devicelab/bin/tasks/platform_view_macos__start_up.dart diff --git a/.ci.yaml b/.ci.yaml index eab3817be2480..0124983b41f6a 100644 --- a/.ci.yaml +++ b/.ci.yaml @@ -2729,6 +2729,16 @@ targets: - bin/** - .ci.yaml + - name: Mac platform_view_macos__start_up + bringup: true # New target https://github.com/flutter/flutter/issues/109633 + presubmit: false + recipe: devicelab/devicelab_drone + timeout: 60 + properties: + tags: > + ["devicelab", "hostonly"] + task_name: platform_view_macos__start_up + - name: Mac plugin_dependencies_test recipe: devicelab/devicelab_drone timeout: 60 diff --git a/TESTOWNERS b/TESTOWNERS index 8d39fdb63ede4..33905722990af 100644 --- a/TESTOWNERS +++ b/TESTOWNERS @@ -248,6 +248,7 @@ /dev/devicelab/bin/tasks/complex_layout_macos__compile.dart @a-wallen @flutter/desktop /dev/devicelab/bin/tasks/flutter_gallery_macos__compile.dart @a-wallen @flutter/desktop /dev/devicelab/bin/tasks/flutter_gallery_macos__start_up.dart @a-wallen @flutter/desktop +/dev/devicelab/bin/tasks/platform_view_macos__start_up.dart @a-wallen @flutter/desktop ## Host only framework tests # Linux analyze diff --git a/dev/devicelab/bin/tasks/platform_view_macos__start_up.dart b/dev/devicelab/bin/tasks/platform_view_macos__start_up.dart new file mode 100644 index 0000000000000..68f7768d1458d --- /dev/null +++ b/dev/devicelab/bin/tasks/platform_view_macos__start_up.dart @@ -0,0 +1,12 @@ +// 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_devicelab/framework/devices.dart'; +import 'package:flutter_devicelab/framework/framework.dart'; +import 'package:flutter_devicelab/tasks/perf_tests.dart'; + +Future main() async { + deviceOperatingSystem = DeviceOperatingSystem.macos; + await task(createPlatformViewStartupTest()); +} From 70f6bed9ee140768efd6a891676650ce03707fc1 Mon Sep 17 00:00:00 2001 From: Camille Simon <43054281+camsim99@users.noreply.github.com> Date: Thu, 8 Sep 2022 14:24:12 -0700 Subject: [PATCH 08/21] Fix spell_check_test (#110814) --- .../android/app/src/main/res/drawable/launch_background.xml | 2 +- .../spell_check/android/app/src/main/res/values/styles.xml | 2 +- .../spell_check/integration_test/integration_test.dart | 4 ++-- packages/flutter/lib/src/services/spell_check.dart | 3 +-- .../android/app/src/main/res/drawable/launch_background.xml | 2 +- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/dev/integration_tests/non_nullable/android/app/src/main/res/drawable/launch_background.xml b/dev/integration_tests/non_nullable/android/app/src/main/res/drawable/launch_background.xml index 32d7798786856..3727f9e00a029 100644 --- a/dev/integration_tests/non_nullable/android/app/src/main/res/drawable/launch_background.xml +++ b/dev/integration_tests/non_nullable/android/app/src/main/res/drawable/launch_background.xml @@ -1,8 +1,8 @@ + - diff --git a/dev/integration_tests/spell_check/android/app/src/main/res/values/styles.xml b/dev/integration_tests/spell_check/android/app/src/main/res/values/styles.xml index c5ad344a971e5..55fd7b57ee682 100644 --- a/dev/integration_tests/spell_check/android/app/src/main/res/values/styles.xml +++ b/dev/integration_tests/spell_check/android/app/src/main/res/values/styles.xml @@ -1,8 +1,8 @@ + -