fleaflet / flutter_map

A versatile mapping package for Flutter. Simple and easy to learn, yet completely customizable and configurable, it's the best choice for mapping in your Flutter app.
https://pub.dev/packages/flutter_map
BSD 3-Clause "New" or "Revised" License
2.68k stars 848 forks source link

[BUG] After Zoom, old tiles remain on screen along with new tiles, only disappearing after map gesture or rebuild. #1837

Open corepuncher opened 4 months ago

corepuncher commented 4 months ago

What is the bug?

After a fast change in zoom, my simple state/country border webp tiles do not redraw correctly. My GUESS is that the "old" tiles are not being REMOVED until a map interaction. All other tiles redraw fine.

How can we reproduce it?

I am using transparent webp tiles for my maps. They have black or white state/country lines, that's it. They are actually VERY small, the largest being 1-2kb.

Make a set of transparent tiles with only state boundaries (or I can send you mine), then zoom in or out fast to the point of needing to download a new zoom level of tiles.

After the zoom gesture, you will notice the lines appear "brighter". That is because temporarily, there are two layers of tiles loaded. Since the old (now stretched) tile image from the lower zoom level has "thicker" lines, I can actually see the new lines plot on top of the previous lines. Then when I move the map, the old/stretched tiles disappear.

Just a simple tile layer:

                TileLayer(
                    tileProvider: CancellableNetworkTileProvider(),
                    urlTemplate: 'https://site.com/{z}/{x}/{y}.webp',
                    tms: false,
                    minNativeZoom: 4,
                    maxNativeZoom: 10,
                  ),

Do you have a potential solution?

Since I have never seen this issue before with all my other tiles, it makes me wonder:

Has this been going on before, but I only noticed now because these are transparent tiles? In other words, the previous set of tiles remain on the screen, but most of the time, with opaque tiles, you don't see it? Anyway, it would be nice if once the new tiles are downloaded, the old would immediately disappear, without a map gesture.

Also, I have ruled out: Cancellable vs NetworkTileProvider...no difference. Also commended out keep/pan buffers and tileDisplay property. No difference.

Platforms

Galaxy S23

Severity

Obtrusive: Prevents normal functioning but causes no errors in the console

corepuncher commented 4 months ago

FYI, if I zoom slowly, it gives it time for the tiles to update correctly. In addition, I tested my other transparent layer. Same behavior, I just didn't notice before. For my other layer I zoom in really fast, I see the new tiles render, but just underneath, is the old one, and it only disappears upon panning the map (or natural rebuild).

Interestingly, even with a large keepBuffer value, and after panning and zooming to "precache" those images, the same behavior is still observed.

mootw commented 1 month ago

I am able to replicate this behavior on the latest release, however once tiles are cached they do instantly update and load when the new zoom level is reached. Its only tiles that are not cached that experience this issue. Panning "fixes" both zoom levels of tiles being loaded at the same time and unloads the lower zoom level

JaffaKetchup commented 5 days ago

For workaround (very much a workaround) see https://discord.com/channels/951867686378409984/1215063056208633897/1258228136810647604.