diff --git a/CHANGELOG.md b/CHANGELOG.md index 589e31794d..53b4f343b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ - Reduce rendering calls on initial load. No reason to try rendering before style is loaded. ([#2464](https://github.com/maplibre/maplibre-gl-js/pull/2464)) - Lazy load default style properties on demand to improve loading performance and reduce memory usage. ([#2476](https://github.com/maplibre/maplibre-gl-js/pull/2476)) - Replace playwright with puppeteer ([#2494](https://github.com/maplibre/maplibre-gl-js/pull/2494)) +- Revert ([#2377](https://github.com/maplibre/maplibre-gl-js/pull/2377)), as it is causing raster tiles to not load in certain scenarios when user do a fast zoom operation using mouse wheel. - _...Add new stuff here..._ ### 🐞 Bug fixes diff --git a/src/source/source_cache.test.ts b/src/source/source_cache.test.ts index e9aa8ebaef..cad705e23e 100644 --- a/src/source/source_cache.test.ts +++ b/src/source/source_cache.test.ts @@ -1267,84 +1267,6 @@ describe('SourceCache#_updateRetainedTiles', () => { }); - test('Only retain loaded parent tile when zooming in', () => { - const sourceCache = createSourceCache({ - loadTile(tile, callback) { - tile.state = 'loading'; - callback(); - } - }); - - let idealTiles = [new OverscaledTileID(9, 0, 9, 0, 0), new OverscaledTileID(9, 0, 9, 1, 0)]; - let retained = sourceCache._updateRetainedTiles(idealTiles, 9); - // Parent loading tiles from z=8 not retained - expect(Object.keys(retained).sort()).toEqual( - idealTiles.map((tile) => tile.key).sort() - ); - - idealTiles = [new OverscaledTileID(10, 0, 10, 0, 0), new OverscaledTileID(10, 0, 10, 1, 0)]; - retained = sourceCache._updateRetainedTiles(idealTiles, 10); - // Parent loading tiles from z=9 not retained - expect(Object.keys(retained).sort()).toEqual( - idealTiles.map((tile) => tile.key).sort() - ); - - const loadedTiles = idealTiles; - loadedTiles.forEach(t => { - sourceCache._tiles[t.key] = new Tile(t, undefined); - sourceCache._tiles[t.key].state = 'loaded'; - }); - - idealTiles = [new OverscaledTileID(11, 0, 11, 0, 0), new OverscaledTileID(11, 0, 11, 1, 0)]; - retained = sourceCache._updateRetainedTiles(idealTiles, 11); - // Parent loaded tile in the view port from z=10 was retained - expect(Object.keys(retained).sort()).toEqual([ - new OverscaledTileID(10, 0, 10, 0, 0).key, // Parent loaded tile - new OverscaledTileID(11, 0, 11, 0, 0).key, - new OverscaledTileID(11, 0, 11, 1, 0).key - ].sort()); - - }); - - test('Only retain loaded child tile when zooming out', () => { - const sourceCache = createSourceCache({ - loadTile(tile, callback) { - tile.state = 'loading'; - callback(); - } - }); - - let idealTiles = [new OverscaledTileID(7, 0, 7, 0, 0), new OverscaledTileID(7, 0, 7, 1, 0)]; - let retained = sourceCache._updateRetainedTiles(idealTiles, 7); - // Client tiles from z=6 not retained - expect(Object.keys(retained).sort()).toEqual( - idealTiles.map((tile) => tile.key).sort() - ); - - idealTiles = [new OverscaledTileID(6, 0, 6, 0, 0), new OverscaledTileID(6, 0, 6, 1, 0)]; - retained = sourceCache._updateRetainedTiles(idealTiles, 6); - // Client tiles from z=6 not retained - expect(Object.keys(retained).sort()).toEqual( - idealTiles.map((tile) => tile.key).sort() - ); - - const loadedTiles = idealTiles; - loadedTiles.forEach(t => { - sourceCache._tiles[t.key] = new Tile(t, undefined); - sourceCache._tiles[t.key].state = 'loaded'; - }); - - idealTiles = [new OverscaledTileID(5, 0, 5, 0, 0), new OverscaledTileID(5, 0, 5, 1, 0)]; - retained = sourceCache._updateRetainedTiles(idealTiles, 5); - // Child loaded tile in the view port from z=6 was retained - expect(Object.keys(retained).sort()).toEqual([ - new OverscaledTileID(6, 0, 6, 0, 0).key, - new OverscaledTileID(6, 0, 6, 1, 0).key, - new OverscaledTileID(5, 0, 5, 0, 0).key, - new OverscaledTileID(5, 0, 5, 1, 0).key - ].sort()); - }); - test('adds correct loaded parent tiles for overzoomed tiles', () => { const sourceCache = createSourceCache({ loadTile(tile, callback) { diff --git a/src/source/source_cache.ts b/src/source/source_cache.ts index 82badba4bb..bb043aabba 100644 --- a/src/source/source_cache.ts +++ b/src/source/source_cache.ts @@ -717,14 +717,11 @@ class SourceCache extends Evented { tile = this._addTile(parentId); } if (tile) { - const hasData = tile.hasData(); - if (parentWasRequested || hasData) { - retain[parentId.key] = parentId; - } + retain[parentId.key] = parentId; // Save the current values, since they're the parent of the next iteration // of the parent tile ascent loop. parentWasRequested = tile.wasRequested(); - if (hasData) break; + if (tile.hasData()) break; } } }