p-lr / MapView

A Fast, memory efficient Android library to display tiled maps, with support for markers, paths, and rotation.
Apache License 2.0
189 stars 38 forks source link

Fixed redrawTiles not working #45

Closed artudi54 closed 12 months ago

artudi54 commented 12 months ago

Hello

Since the commit ee06fba22a9fe4f6c2a67a095fdb1ed9d70938f8 function redrawTiles stopped working.

I managed to find the reason for this. In the old code in the function CoroutineScope.worker instruction tilesDownloaded.send(spec) was always called, regardless of the bitmap being succesfully loaded or not. It was placed inside finally block, so whether we got null bitmap and called continue, or we got an exception it was called for every tile.

In the current implementation it is only called when we get the bitmap correctly. Current behaviour causes redrawTiles to not work (at least for me). I adjusted the code accordingly, to bring back the old behaviour, while leaving the new load algorithm intact and it seems to have solved the issue.

I don't know exactly what those channels are doing, I just found an issue and a possible fix for it. If you have a better solution than this one, then feel free to do it your own way.

Best regards

p-lr commented 12 months ago

Hello,

You're right, the design is the tilesDownloaded.send(spec) should always be called, because the "tileCollectorKernel" actor keeps track of which tile is being processed. Without tilesDownloaded.send(spec) being called, subsequent attempts to download the tile will be skipped. So I inadvertently broke this contract in the commit you linked.

Thanks!

artudi54 commented 12 months ago

Thanks for the quick merge. Could you release a new version with this fix? I could then include it in my app.

p-lr commented 12 months ago

Yes, I've just published 3.1.8 on mavencentral. It may take one hour or so to be available.