-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[core] Fix collision with content insets #15130
Conversation
Viewport center offset usage was wrongly submitted in #14664. It was part of alternative approach that used enlarged viewport. Existing and added tests were not sufficient to spot the regression, since the collision check padding is usually larger than the center offset x and y. Annotation picking has tolerance of only 10 pixels but no annotation integration test was using content insets. Usage of offset is not needed because `posMatrix` in e.g. `CollisionIndex::projectPoint(const mat4& posMatrix, const Point<float>& point)` already incorporates center offset (projection matrix) and the code in current master was just offsetting all by the value. Modified [ios] MGLAnnotationViewIntegrationTests.testSelectingAnnotationWithCenterOffset to use different insets. It verifies the fix. Fixes [iOS] Annotations are not selectable (added via iosapp menu) #15106: In case of #15106, view's original content insets is {top:88, bottom:34}, causing that center offset is {x:0, y:27} and selection with tolerance of 10 wouldn't select annotation. After tapping the view, so that the header gets removed, view's content insets get changed to {top:44, bottom:34}, center offset is {x:0, y:5} and annotation selection would work, as described in #15106. Fixes: #15106
This is labelled as |
Does this fix have any visual impact on client code that remains unchanged but upgrades to include this fix? We should test this change against the iOS navigation SDK to ensure that it doesn’t cause any regressions. The navigation SDK (and applications that integrate it) are heavy users of content insets, particularly in landscape orientation and on CarPlay. /cc @d-prukop |
Did this issue also arise on @mapbox/maps-android? |
@julianrex, @chloekraw, |
Yes. Verified that without this patch, Android demo app doesn't show "Center map" annotation title when tapping the symbol. Screenshot taken with the fix integrated. |
@1ec5, Other than that, it is about annotation selection: on annotation selection, collision rectangle dimensions are 10px. I don't know if we there are other selecting item on tap features, that could be affected. |
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.
LGTM
Thanks for digging further into this, @astojilj. I (somewhat unilaterally 😅) tagged this as a I’m concerned that existing tests in core and Android didn’t detect this, and I think this further reinforces the need for comprehensive tests to be written on iOS (#14827). |
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.
This needs a change log.
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.
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.
Viewport center offset usage was wrongly submitted in #14664. It was part of alternative approach that used enlarged viewport. Existing and added tests were not sufficient to spot the regression, since the collision check padding is usually larger than the center offset x and y. Annotation picking has tolerance of only 10 pixels but no annotation integration test was using content insets.
Usage of offset is not needed because
posMatrix
in e.g.CollisionIndex::projectPoint(const mat4& posMatrix, const Point<float>& point)
already incorporates center offset (projection matrix) and the code in current master was just offsetting all by the value.Modified [ios] MGLAnnotationViewIntegrationTests.testSelectingAnnotationWithCenterOffset to use different insets. It verifies the fix.
Fixes [iOS] Annotations are not selectable (added via iosapp menu) #15106:
In case of #15106, view's original content insets is {top:88, bottom:34}, causing that center offset is {x:0, y:27} and selection with tolerance of 10 wouldn't select annotation.
After tapping the view, so that the header gets removed, view's content insets get changed to {top:44, bottom:34}, center offset is {x:0, y:5} and annotation selection would work, as described in #15106.
Fixes: #15106