-
Notifications
You must be signed in to change notification settings - Fork 27.1k
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
When zooming and panning complex paths, performance degrades #72718
Comments
cc @goderbauer |
I was able to notice some lag while zooming in and then trying move the map. flutter doctor -v
|
This could also be something I've been seeing (using flutter_map). I've been trying to draw vectors/paths using a custompainter (with a repaintboundary). My experience has been that panning is ok, but pinch-zooming is very slow, and the painter needs to repaint every time (frame) and there seems to be simply no way to avoid it (even with shouldrepaint false). I had wondered about wrapping it in a valuenotifier, but I suspect the custompainter has to completely repaint every time there is a different zoom/transform or whatever. In your case, I wonder if you could try creating a path with subpaths of those, and only call drawpath once (if you aren't changing the fills/strokes) ? That may help a little ? |
@ibrierley Thanks for your inputs. Previously I had redrawn all the paths every time while zooming and panning. As expected, I have faced lagging issues and hence I decided to wrap our widget inside the Transform widget with RepaintBoundary. Now, we set only the scale and translation value while interacting (I had used InteractiveViewer in the above sample but tried Transform widget already) and redrawn the paths only at the interaction end and not during interaction. So paint is not being called while interacting now. |
This is weird, the RepaintBoundary work as expected because the painter don't redraw everytimes, when zooming it take between 60ms and 30ms to draw a frame but when panning it only take 3ms so there is something to do with the zoom. Transform.scale give the same performance so I don't believe its the fault of InteractiveViewer but something else that has to do with how flutter paint handle long path ? |
@pedromassangocode Can you please update its progress? |
No, you will get notification for every update on this issue (because you are the author)! |
I have faced similar issues with using CustomPaint for drawing many complex paths and then trying to pan and zoom. My open issue: #72066 Do you also see a difference between Android and iOS? In my case, on iOS devices the issue is almost disappearing; only older iPhones may show some jank when zooming. However, on Android, even high-end devices seem to struggle and get under 20fps. |
@whiplashoo Yes, I can see the difference between Android and iOS. Facing more performance lag with android and iOS is better than that. |
There is a shorter (~20 line) example of this issue with a video in #78543. |
I had the same problem and solved it by switching from path drawing to line drawing. |
This looks like a duplicate of #78543. To focus conversation and work to resolve the issue, I am going to close this. Please follow up there. A lot of discussion has already occurred with potential solutions. If you feel this is a separate issue, let us know and we'll take another look! Thanks! |
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
Using CustomPainter/RenderBox, I rendered a complex path by converting coordinate points(get it from the JSON file) into pixel offsets. After that, I've added the InteractiveViewer to do zooming and panning. Here, I've faced enormous performance problems.
I suspect it maybe the reason of repainting every pixel update, so I have wrapped my widget inside the RepaintBoundary widget, but still I didn't get any improvements.
I have tested both Android and iOS.
JSON file: json_file.zip
Code
flutter doctor
The text was updated successfully, but these errors were encountered: