flutter_map icon indicating copy to clipboard operation
flutter_map copied to clipboard

[FEATURE] Add option to automatically retry missed tiles

Open corepuncher opened this issue 1 year ago • 2 comments

What do you want implemented?

When downloading large numbers of tiles, sometimes a few are missed for whatever reason, resulting in ye olde checkerboard pattern.

However, the next time the tile layers rebuild (for example, when my timer updates with new data), all the previously missed tiles get filled in. So it appears they are "remembered" in some way. This fill-in behavior is reliable.

Instead of waiting for a rebuild (which in my case is 10 minutes later), it would be nice to have the option to automatically retry missed/failed tile downloads. It could take two parameters:

delay: The length of time to wait before retrying retries: The number of times to retry

What other alternatives are available?

No response

Can you provide any other information?

I'd be happy to test this out, tune the parameters, etc.

Severity

Obtrusive: No workarounds are available, and this is essential to me

corepuncher avatar Mar 20 '24 18:03 corepuncher

I will say that using fallbackUrl seems to really mitigate the issue. To my surprise the images remain cached, although I have been told this may be more of a flutter bug, and is not really a "fix".

In addition, another workaround I have found (especially for slow web rendering) is to split TileLayers up among CancellableNetworkTileProvider and NetworkTileProvider. I have scores of TileLayers, and for some reason, changing a portion of them to NetworkTileProvider alleviates the load somewhat, resulting in less missed tiles.

corepuncher avatar May 03 '24 03:05 corepuncher

Indeed, as discussed, if fallbackUrl is still caching tiles, that could be considered a bug. See the discussion at https://github.com/fleaflet/flutter_map/pull/1629 for info.

The equality method does implement this properly, but the hashCode does not, which could be causing the bug: https://github.com/fleaflet/flutter_map/blob/master/lib%2Fsrc%2Flayer%2Ftile_layer%2Ftile_provider%2Fnetwork_image_provider.dart#L120.


Does using the reset stream make a difference? Not sure if we've already tried that. (Although it might not work, see #1808).

JaffaKetchup avatar May 16 '24 19:05 JaffaKetchup

Please supply an http RetryClient into your tile provider. There is one provided in the http library. this will ensure that the requests are retried when they fail, and it will guarantee correct caching. You can just supply it into whatever CachedTileProvider you are currently using.

(http clients can wrap other clients, so if you are already using a custom client, just wrap that client in the RetryClient (or the other way around), depending on whatever is appropriate for your app)

mootw avatar Jan 14 '25 20:01 mootw