-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
View / safeguard against negative hint values to avoid unexpected behaviour #14545
View / safeguard against negative hint values to avoid unexpected behaviour #14545
Conversation
📦 Preview the website for this branch here: https://deploy-preview-14545--ol-site.netlify.app/. |
72b5908
to
54c88fb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @jahow for taking a stab at this. It looks like your fix is a cure for the symptoms, but not for the root of the problem. In the first place. the view hints should never have a negative value. I'm not sure if it is enough to change endInteractionInternal()
to not go below zero, or if the observed behavior is a sign of a more severe problem.
For now, it would probably be ok to safeguard the hints against going below zero, but I'd sleep better if interaction handling would work in a way that the hints would never go below zero without a safeguard.
IIRC the I agree that this fix isn't great -- especially because other parts of the lib also rely on view hints being specifically zero instead of zero and less. |
Ah, I see now! I hadn't read the original issue closely enough. So for this case, I think it is enough to safeguard |
54c88fb
to
1f8f188
Compare
I modified the PR to add the safeguard at the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a better place to add a safeguard would be the API method endInteraction()
, by means of checking for getInteracting()
. Internally, I hope/think we do things correctly, and we could add a test to ensure that the hint is always >= 0
. Otherwise I fear this is prone to problems that are hard to debug.
afbc124
to
abe5289
Compare
This could happen in case `view.endInteraction()` was called too many times, which might cause unexpected behaviours with logic relying on hints being zero or more.
abe5289
to
49f1fe0
Compare
@ahocevar went with your suggestion! I think this contributes to make the view API safer to use. |
OpenLayers could output a warning in this case. It's a bug in application code, but maybe shouldn't be ignored silently. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me, this looks great now. Thanks, @jahow !
I think making it more permissive is not unreasonable, people might end up writing custom interactions which use begin/endInteraction liberally and calling endInteraction too many times shouldn't cause any serious issue with this PR. |
Apologies for approving without reading the existing discussion. I think this ended up in a good place. |
This could happen e.g. in case
view.endInteraction()
was used too many times, which then might cause unexpected behaviours in dependent logic such as the webgl points renderer.Fixes #14544