mapsforge_flutter icon indicating copy to clipboard operation
mapsforge_flutter copied to clipboard

Performance issue when rotating the map

Open vasilevzhivko opened this issue 5 months ago • 12 comments

Hi @mikes222 , its me again :) I recorded a video of a performance issue when rotating the map, when there are many symbols its really laggy, this used to work on the previous version. Here is the video

I will also open a PR with an extension to this rotation layer that enables the user to recenter the map or lock it

vasilevzhivko avatar Sep 25 '25 14:09 vasilevzhivko

I suggest to use the positionStream instead of the rotationNotifier.

mikes222 avatar Sep 25 '25 17:09 mikes222

The former comment regards to the PullRequest.

  • How many symbols are in the datastore(s) when you rotate?
  • What means "previous version"?
  • Is the map rotation fast without the symbols?

mikes222 avatar Sep 25 '25 17:09 mikes222

  • i dont know exactly, but I guess a lot in the map itself in the stores around 20
  • the version before the refactoring
  • yes you also have the map that i am using so maybe you can give it a try, but i tried on both physical and simulator

vasilevzhivko avatar Sep 25 '25 17:09 vasilevzhivko

I have experienced similar issues, but with thousands of markers. I need more time to find the root cause...

mikes222 avatar Sep 28 '25 16:09 mikes222

I have experienced similar issues, but with thousands of markers. I need more time to find the root cause...

yes, i guess it was thousands for me as well, because its only happening near big cities.. hope you manage to solve it

vasilevzhivko avatar Sep 28 '25 18:09 vasilevzhivko

Improved rotation:

  • Switched to rotationHandler which is a faster implementation compared to RotationGestureDetector
  • Prevent recalculating tiles while rotating or zooming

Additionally I have implemented a DefaultMarkerClusterDatastore which helps if there are thousands of markers which could be clustered.

Let me know if this solves your problem.

mikes222 avatar Oct 04 '25 08:10 mikes222

Improved rotation:

  • Switched to rotationHandler which is a faster implementation compared to RotationGestureDetector
  • Prevent recalculating tiles while rotating or zooming

Additionally I have implemented a DefaultMarkerClusterDatastore which helps if there are thousands of markers which could be clustered.

Let me know if this solves your problem.

sorry for the delayed response, just managed to test it on an actual device. there is significant improvement in the rotation, even tho the map does not feel smooth as the initial version when i started using your library, we are getting there day by day. Thank you for your effort!

vasilevzhivko avatar Oct 06 '25 13:10 vasilevzhivko

@mikes222 there is one more thing that is a bit problematic here is a video of it if you have a marker (path marker, or poimarker) drawn and you start moving the map, the map moves before the markers do, that very visible when you have lots of symbols on the map, do you think thats something that can be fixed?

vasilevzhivko avatar Oct 07 '25 14:10 vasilevzhivko

Unfortunately I have no idea how to synchronize the overlays in the best possible way. Each overlay is now independent of each other and receives its informations at different times. If you have an idea or find a possible architectural pattern feel free to point me in the right direction.

mikes222 avatar Oct 07 '25 16:10 mikes222

Unfortunately I have no idea how to synchronize the overlays in the best possible way. Each overlay is now independent of each other and receives its informations at different times. If you have an idea or find a possible architectural pattern feel free to point me in the right direction.

@mikes222 i played around trying to figure out someway to resolve it, i updated my PR you can check it maybe you will get an better idea from it, the main problem is the different update sources for tiles and marker datastore, i tried to unite them, but now the markers are blinking on every map movement, otherwise they move with the map :) its almost 12 AM here, so i cant do much more, but if you get an inspiration from my PR feel free to cancel it

vasilevzhivko avatar Oct 07 '25 20:10 vasilevzhivko

hi @mikes222 unfortunately there is one more performance issue, if the map is zoomed out a lot, and you try to move it around while having lots of markers, its very slow, this was working quite smoothly in the previous implementation of the library any update on that topic?

posting a video as well

vasilevzhivko avatar Oct 21 '25 11:10 vasilevzhivko

hi @mikes222 regarding the last issue, i noticed its the LabelView causing it, when the zoom level is really low, it tries to draw thousands of markers, i created a very simple pull request where you can limit when labels are drawn on the map based on the zoom level: PR here

vasilevzhivko avatar Oct 24 '25 11:10 vasilevzhivko