Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make sure worker sends response after reloading 'empty' tile #7355

Merged
merged 1 commit into from
Oct 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/source/vector_tile_worker_source.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ class VectorTileWorkerSource implements WorkerSource {
delete this.loading[uid];

if (err || !response) {
workerTile.status = 'done';
this.loaded[uid] = workerTile;

This comment was marked as resolved.

return callback(err);
}

Expand Down Expand Up @@ -163,7 +165,12 @@ class VectorTileWorkerSource implements WorkerSource {
if (workerTile.status === 'parsing') {
workerTile.reloadCallback = done;
} else if (workerTile.status === 'done') {
workerTile.parse(workerTile.vectorTile, this.layerIndex, this.actor, done);
// if there was no vector tile data on the initial load, don't try and re-parse tile
if (workerTile.vectorTile) {
workerTile.parse(workerTile.vectorTile, this.layerIndex, this.actor, done);
} else {
done();
}
}
}
}
Expand Down
24 changes: 24 additions & 0 deletions test/unit/source/vector_tile_worker_source.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ test('VectorTileWorkerSource#reloadTile reloads a previously-loaded tile', (t) =
source.loaded = {
'0': {
status: 'done',
vectorTile: {},
parse
}
};
Expand All @@ -79,6 +80,7 @@ test('VectorTileWorkerSource#reloadTile queues a reload when parsing is in progr
source.loaded = {
'0': {
status: 'done',
vectorTile: {},
parse
}
};
Expand Down Expand Up @@ -112,6 +114,7 @@ test('VectorTileWorkerSource#reloadTile handles multiple pending reloads', (t) =
source.loaded = {
'0': {
status: 'done',
vectorTile: {},
parse
}
};
Expand Down Expand Up @@ -152,6 +155,27 @@ test('VectorTileWorkerSource#reloadTile handles multiple pending reloads', (t) =
t.end();
});

test('VectorTileWorkerSource#reloadTile does not reparse tiles with no vectorTile data but does call callback', (t) => {
const source = new VectorTileWorkerSource(null, new StyleLayerIndex());
const parse = t.spy();

source.loaded = {
'0': {
status: 'done',
parse
}
};

const callback = t.spy();

source.reloadTile({ uid: 0 }, callback);
t.ok(parse.notCalled);
t.ok(callback.calledOnce);

t.end();
});


test('VectorTileWorkerSource provides resource timing information', (t) => {
const rawTileData = fs.readFileSync(path.join(__dirname, '/../../fixtures/mbsv5-6-18-23.vector.pbf'));

Expand Down