Rework handling of skipped features in replay #1990
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There is a bug in the handling of skipped features in the canvas replay when replaying the hit detection instructions. This PR aims at fixing the bug.
Description of the issue:
Currently the canvas replay uses the
instructionIndices_
object to store instruction index/feature uid pairs and be able to get the feature uid for an (begin geometry) instruction and know when a feature/geometry should be skipped. See https://github.com/openlayers/ol3/blob/master/src/ol/render/canvas/canvasreplay.js#L256-L261.But this doesn't work when replaying the batch for feature detection. For feature detection the replay indeed uses a specific instruction arrays (
hitDetectionInstructions
), so the instruction indices stored ininstructionIndices_
are not valid for hit detection. So with the current code, when replaying the instructions for hit detection, features that should not be skipped may be skipped, and features that should be skipped may not be skipped.The problem can easily be reproduced with just three point features in a vector layer and a select interaction. It's much more difficult to reproduce when the vector layer has many features (because you must be unlucky enough to find a problematic pair of features).
This PR fixes the bug by removing the
instructionIndices_
object entirely and storing the references to features in the begin geometry instructions. This simplifies the code and makes "skip feature" work with hit detection as well.