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
[BUG] Poor performance while zooming in with dotted line polygons on map #1416
Comments
Have you tried polygonCulling: true on the PolygonLayer ? |
If i add in the This is really hard, and it doesn't help to quickly test the capabilities of this library using points and polygons when the sample application freezes on basic examples. |
What zoom level are you using when it gets slow, and how many points does the poly(s) have ? It would be useful to have a test case to look at, and maybe a video or something. |
If i counted correctly there are only 21 points in 6 polygons and for me it starts freezing around zoom 16/17 (https://github.com/fleaflet/flutter_map/blob/master/example/lib/pages/polygon.dart).
and
So in my opinion the problem is the dotted polygon line. It looks like it doesn't cut the polygon line and draws all the points of the line / polygon, even outside the visible area. Also i edited this issue because i found out that the proble is only ocuring when doted line of polygon is visible or is just close to visible borders. |
Maybe the code should do culling on the circles painted by the dotted line if partially out of view or something. Might be interesting to try and see if that helps at all and do a PR if it does |
Also i feel like this issue can be closed by repetition of #990 |
21 points in 6 polygons is a very small number. @ibrierley would culling actually make any difference? To add, yes culling did help in my case at the slightly lower zoom levels because I was drawing huge polylines - but it didn't work initially because the lines are single geometries so they have to be cut up and added as a bunch of short little segments. |
Interestingly, I thought there were some performance improvements to the dotted lines as part of a PR (which I can't remember the name of) after #990 was confirmed/closed. |
If you can post a video, or add a minimal reproducible example, I can mark this as verified :) |
I did try culling circle/points earlier out of interest. I'd say it helped a little, but not to a level I think would make that much of a difference. With a large polyline zoomed in, there's ultimately potentially a lot of circles to bounds test, and I think there's a tradeoff there (extra testing for dots that are in bounds, vs those that aren't), so I'm not sure thats the best solution here. It may be worth looking to see what some other libraries like leaflet do here. |
It was a while ago that I was dealing with it, but I seem to recall noticing that there was some change in behaviour when the line was entirely within/outside the viewport vs intersecting the viewport, with the latter producing performance problems. Yeah I know it doesn't help without a reproducible sample - maybe if I can find time over the holidays. |
I feel like the best way to fix it is by finding interection point of doted line and view boundary +- some value and then draw only this "subline" instead of the whole line. That way we can skip testing circles to bounds. |
@RMaciuszonek the only complication is that you can't just exclude vertices that fall outside the viewport and then connect the dots that are left. If the line crosses the viewport you need to exclude all but the next vertex falling outside so that you can connect the vertex in the viewport to it with a line. Not impossible to do but it could be a fiddly piece of code. |
I think this is it in a nutshell...it's certainly possible, but there are overheads whatever, and it's already slowish. So then you add extra calculations which help when a poly is mainly out of view, but possibly makes it even slower when it's mainly in view. It's worth experimenting though! |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days. |
This needs re-evaluating after v4. |
Just tried on latest master and confirmed still an issue. Setting |
Confirmed still a thing. This isn't a big issue to me personally as the difference is only cosmetic, but looks like progress is being made |
This does appear to now be resolved. Please ping if you still experience this with the latest version! |
@JaffaKetchup thanks for looking into this. Just tried with the latest master (e7170d) and unfortunately still freezes with isDotted = true. Setting to false fixes all performance issues. |
No freezing here:
|
What is the bug?
When using a polygon with dotted line on a map with a large zoom value (16/17 for me), the map becomes unreactive, and the larger the zoom the worse the performance of the application. It looks like it doesn't cut the polygon line and draws all the points of the line / polygon, even outside the visible area.
What is the expected behaviour?
The map should run smoothly at all times.
How can we reproduce this issue?
Do you have a potential solution?
Probably not drawing objects outside map borders. Also meybe some cutting them by border line would improve it even more. Just check if parts of polygon are in visible screen.
Can you provide any other information?
No response
Platforms Affected
Android
Severity
Obtrusive: Prevents normal functioning but causes no errors in the console
Frequency
Consistently: Always occurs at the same time and location
Requirements
flutter doctor
finds no relevant issuesThe text was updated successfully, but these errors were encountered: