Skip to content

Commit

Permalink
Don't call tile.added() for tiles that have been removed from the ren…
Browse files Browse the repository at this point in the history
…der tree.

Fixes issue #5837, which could cause symbols to be incorrectly hidden.
  • Loading branch information
ChrisLoer committed Dec 14, 2017
1 parent 63fba0d commit d759da6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/source/source_cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,11 @@ class SourceCache extends Evented {
if (this.map) this.map.painter.tileExtentVAO.vao = null;

this._updatePlacement();
if (this.map)
if (this.map && this.getTileByID(id)) {
// Only add this tile to the CrossTileSymbolIndex if it is still in the retain set
// See issue #5837
tile.added(this.map.painter.crossTileSymbolIndex);
}
}

/**
Expand Down
17 changes: 17 additions & 0 deletions test/unit/source/source_cache.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,23 @@ test('SourceCache#removeTile', (t) => {
t.end();
});

t.test('_tileLoaded after _removeTile skips tile.added', (t) => {
const tileID = new OverscaledTileID(0, 0, 0, 0, 0);

const sourceCache = createSourceCache({
loadTile: function(tile, callback) {
tile.added = t.notOk();
sourceCache._removeTile(tileID.key);
callback();
}
});
sourceCache.map = { painter: { crossTileSymbolIndex: "", tileExtentVAO: {} } };

sourceCache._addTile(tileID);

t.end();
});

t.end();
});

Expand Down

0 comments on commit d759da6

Please sign in to comment.