Slow rendering of zoomed map with polylines
I put a couple of polylines on the map. If I zoom from min zoom to see small towns and villages map is being re-build with some freezes. Other widgets above the map also experience some freezes. If I don't put any polylines, the map works good and doesn't freeze.
I supposed it is because of redrawing polylines outside the viewport. So I set polylineCulling: true but got LateInitializationError: Field 'boundingBox' has already been initialized since polyline.boundingBox is final but PolylineLayerOptions constructor tries to set its value. Making boundingBox not final doesn't seem to make polylineCulling work. Or the reason of map freezes is something else.
Seems like that LateInitializationError error is plaguing flutter_map at the moment. Not sure what to recommend, other than waiting unfortunately. There may be open PR that may fix your issue...
At the moment I am not sure that this error causes freezes. Since making boundingBox not final stops the error but not the freezes. I haven't debugged it yet but have a feeling that the code which updates boundingBox if polylineCulling is true does not really archive intended effects.
Ignoring the late init error for the moment, you mention a "couple" of polylines, but then mention small towns and villages map (I'm assuming we're not talking raster images here?), so I'm wondering how detailed these polylines are. Again, I may be misunderstanding that.
Do you mean polyline points? If yes, then each polyline has 181 points (one for each latitude int degree). Mentioning villages and towns I meant the zoom level from which freezes become noticible, sorry I should have given a zoom value instead to be precise.
So, do you mean there's a lot more than 2 polylines in total (how many if so), but only 2 would be visible at higher zooms and it's too slow still?
Lets simplify it - single polyline of 181 points: latitude goes from -65˚ to 65˚ and longitude from -180˚ to 180˚. After I zoom the map to level close to 10 and then move it with a finger gesture, I can notice some freezing of map updating. If I zoom more these freezes become more noticeable. Reproduced with any value of polylineCulling. When I also add a https://pub.dev/packages/sliding_up_panel widget covering a part of the map area and slide it up or down it also works with freezes (here I suppose that panel renders everything that under it - map in my case, so the reason of panel freezes seem to be the same as map freezes when moving it - rendering of polyline, I guess even those parts of it which are out of viewport). Without a polyline everything works perfect.
Curious. Just out of interest, if you make the polyline have a stroke width of 0 only (just for testing), does it have any effect on the freezes ?
@ibrierley Thank you very much for mentioning stroke. My problematical polyline is dotted. When I make it regular line, no freezes! So I guess by now I have to switch to isDotted: false, unfortunatelly. I appreciate if you consider a possibility of making dotted polylines work fast (but I guess they should take more time to be drawn). Thanks again.
No problem, dotted lines and strokewidths over 1 both have some performance implications (especially when panzooming I think). I suspect there's some tweaks for dotted lines, but it's probably a fair bit of work if anyone ever wants to experiment. I've done the odd hack where when panning I draw a thin solid line, and then change it after panning, but it sometimes feels a bit clunky and I had to do my own plugin etc.
On Fri, Aug 6, 2021 at 8:36 AM mchesnokov @.***> wrote:
@ibrierley https://github.com/ibrierley Thank you very much for mentioning stroke. My problematical polyline is dotted. When I make it regular line, no freezes! So I guess by now I have to switch to isDotted: false, unfortunatelly. I appreciate if you consider a possibility of making dotted polylines work fast (but I guess they should take more time to be drawn). Thanks again.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/fleaflet/flutter_map/issues/990#issuecomment-894067340, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA5YN5PGWLFOV2BRNAGHXG3T3OGGVANCNFSM5BULL4QQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .