Skip to content

Commit

Permalink
fix #8705 actor error after map is removed (#8711) (#8723)
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
mourner authored Sep 4, 2019
1 parent d9ea3b7 commit a0f715d
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 a0f715d

Please sign in to comment.