vector_map_flutter icon indicating copy to clipboard operation
vector_map_flutter copied to clipboard

Background loading performance

Open bartoszpijet opened this issue 4 years ago • 3 comments

Hi,

I've noticed that background in tiles is loading really slowly while zooming map with mouse scroll. Seems like this problem is occuring both on debug and build. Tested with flutter web.

err

bartoszpijet avatar Dec 01 '21 14:12 bartoszpijet

Hi @bartoszpijet !

I don't know if it was a good solution, but I set a property to recreate the image buffers after matrix changes. The default value is 1000 milliseconds but can be changed to 0.

This is to try to avoid creating the buffers all the time (heavy). Makes more sense for heavy geometries. It's overkill for geometries with few coordinates.

Try changing:

VectorMapController(..., delayToRefreshResolution: 0)

caduandrade avatar Dec 01 '21 21:12 caduandrade

Hi @caduandrade!

Thank you for your quick response!

I have not noticed that parameter. Testing it out shows that it loads without initial delay, just as you've said.

Unfortunately, background loading is still not responsive enough. I've also checked it on Desktop/Linux, the problem still occurs.

Since I and my team do need this package for one of our projects I'll try to contribute with a fix for that issue. Please do not close this issue, I'll contact you here pretty soon with more info about our fix proposition.

Greetings

bartoszpijet avatar Dec 02 '21 12:12 bartoszpijet

I couldn't see the debugger in the animation. Does your geometry have many points? I separated each layer into chunks. So at each new resolution (scaling/translation), each chunk is updated but executes a Future with zero delay to not lock the screen, letting the Flutter EventLoop continue running. The side effect is that the total time to finish the buffers takes longer.

This part is a little complex. To avoid multiple buffers being generated simultaneously, I tried to create something like a "ticket" to cancel the creation of the current one and let a new one be started.

One more detail about chunks: I tried to provide at least some feedback to the user. Even if it was little by little. Better than a frozen screen you know?

Any new idea or improvement is very welcome. Always try to test with geometries with many coordinates.

caduandrade avatar Dec 02 '21 13:12 caduandrade