-
Notifications
You must be signed in to change notification settings - Fork 26.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[web] canvaskit performance issue #88704
Comments
Issue is reproducible on See profile reports below: canvaskit-stable.json.zip html-renderer.json.zip
flutter doctor -v[✓] Flutter (Channel master, 2.5.0-7.0.pre.213, on macOS 11.5.1 20G80
darwin-arm, locale en-GB)
• Flutter version 2.5.0-7.0.pre.213 at /Users/nexus/dev/sdks/flutters
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 6dc18ef74e (7 hours ago), 2021-08-24 11:09:04 +0530
• Engine revision 926ce0d855
• Dart version 2.15.0 (build 2.15.0-43.0.dev)
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
• Android SDK at /Users/nexus/Library/Android/sdk
• Platform android-31, build-tools 31.0.0
• Java binary at: /Applications/Android
Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 12.5.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• CocoaPods version 1.10.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2020.3)
• 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 11.0.10+0-b96-7249189)
[✓] VS Code (version 1.59.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.25.0
[✓] Connected device (3 available)
• M2007J20CG (mobile) • 5dd3be00 • android-arm64 • Android 11 (API 30)
• macOS (desktop) • macos • darwin-arm64 • macOS 11.5.1 20G80
darwin-arm
• Chrome (web) • chrome • web-javascript • Google Chrome
92.0.4515.159
• No issues found! [✓] Flutter (Channel stable, 2.2.3, on macOS 11.5.1 20G80 darwin-arm, locale
en-GB)
• Flutter version 2.2.3 at /Users/nexus/dev/sdks/flutter
• Framework revision f4abaa0735 (8 weeks ago), 2021-07-01 12:46:11 -0700
• Engine revision 241c87ad80
• Dart version 2.13.4
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
• Android SDK at /Users/nexus/Library/Android/sdk
• Platform android-31, build-tools 31.0.0
• Java binary at: /Applications/Android
Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.5.1, Build version 12E507
• CocoaPods version 1.10.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2020.3)
• 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 11.0.10+0-b96-7249189)
[✓] VS Code (version 1.59.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.25.0
[✓] Connected device (3 available)
• M2007J20CG (mobile) • 5dd3be00 • android-arm64 • Android 11 (API 30)
• macOS (desktop) • macos • darwin-arm64 • macOS 11.5.1 20G80
darwin-arm
• Chrome (web) • chrome • web-javascript • Google Chrome
92.0.4515.159
• No issues found! |
The images are very big (4000x4000, which requires 64MB of memory assuming 4-bytes per pixel). I'm guessing that loading them all at the same time maxes out the GPU memory limit causing the images to be kicked out of the cache and reuploaded again on every frame. Flutter currently does not automatically downscale images. Chrome probably does (when using the HTML renderer). @laurensdewaele Can you please try increasing the GPU memory limit and see if that improves performance? To increase the limit call first thing in the await SystemChannels.skia.invokeMethod('Skia.setResourceCacheMaxBytes', 1000000000); |
Once we confirm the hypothesis that this is a GPU memory limit issue, we can start thinking about solutions. For example, one solution (and one that's generally recommended on the web) is to use smaller images for thumbnails. However, it's also fair to say that Flutter shouldn't be worse than HTML, and we could attempt a heuristic similar to what browsers do, such as downscale the image automatically. |
@yjbanov, Increasing the GPU mem limit does solve the performance problem for the reproducible demo app. The app we're building, ideally, needs to be capable to handle a lot of high-res images in a sort of InteractiveViewer widget. What would be the ideal implementation here?
Any thoughts? (@dnfield probably knows more about this) |
@yjbanov are you sure the resource cache in Skia is used for images? We don't use it on the VM side, we actually disable the resource cache on the thread responsible for image decoding. You are right that these images are really big and using a lot of memory. You might try to increase the image cache's limit, but it's probably not relevant here since the widget tree contains all the images anyway up front, and even if they don't fit in the limits of the cache they'll get tracked that way. I'd recommend trying to add a |
|
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
Details
To reproduce: put scaled images in a Stack wrapped with an InteractiveViewer (see gist)
The problem is that the performance is fine on macOS desktop target, however on Chrome with canvaskit, the performance really suffers.
Test was done with
--release
and--web-renderer canvaskit
Sample app
Video showcasing osx vs chrome
**Target Platform: macOS / Web
**Target OS version/browser: 11.5.2 / 92
Logs
Logs
The text was updated successfully, but these errors were encountered: