Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

[core] Synchronize state of CollisionIndex and FeatureIndexes. - #10950

Merged
ChrisLoer merged 2 commits into
masterfrom
cloer-10778
Jan 18, 2018
Merged

ChrisLoer merged 2 commits into
masterfrom
cloer-10778

Conversation

@ChrisLoer

Copy link
Copy Markdown
Contributor

Fixes issue #10778, in which mismatch between FeatureIndex and CollisionIndex could lead to inconsistent results or even invalid array access.

The expected behavior after this change is that the FeatureIndexes used by queryRenderedFeatures will only update at the same time placement finishes and the CollisionIndex is updated. This means the results will always be valid, and there shouldn't be any "flickering" in which a symbol disappears from query results in between the time a tile updates and the time the next placement happens. For non-symbol features, this change opens a gap between when they start being rendered (as soon as the tile loads) and when they show up in query results (when placement happens).

This approach relies on placement happening all at once, so we can't port it directly to GL JS (and if we implement partial placement on gl-native we'll have to adjust this). I think a fuller solution would have the CollisionIndex either outright own the data it needs to return (too bulky?) or maybe have some form of shared ownership.

I don't have a good strategy for measuring the performance impact, but I think it should be pretty minimal -- it's basically just a delete gets deferred by up to 300ms when a tile updates.

I also don't know a great way to test this, since the flaw depends on precise timing and the logic isn't contained to a single unit. 😕

/cc @ansis

Fixes issue #10778, in which mismatch between FeatureIndex and CollisionIndex could lead to inconsistent results or even invalid array access.
@ChrisLoer
ChrisLoer requested a review from ansis January 17, 2018 22:56

@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.

I don't have any good ideas about testing this

I still think the long term ideal solution is to make symbol querying not rely on CollisionIndex but thats a significant task.

@ChrisLoer

Copy link
Copy Markdown
Contributor Author

There's another subtle change here, which is that querySourceFeatures avaibility is delayed to match the timing of queryRenderedFeatures. Although that's not strictly necessary for valid results, it seems like reasonable/consistent behavior to me.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants