-
Notifications
You must be signed in to change notification settings - Fork 28.6k
Ability to use Canvas in Isolates #75755
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
Comments
Follow-up on this since I am stuck with the same problem for advanced rendering. |
I could also use this feature very well when generating images for PDFs. |
This would be immensely useful for my app BeatScratch. |
@nfriend , how did you work around this, or is the rasterization jank unavoidable with Flutter? |
@rlueders If I remember correctly, I did not find a solution 😞 The jank shown in the screenshot above is still present in the production version of my app. |
Right now this is a huge bottleneck for rendering vector tiles directly in dart, which would massively benefit from this feature. A lot of users are waiting for a performance improvement (https://github.com/greensopinion/flutter-vector-map-tiles) |
FYI, you can use most of dart.UI from Flutter Isolates. I have been using it for a while with dramatic improvements when generating hundreds of thousands of images from Canvas. However, use with caution as calls dart.ui from Flutter Isolates seems to have broken after I enable Impeller on IOS. Still works with on Android and with Impeller disabled. |
Perhaps the issue could be addressed by allowing the creation of lightweight Flutter engines in isolates in a pure Flutter app (not Add-to-app)? Since the lightweight Flutter engines share some context they would start up quickly, but would allow the developer to generate images in background isolates. This would open up so many GIS use cases, given the amount of data and rendering which is required!! Restricting the use of writing to the Canvas to a single thread, means for all intents and purposes, a Flutter GIS solution is an order of magnitude slower than a native GIS implementation. (Even in Xamarin you can draw to the canvas in background threads). |
Duplicate of #13343 |
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 |
Use case
I'm building a drawing application that renders lots of lines:
Since each of these designs can include hundreds of thousands of points, I regularly (every 1000 points) rasterize the line, set the result as the background image of the drawing canvas, and remove the captured points. This keeps the total number of non-rasterized lines low and keeps the frame-rate high even after lots of drawing.
The problem
However, there's a noticeable jank when I perform this rasterization process. (You can see it happen about 5 times in the GIF above.)
I've already optimized this process a bit by breaking the background canvas into tiles and only updating the tiles that have changed. This helps tremendously, but it's still not enough to avoid noticeable jank.
My attempt at a solution
I thought moving this rasterization process to an
Isolate
might help smooth the frame rate a bit. However,dart:ui
isn't available inIsolate
s (source).Proposal
Allow a
Canvas
to be instantiated and rendered in aIsolate
. This would allow computationally complex image manipulations to be performed off the main Isolate.Related issues
Disclaimer
I'm not actually sure if this would solve my problem - perhaps copying the image data between
Isolate
s would be just as expensive as the render itself 🤷Source code
In case it's useful, the source code for my Flutter app can be found here: https://gitlab.com/nfriend/inspiral
The text was updated successfully, but these errors were encountered: