Skip to content

Commit

Permalink
Reverted PR maplibre#2377
Browse files Browse the repository at this point in the history
  • Loading branch information
pramik committed May 9, 2023
1 parent e50e273 commit 208df03
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 83 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
78 changes: 0 additions & 78 deletions src/source/source_cache.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
7 changes: 2 additions & 5 deletions src/source/source_cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
Expand Down

0 comments on commit 208df03

Please sign in to comment.