Skip to content
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

Closed
5 tasks done
RMaciuszonek opened this issue Dec 19, 2022 · 21 comments
Closed
5 tasks done
Labels
bug This issue reports broken functionality or another error P: 2 (soon™?) S: core Scoped to the core flutter_map functionality

Comments

@RMaciuszonek
Copy link

RMaciuszonek commented Dec 19, 2022

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?

Zoom in in example app when checking out polygons.

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

  • I agree to follow this project's Code of Conduct
  • My Flutter/Dart installation is unaltered, and flutter doctor finds no relevant issues
  • I am using the latest stable version of this package
  • I have checked the FAQs section on the documentation website
  • I have checked for similar issues which may be duplicates
@RMaciuszonek RMaciuszonek added bug This issue reports broken functionality or another error needs triage This new bug report needs reproducing and prioritizing labels Dec 19, 2022
@RMaciuszonek RMaciuszonek changed the title [BUG] Freezing while zooming in with polygons on map Dec 19, 2022
@ibrierley
Copy link
Collaborator

Have you tried polygonCulling: true on the PolygonLayer ?

@RMaciuszonek
Copy link
Author

RMaciuszonek commented Dec 20, 2022

If i add in the example app in class polygon.dart atribute polygonCulling: true to PolygonLayer widget then app is still freezing when using big zoom. Maybe problem is somwhere else, but on the other hand i it is ocuring for me only in polygon usage example.

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.

@ibrierley
Copy link
Collaborator

ibrierley commented Dec 20, 2022

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.

@RMaciuszonek
Copy link
Author

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).

Polygon(
        points: filledDotedPoints,
        isFilled: true,
        isDotted: true,
        borderStrokeWidth: 4,
        borderColor: Colors.lightBlue,
        color: Colors.lightBlue,
      ),

and

Polygon(
       points: notFilledDotedPoints,
       isFilled: false,
       isDotted: true,
       borderColor: Colors.green,
       borderStrokeWidth: 4,
     ),

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.

@ibrierley
Copy link
Collaborator

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

@RMaciuszonek RMaciuszonek changed the title Freezing while zooming in with polygons on map Freezing while zooming in with dotted line polygons on map Dec 20, 2022
@RMaciuszonek
Copy link
Author

Also i feel like this issue can be closed by repetition of #990

@spatialbits
Copy link

spatialbits commented Dec 20, 2022

21 points in 6 polygons is a very small number. @ibrierley would culling actually make any difference?
I ran into this a while back and resigned to just limiting zoom to an arbitrary level (maybe 20?) which helped but it can still get freezy.

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.

@JaffaKetchup
Copy link
Member

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.
Perhaps I'm remembering wrongly, or perhaps that didn't go far enough to resolve something like this.

@JaffaKetchup
Copy link
Member

JaffaKetchup commented Dec 20, 2022

If you can post a video, or add a minimal reproducible example, I can mark this as verified :)

@ibrierley ibrierley removed the needs triage This new bug report needs reproducing and prioritizing label Dec 20, 2022
@ibrierley
Copy link
Collaborator

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.

@spatialbits
Copy link

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.

@RMaciuszonek
Copy link
Author

RMaciuszonek commented Dec 21, 2022

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.

@spatialbits
Copy link

@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.

@ibrierley
Copy link
Collaborator

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!

@github-actions
Copy link

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.

@JaffaKetchup
Copy link
Member

This needs re-evaluating after v4.

@spatialbits
Copy link

Just tried on latest master and confirmed still an issue. Setting isDotted=true causes crashing at higher zoom, back to false and crashing stops.

@V3ntus
Copy link

V3ntus commented Jun 28, 2023

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

@JaffaKetchup JaffaKetchup changed the title Freezing while zooming in with dotted line polygons on map [BUG] Poor performance while zooming in with dotted line polygons on map Dec 10, 2023
@JaffaKetchup
Copy link
Member

This does appear to now be resolved. Please ping if you still experience this with the latest version!

@JaffaKetchup JaffaKetchup added the S: core Scoped to the core flutter_map functionality label Dec 10, 2023
@ibariens
Copy link

@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.

@V3ntus
Copy link

V3ntus commented Dec 13, 2023

No freezing here:

  flutter_map:
    dependency: "direct main"
    description:
      name: flutter_map
      sha256: cda8d72135b697f519287258b5294a57ce2f2a5ebf234f0e406aad4dc14c9399
      url: "https://pub.dev"
    source: hosted
    version: "6.1.0"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue reports broken functionality or another error P: 2 (soon™?) S: core Scoped to the core flutter_map functionality
Projects
Archived in project
Development

No branches or pull requests

6 participants