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

Render raster loop #3399

Merged
merged 3 commits into from
Dec 23, 2016
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
14 changes: 10 additions & 4 deletions js/source/source_cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,8 @@ class SourceCache extends Evented {
return tile;
}
if (this._cache.has(coord.id)) {
this.addTile(coord);
retain[coord.id] = true;
return this._tiles[coord.id];
return this._cache.get(coord.id);
}
}
}
Expand Down Expand Up @@ -288,6 +287,7 @@ class SourceCache extends Evented {
let i;
let coord;
let tile;
let parentTile;

this.updateCacheSize(transform);

Expand Down Expand Up @@ -332,7 +332,10 @@ class SourceCache extends Evented {
// The tile we require is not yet loaded.
// Retain child or parent tiles that cover the same area.
if (!this.findLoadedChildren(coord, maxCoveringZoom, retain)) {
this.findLoadedParent(coord, minCoveringZoom, retain);
parentTile = this.findLoadedParent(coord, minCoveringZoom, retain);
if (parentTile) {
this.addTile(parentTile.coord);
}
}
}

Expand All @@ -348,7 +351,10 @@ class SourceCache extends Evented {
if (this.findLoadedChildren(coord, maxCoveringZoom, retain)) {
retain[id] = true;
}
this.findLoadedParent(coord, minCoveringZoom, parentsForFading);
parentTile = this.findLoadedParent(coord, minCoveringZoom, parentsForFading);
if (parentTile) {
this.addTile(parentTile.coord);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove this.addTile from findLoadedParent and then add it to all the call sites of findLoadedParent?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

findLoadedParent() is also called from within draw_raster.js. It was important not to call addTile again from there to avoid the the render loop. We could have fixed this another way but this seemed to make the most sense given the name findLoadedParent() I wouldn't have expected it to retain a tile.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. This makes sense 👍

}
}

Expand Down
3 changes: 1 addition & 2 deletions test/js/source/source_cache.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ test('SourceCache#findLoadedParent', (t) => {
t.end();
});

t.test('adds from cache', (t) => {
t.test('retains parents', (t) => {
const sourceCache = createSourceCache({});
sourceCache.onAdd();
const tr = new Transform();
Expand All @@ -756,7 +756,6 @@ test('SourceCache#findLoadedParent', (t) => {
t.equal(sourceCache.findLoadedParent(new TileCoord(2, 0, 0), 0, retain), tile);
t.deepEqual(retain, expectedRetain);
t.equal(sourceCache._cache.order.length, 0);
t.equal(sourceCache._tiles[tile.coord.id], tile);

t.end();
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test that triggers the render raster loop to ensure this behavior does not regress?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can try

Expand Down