Skip to content

Prevent multiple symbols at the same zoom from sharing a crossTileID - #5994

Merged
ChrisLoer merged 1 commit into
masterfrom
cloer-5993
Jan 16, 2018
Merged

ChrisLoer merged 1 commit into
masterfrom
cloer-5993

Conversation

@ChrisLoer

Copy link
Copy Markdown
Contributor

Fixes issue #5993, which would allow multiple symbols in a tile to share the same crossTileID as one of their duplicate parent-tile symbols. Once the symbols shared a crossTileID, they would permanently remain "duplicates" of each other, even after increasing zoom level allowed the CrossTileSymbolIndex to distinguish between them.

This change introduces some extra work on removing a bucket (since we have to iterate through all symbol instances removing their crossTileIDs from the index), but it doesn't really show up in benchmarks. However, running the Chrome javascript profiler while doing pan and zoom operations, I'm seeing removeStaleBuckets taking .5-1.5% of CPU time, which seems tolerable but still pretty concerning. Since there's no time urgency on the pruning, maybe we can set up a separate pruning function that we just run once every N minutes/iterations/frames?

On top of the unit test, I tested by manually exercising the "chinese.html" debug page with the keys all set to the same value. I watched to see how crossTileIDs got assigned and watched that usedCrossTileIDs wasn't growing without bound.

@friedbunny once we get this in we'll port it over to native to fix the original annotation view bug.

/cc @ansis

@ChrisLoer
ChrisLoer requested a review from ansis January 12, 2018 22:53
@ChrisLoer

Copy link
Copy Markdown
Contributor Author

I put together a commit that does periodic pruning instead of doing the pruning during removeStaleBuckets, but it didn't actually make removeStaleBuckets run that much faster -- I guess what that probably means is the "there's nothing to remove" part of removeStaleBuckets is more expensive than the case where we actually have to remove something. So I think the deferred pruning commit probably isn't worth the (mild) extra complexity

@ansis ansis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good to me!

Comment thread src/symbol/cross_tile_symbol_index.js Outdated
const zoomIndexes = this.indexes[z];
for (const tileKey in zoomIndexes) {
if (!currentIDs[zoomIndexes[tileKey].bucketInstanceId]) {
for (const key of Object.keys(zoomIndexes[tileKey].indexedSymbolInstances)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is there an advantage to using for (const key of Object.keys(z)) instead of for (const key in z)) in this case?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't think so, it's just left over from an earlier implementation I tried iterating over Object.entries. I'll update it to the simpler form.

Fixes issue #5993, which would allow multiple symbols in a tile to share the same crossTileID as one of their duplicate parent-tile symbols. Once the symbols shared a crossTileID, they would permanently remain "duplicates" of each other, even after increasing zoom level allowed the CrossTileSymbolIndex to distinguish between them.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants