zeta243 / osmdroid

Automatically exported from code.google.com/p/osmdroid
1 stars 0 forks source link

Fix for "stuck" tiles never loading #335

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
There is an issue where, after scrolling a long distance, tiles will get 
"stuck" and will never load.

Each tile provider has a pending queue that is implemented as a 
Least-Recently-Used queue. If too many tile requests queue up, then the oldest 
requests are discarded since they are likely no longer needed. The queue's 
limit is rarely reached since most tile providers can keep up with the 
requests, but if you scroll very fast then the download queue can grow to 
exceed the queue and that causes pending tiles to be dropped. The current code 
simply discards the pending tile requests. This is incorrect, since what is 
really happening is that the tile request has failed so it is imperative that 
we notify the Array provider that the request failed otherwise it will always 
assume that the tile request is still alive and queued for handling.

So the fix for this problem is to change MapTileModuleProviderBase, at line 99 
change removeEldestEntry to be:

    @Override
    protected boolean removeEldestEntry(
        final Map.Entry<MapTile, MapTileRequestState> pEldest) {
           if (size() > pPendingQueueSize) {
               removeTileFromQueues(pEldest.getKey());
               pEldest.getValue().getCallback().mapTileRequestFailed(pEldest.getValue());
           }
           return false;
        }

I will allow a short time for review and then commit the fix early next week. I 
have been running this patch for a while, and it solves the issue described 
above.

Original issue reported on code.google.com by kurtzm...@gmail.com on 6 Apr 2012 at 8:26

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r1090.

Original comment by kurtzm...@gmail.com on 9 Apr 2012 at 9:08

GoogleCodeExporter commented 9 years ago
I m using osmdroid-android-3.0.7.jar.So how can i fix this problem :S

Original comment by muratkar...@gmail.com on 19 Apr 2012 at 1:16