Skip to content

Commit

Permalink
Track the number of tiles loading since loading had finished previously
Browse files Browse the repository at this point in the history
  • Loading branch information
gkjohnson committed Jan 11, 2025
1 parent 8d4c7bd commit 836c2f6
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/base/TilesRendererBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export class TilesRendererBase {
this.fetchOptions = {};
this.plugins = [];
this.queuedTiles = [];
this.cachedSinceReset = new Set();

const lruCache = new LRUCache();
lruCache.unloadPriorityCallback = lruPriorityCallback;
Expand All @@ -125,6 +126,7 @@ export class TilesRendererBase {
this.downloadQueue = downloadQueue;
this.parseQueue = parseQueue;
this.stats = {
inCacheSinceReset: 0,
inCache: 0,
parsing: 0,
downloading: 0,
Expand Down Expand Up @@ -642,6 +644,13 @@ export class TilesRendererBase {

// Decrement stats
stats.inCache --;
if ( this.cachedSinceReset.has( tile ) ) {

this.cachedSinceReset.delete( tile );
stats.inCacheSinceReset --;

}

if ( t.__loadingState === LOADING ) {

stats.downloading --;
Expand All @@ -666,6 +675,8 @@ export class TilesRendererBase {

}

this.cachedSinceReset.add( tile );
stats.inCacheSinceReset ++;
stats.inCache ++;
stats.downloading ++;
tile.__loadingState = LOADING;
Expand Down Expand Up @@ -809,6 +820,16 @@ export class TilesRendererBase {

}

} )
.finally( () => {

if ( stats.parsing === 0 && stats.downloading === 0 ) {

this.cachedSinceReset.clear();
stats.inCacheSinceReset = 0;

}

} );

}
Expand Down

0 comments on commit 836c2f6

Please sign in to comment.