flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
165.59k stars 27.34k forks source link

Sibling FloatingActionButtons nested under a Wrap slow to repaint on the Web #54242

Open yjbanov opened 4 years ago

yjbanov commented 4 years ago

Sample app that reproduces the issue: https://gist.github.com/clocksmith/240a6bbe1a0f72847ee4139fe493a712.

This is reproducible on the HTML backend. We should also check CanvasKit, just in case.

Hat tip to @clocksmith for narrowing it down to a reproducible app.

yjbanov commented 4 years ago

This has improved slightly after the static content scrolling optimization (https://github.com/flutter/engine/pull/17621). As the action buttons scroll out of the view we now prune the invisible paint ops. However, it does not fix the case when all the fabs are visible at once. We need a different strategy for that. I won't be able to come back to this very soon, so I'm unassigning for now.

TahaTesser commented 3 years ago

Canvaskit test looks fine

Dom

ezgif com-gif-maker

Canvaskit

ezgif com-gif-maker (1)

code sample ```dart import 'package:flutter/material.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', home: _MyHomePage(), ); } } class _MyHomePage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( body: _SlidingBackdrop(), ); } } class _SlidingBackdrop extends StatefulWidget { @override _SlidingBackdropState createState() => _SlidingBackdropState(); } class _SlidingBackdropState extends State<_SlidingBackdrop> with SingleTickerProviderStateMixin { AnimationController _controller; Widget _content; @override void initState() { super.initState(); _controller = AnimationController( duration: Duration(seconds: 5), vsync: this, ); _content = _ExpensiveWidget(); } @override Widget build(BuildContext context) { return LayoutBuilder(builder: (context, constraints) { return SizedBox.expand( child: Stack( children: [ RaisedButton( child: Text('top'), onPressed: () { print('onTap'); if (_controller.isCompleted) { _controller.reverse(); } else if (_controller.isDismissed) { _controller.forward(); } }, ), PositionedTransition( rect: RelativeRectTween( begin: const RelativeRect.fromLTRB(0, 100, 0, 0), end: RelativeRect.fromLTRB( 0, constraints.biggest.height - 100, 0, 0), ).animate(CurvedAnimation( parent: _controller, curve: Curves.easeInOut)), child: _content, ), ], ), ); }); } } class _ExpensiveWidget extends StatelessWidget { static List _colors = [ Colors.redAccent, Colors.orangeAccent, Colors.yellowAccent, Colors.greenAccent, Colors.blueAccent, Colors.purpleAccent, ]; static const _fabCount = 200; @override Widget build(BuildContext context) { return Container( color: Colors.black12, child: Wrap( children: [ for (int i = 0; i < _fabCount; i++) FloatingActionButton( child: Icon(Icons.add), onPressed: () {}, backgroundColor: _colors[i % _colors.length], ) ], ), ); } } ```
flutter doctor -v ```bash [✓] Flutter (Channel master, 1.24.0-8.0.pre.194, on Mac OS X 10.15.7 19H15 darwin-x64, locale en-GB) • Flutter version 1.24.0-8.0.pre.194 at /Users/tahatesser/Code/flutter_master • Framework revision 018467cdb1 (4 hours ago), 2020-11-11 02:04:03 -0500 • Engine revision 81f219c59c • Dart version 2.12.0 (build 2.12.0-31.0.dev) [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2) • Android SDK at /Users/tahatesser/Code/sdk • Platform android-30, build-tools 30.0.2 • ANDROID_HOME = /Users/tahatesser/Code/sdk • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 12.2) • Xcode at /Volumes/SanDisk/Xcode-beta.app/Contents/Developer • Xcode 12.2, Build version 12B5044c • CocoaPods version 1.10.0 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 4.1) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495) [✓] VS Code (version 1.51.0) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.16.0 [✓] Connected device (4 available) • Taha’s iPad (mobile) • 00008020-000255113EE8402E • ios • iOS 14.2 • macOS (desktop) • macos • darwin-x64 • Mac OS X 10.15.7 19H15 darwin-x64 • Web Server (web) • web-server • web-javascript • Flutter Tools • Chrome (web) • chrome • web-javascript • Google Chrome 86.0.4240.193 • No issues found! ```
darshankawar commented 11 months ago

Verified this using latest versions and observed the using html renderer, the issue persists, wherein the rendering is slow and FABs are nots repainted properly, as compared to canvaskit.

  1. html:

https://github.com/flutter/flutter/assets/67046386/48e69399-8c1e-4ae8-a01b-f990040f3788

  1. canvaskit:

https://github.com/flutter/flutter/assets/67046386/46730ed9-9650-445d-b73b-cdb6c1c8b358

stable, master flutter doctor -v ``` [!] Flutter (Channel stable, 3.13.9, on macOS 12.2.1 21D62 darwin-x64, locale en-GB) • Flutter version 3.13.9 on channel stable at /Users/dhs/documents/fluttersdk/flutter ! Warning: `flutter` on your path resolves to /Users/dhs/Documents/Fluttersdk/flutter/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/dhs/documents/fluttersdk/flutter. Consider adding /Users/dhs/documents/fluttersdk/flutter/bin to the front of your path. ! Warning: `dart` on your path resolves to /Users/dhs/Documents/Fluttersdk/flutter/bin/dart, which is not inside your current Flutter SDK checkout at /Users/dhs/documents/fluttersdk/flutter. Consider adding /Users/dhs/documents/fluttersdk/flutter/bin to the front of your path. • Upstream repository https://github.com/flutter/flutter.git • Framework revision d211f42860 (6 days ago), 2023-10-25 13:42:25 -0700 • Engine revision 0545f8705d • Dart version 3.1.5 • DevTools version 2.25.0 • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades. [!] Xcode - develop for iOS and macOS (Xcode 12.3) • Xcode at /Applications/Xcode.app/Contents/Developer ! Flutter recommends a minimum Xcode version of 13. Download the latest version or update via the Mac App Store. • CocoaPods version 1.11.2 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] VS Code (version 1.62.0) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.21.0 [✓] Connected device (5 available) • SM G975F (mobile) • RZ8M802WY0X • android-arm64 • Android 11 (API 30) • Darshan's iphone (mobile) • 21150b119064aecc249dfcfe05e259197461ce23 • ios • iOS 14.4.1 18D61 • iPhone 12 Pro Max (mobile) • A5473606-0213-4FD8-BA16-553433949729 • ios • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator) • macOS (desktop) • macos • darwin-x64 • Mac OS X 10.15.4 19E2269 darwin-x64 • Chrome (web) • chrome • web-javascript • Google Chrome 98.0.4758.80 [✓] HTTP Host Availability • All required HTTP hosts are available ! Doctor found issues in 1 category. [!] Flutter (Channel master, 3.17.0-5.0.pre.20, on macOS 12.2.1 21D62 darwin-x64, locale en-GB) • Flutter version 3.17.0-5.0.pre.20 on channel master at /Users/dhs/documents/fluttersdk/flutter ! Warning: `flutter` on your path resolves to /Users/dhs/Documents/Fluttersdk/flutter/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/dhs/documents/fluttersdk/flutter. Consider adding /Users/dhs/documents/fluttersdk/flutter/bin to the front of your path. ! Warning: `dart` on your path resolves to /Users/dhs/Documents/Fluttersdk/flutter/bin/dart, which is not inside your current Flutter SDK checkout at /Users/dhs/documents/fluttersdk/flutter. Consider adding /Users/dhs/documents/fluttersdk/flutter/bin to the front of your path. • Upstream repository https://github.com/flutter/flutter.git • Framework revision 94550c6257 (68 minutes ago), 2023-11-08 19:46:25 -0800 • Engine revision 8b490a9f16 • Dart version 3.3.0 (build 3.3.0-107.0.dev) • DevTools version 2.30.0-dev.1 • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades. [!] Android toolchain - develop for Android devices (Android SDK version 30.0.3) • Android SDK at /Users/dhs/Library/Android/sdk ✗ cmdline-tools component is missing Run `path/to/sdkmanager --install "cmdline-tools;latest"` See https://developer.android.com/studio/command-line for more details. ✗ Android license status unknown. Run `flutter doctor --android-licenses` to accept the SDK licenses. See https://flutter.dev/docs/get-started/install/macos#android-setup for more details. [✓] Xcode - develop for iOS and macOS (Xcode 13.2.1) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 13C100 • CocoaPods version 1.11.2 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] IntelliJ IDEA Ultimate Edition (version 2021.3.2) • IntelliJ at /Applications/IntelliJ IDEA.app • Flutter plugin version 65.1.4 • Dart plugin version 213.7228 [✓] VS Code (version 1.62.0) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.29.0 [✓] Connected device (3 available) • Darshan's iphone (mobile) • 21150b119064aecc249dfcfe05e259197461ce23 • ios • iOS 15.3.1 19D52 • macOS (desktop) • macos • darwin-x64 • macOS 12.2.1 21D62 darwin-x64 • Chrome (web) • chrome • web-javascript • Google Chrome 109.0.5414.119 [✓] Network resources • All expected network resources are available. ! Doctor found issues in 1 category. [!] Xcode - develop for iOS and macOS (Xcode 12.3) • Xcode at /Applications/Xcode.app/Contents/Developer ! Flutter recommends a minimum Xcode version of 13. Download the latest version or update via the Mac App Store. • CocoaPods version 1.11.2 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] VS Code (version 1.62.0) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.21.0 [✓] Connected device (5 available) • SM G975F (mobile) • RZ8M802WY0X • android-arm64 • Android 11 (API 30) • Darshan's iphone (mobile) • 21150b119064aecc249dfcfe05e259197461ce23 • ios • iOS 14.4.1 18D61 • iPhone 12 Pro Max (mobile) • A5473606-0213-4FD8-BA16-553433949729 • ios • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator) • macOS (desktop) • macos • darwin-x64 • Mac OS X 10.15.4 19E2269 darwin-x64 • Chrome (web) • chrome • web-javascript • Google Chrome 98.0.4758.80 [✓] HTTP Host Availability • All required HTTP hosts are available ! Doctor found issues in 1 category. ```