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

Tiles not loading correctly with slow tiles provider and multiple zooms/pans #659

Closed
HugoHeneault opened this issue Jun 19, 2020 · 7 comments

Comments

@HugoHeneault
Copy link
Contributor

Hello 👋

We love flutter_map 0.9.0 with the new zoom/pan behavior from #572. Well done @maRci002 !
But we have an issue when using a slow tiles provider.

Using fast tiles provider works great. When it takes a few sec to fetch the tiles, things get weird.
If a tile didn't finish loading and a zoom is triggered, the new one seems to be extremely slow to load, as if it awaits the first one to load before loading the latest zoom. Sometimes it even seems to never load at all.

Do you have any idea?

Thanks!

@louyanqi
Copy link

louyanqi commented Jul 2, 2020

This will lead to a bad experience, can there be a parameter to control whether the old tiles needs to be displayed?

@maRci002
Copy link
Contributor

maRci002 commented Jul 2, 2020

#580 (comment)

then _abortLoading() should handle it and ask TileProvider to drop connections if a Tile is still in loading phase and when dispose is called, however there no way to ask CachedNetworkImageProvider / NetworkImage to abort downloading this may be the second issue to flutter team

In #572 I implemented _abortLoading method, however it cannot abort an ongoing image fetch, maybe a custom Image provider can solve this which supports abort the fetch.

@tuarrep
Copy link
Contributor

tuarrep commented Jul 13, 2020

I've forked flutter_image package and made request cancelable : https://github.com/OwnWeb/flutter_image.

I've tried to implement this by adding tile.imageProvider.cancel('') in TileLayer _abortLoading method (l 527) but it doesn't seems to fix the described issue.
When intensively zooming (in / out) some tiles never fetches but other goes well.

Here is the snippet:

if (tile.imageProvider is NetworkImageWithRetry) {
  NetworkImageWithRetry imageProvider = tile.imageProvider;
  imageProvider.abort('');
}

As an example of "slow tiles provider" you can use "https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png"

I've pushed my code here https://github.com/OwnWeb/flutter_map/tree/fix/tile-loading-stuck

@tuarrep
Copy link
Contributor

tuarrep commented Aug 12, 2020

I've searched a lit bit more.

I feel the canceled tiles are not removed from the tiles list, so they aren't refreshed when zooming back to the level which requires them.

Perhaps #667 can help to discard canceled tiles.

Not tested anything yet.

@maRci002
Copy link
Contributor

It's not about canceled tiles, onTileReady won't find the incoming tile in _tiles because purne or update / abort removed it from _tiles map. It only preserves the old tiles (removes them if new ones ready from new zoom) if they are already loaded or if they are in loading phase they will removed from _tiles immediately.
I think this is leaflet's algorithm I can check behavior next week.

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

@github-actions github-actions bot added the Stale label Mar 21, 2021
@github-actions
Copy link

This issue was closed because it has been stalled for 5 days with no activity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants