Fix TileLayer lag during fling/animated movement#1247
Fix TileLayer lag during fling/animated movement#1247JaffaKetchup merged 11 commits intofleaflet:masterfrom
Conversation
…ld as it's fast anyways and just complicates the code
Previously we listened to the movement stream, calculated the translations and then called setState(). This introduced noticible jank/lag where when flinging the map or moving it with an AnimatedController other layers (e.g. markers) would not move together with the map.
* Run dart format * Re-fix the tile ordering function, it was putting lower-zoom tiles. above higher zoom ones. * Add the StreamBuilder to trigger builds as a result of map movement.
|
Wow, this looks much better than it did before and was one of our main aims. I'll test as soon as I can :) |
JaffaKetchup
left a comment
There was a problem hiding this comment.
Haven't tested/run anything, but this is all I could see from scrolling through the changes! You've really done a great job, thanks :)
All the suggestions are just slight optimisations and tidy up, and I'm open to discussion if you disagree with any of them.
The Tile loading was initiated before adding the Tile to the TileManager which meant that with a very fast connection or cached Tile images the load callback would be called before the Tile was in the TileManager. Therefore when we tried to set the loaded value of the Tile in the callback we would not find the Tile and the Tile was never marked as loaded. This caused the tile to be removed sooner than it should be since we prune tiles that are not loaded yet when zooming in.
|
Thanks @JaffaKetchup I've made those changes 👌 ! |
|
Thanks. I'll do a full test at some point today! |
1e8a5d0 to
26a9afd
Compare
…he exports since it's needed for custom TileProvider implementations
ibrierley
left a comment
There was a problem hiding this comment.
All looks good to me. Great stuff, and thanks for all the work done on this.
|
Testing now... |
JaffaKetchup
left a comment
There was a problem hiding this comment.
LGTM. Many thanks once again!
|
Awesome I wasn't expecting it to get reviewed and merged so quick, thanks to both of you! |
Fixes #1245
When flinging or animating the moment of the map the TileLayer would lag behind which resulted in either jerkiness or other layers moving out of sync with the TileLayer depending on how fast the device is.
This PR should address that issue by moving the Tile translation calculation in to the builder rather than in a stream listener which called setState(). This means that translation is calculated during the build whilst updating/loading of tiles can still happen in the stream listener to prevent them from slowing down the build too much.
As part of these changes I heavily refactored the TileLayer code as it was difficult for me to follow.