Skip to content

Commit

Permalink
fix mapbox#8705 actor error after map is removed (mapbox#8711)
Browse files Browse the repository at this point in the history
If a tile was reloaded shortly before a `map.remove()`, raster tiles
that were in the middle of being loaded would not be aborted leading to
an error when the tried to work with the removed map.

The problem applies to removing and reloading tile.
  • Loading branch information
ansis authored and Stepan Kuzmin committed Sep 9, 2019
1 parent 77459cd commit 0ce48ec
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/source/source_cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ class SourceCache extends Evented {
if (tile.uses > 0)
return;

if (tile.hasData()) {
if (tile.hasData() && tile.state !== 'reloading') {
this._cache.add(tile.tileID, tile, tile.getExpiryTimeout());
} else {
tile.aborted = true;
Expand Down
4 changes: 4 additions & 0 deletions src/util/dispatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import {uniqueId, asyncAll} from './util';
import Actor from './actor';
import assert from 'assert';

import type WorkerPool from './worker_pool';

Expand Down Expand Up @@ -32,12 +33,14 @@ class Dispatcher {
actor.name = `Worker ${i}`;
this.actors.push(actor);
}
assert(this.actors.length);
}

/**
* Broadcast a message to all Workers.
*/
broadcast(type: string, data: mixed, cb?: Function) {
assert(this.actors.length);
cb = cb || function () {};
asyncAll(this.actors, (actor, done) => {
actor.send(type, data, done);
Expand All @@ -49,6 +52,7 @@ class Dispatcher {
* @returns An actor object backed by a web worker for processing messages.
*/
getActor(): Actor {
assert(this.actors.length);
this.currentActor = (this.currentActor + 1) % this.actors.length;
return this.actors[this.currentActor];
}
Expand Down

0 comments on commit 0ce48ec

Please sign in to comment.