-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Edge padding should not be persisted as content insets #15233
Comments
@1ec5 ,
#14664 made CameraOptions.withPadding(const optional& p) persistent, as all other camera options (pitch, bearing, zoom...). The behavior of implementation before #14664, threating CameraOptions padding as transient was problematic for cases where user specifies value for CameraOptions.withCenter, but supplied padding alters position (bakes padding to new center) to something else and reset padding to 0. After #14664, it is not feasible to have it transient because of asymmetric viewport: if there is pitch on map, when padding animation (e.g. easeTo) animates perspective center to new position, we cannot just jump center of perspective back. Neither we should to it - API defined that easeTo() should lead to specified camera padding (perspective center). This is related to #15232 (comment). |
I think this is a misinterpretation of the term “edge padding” as used on iOS up to now: edge padding was never supposed to affect the vanishing point; only the content insets would do that. If edge padding must affect the vanishing point and be persisted, then the iOS map SDK needs to move off that parameter in favor of a separate parameter that only affects how the center point is calculated. In short, edge padding is a way to say “this screen coordinate should correspond to this geographic coordinate”. It just happens to be defined in terms of padding, but in a future major release, perhaps we could express it as an anchor instead, like we do internally for zooming and rotating. |
Let's discuss on about separate method. Padding is used for iOS's MGLMapView.contentInset (non user tracking mode) and Android's setPadding. Those use jumpTo/flyTo and it has persistent nature. Would CameraOptions.withAnchorAt(ScreenCoordinate, LatLng) implement the desired behavior? |
Yes, I think
Would that work correctly even if the camera changes the pitch, rotation, or zoom level? |
This issue also affects some operations internal to MGLMapView. For example, mapbox-gl-native/platform/ios/src/MGLMapView.mm Lines 5055 to 5059 in b6dd995
When course tracking is turned on, Meanwhile, I think mapbox-gl-native/platform/ios/src/MGLMapView.mm Line 3162 in 6f0cda8
mapbox-gl-native/platform/ios/src/MGLMapView.mm Line 3582 in 6f0cda8
|
I debugged the code and it is also induced by expanded top banner - mapbox/mapbox-navigation-ios#2165 The attached video shows the behavior: In code, this causes relayout and then a change in content insets in RouteMapViewController viewDidLayoutSubviews For a brief period, instructionBannerHeight gets changed, increasing and then decreasing content insets. Note that, as of #14664, content insets also became animatable property... and that is what we see with puck position animated back. This is why I'm thinking that the best solution for this is to fix content insets in mapbox-navigation-ios during navigation - if you're fine with it, could work on proposing a patch. |
Note that the issue reproduces even if the user never interacts with the top banner and the top banner never expands. |
If you have a video prepared, please attach. I used println for analysis, and noticed a short change in instructionBannerHeight, even though the "turn left" or "turn right" banner expansion is not visible. I'm working on patch for it and let's verify it after... |
Decouple dependency content insets -> anchor point -> padding/content insets broken after mapbox/mapbox-gl-native#14664 introduced animated interpolation for padding change. Remove the need to specify center for puck view - use the approach where content inset is keeping it centered. Take safeArea into account when calculating contentInsets. Addresses: mapbox/mapbox-gl-native#15232, mapbox/mapbox-gl-native#15233 Related to: #2165, Fixes: #2145
Please check PR to navigation-ios Simplify anchor point calculation and puck centering #2211 . This is a change of anchor and padding handling in navigation-ios. You also mentioned that there is a need to inform another customer potentially copying the same anchor point - padding approach as it is in navigation-ios. |
Here’s a screen recording of navigation SDK v0.36.0 with map SDK v5.2.0 in an iPhone 8 / iOS 12.4 simulator simulating a route from 39.10128°N, 84.51134°W to 39.09784°N, 84.51383°W along Walnut, Fourth, and Race streets. The puck is in the correct place at all times, but the camera is positioned incorrectly with respect to the puck. Watch as the camera pivots around the intersection while the puck is floating a certain screen distance above it. From the point of view of a consumer of the map SDK, there should be nothing wrong with positioning a view at a screen coordinate and independently centering the camera over that same screen coordinate using a padding.
mapbox/mapbox-navigation-ios#2165 is a red herring – please disregard. The only reason it came up was because the developer thought it was related to a bug in the step list, which is wholly independent of the map view.
When a “then” banner appears and disappears, the combined height of the top bars does change, and the map view’s visual center and the puck’s position should change as a result. Admittedly it is suboptimal that the map only gets recentered upon the next location update, not immediately when the content insets change, but that’s orthogonal to this issue.
To reiterate: from the perspective of the iOS/macOS map SDK’s public API, ignoring mbgl, the Taking a step back, the rationale for an edge padding property is to ensure that the What we’ve learned since #3583, particularly bf87eaa, is that developers normally want the ability to specify an anchor point (in screen coordinates) for the center (geographic) coordinate. Expressing it as edge padding is actually less direct. So if |
The screenshot is from attached video. This doesn't look correct - is it supposed to be like that? I assumed it is supposed to be like in attached screenshot (this is behavior with mapbox/mapbox-navigation-ios#2211):
It is triggering issue with position (padding animation introduced with #14664) kicks in. The problem is not visible after mapbox/mapbox-navigation-ios#2211 |
Noticed. This is fixed by mapbox/mapbox-navigation-ios#2211. |
Need help with this:
Padding and content inset are not fused in MGLMapView - MGLMapView holds value of specified content inset and adds additional supplied padding. What is the use case where reset in completion handler is needed - is there an existing code I could check? Thanks. |
The video depicts the current broken state as of navigation SDK v0.36.0 and map SDK v5.2.0, not how it’s supposed to look. The puck is in the correct position but the camera is wrong. |
This code modifies mapbox-gl-native/src/mbgl/map/transform.cpp Lines 310 to 315 in b6dd995
The next time I think what you’re saying is that the
|
Decouple dependency content insets -> anchor point -> padding/content insets broken after mapbox/mapbox-gl-native#14664 introduced animated interpolation for padding change. Remove the need to specify center for puck view - use the approach where content inset is keeping it centered. Take safeArea into account when calculating contentInsets. Addresses: mapbox/mapbox-gl-native#15232, mapbox/mapbox-gl-native#15233 Related to: #2165, Fixes: #2145
Decouple dependency content insets -> anchor point -> padding/content insets broken after mapbox/mapbox-gl-native#14664 introduced animated interpolation for padding change. Remove the need to specify center for puck view - use the approach where content inset is keeping it centered. Take safeArea into account when calculating contentInsets. Addresses: mapbox/mapbox-gl-native#15232, mapbox/mapbox-gl-native#15233 Related to: #2165, Fixes: #2145
The most straightforward fix for this issue would be for The iOS/macOS map SDK’s If the idea of a “center offset” is anathema, then we should find a way to decouple the Until then, the fact that |
As of #14664, if a padding (
CameraOptions.padding
) is explicitly passed into eithereaseTo()
andflyTo()
, mbgl persists that padding as the content insets (TransformState.edgeInsets
):mapbox-gl-native/src/mbgl/map/transform.cpp
Lines 146 to 151 in b6dd995
mapbox-gl-native/src/mbgl/map/transform.cpp
Lines 310 to 315 in b6dd995
Content insets are supposed to be persistent, but edge padding is supposed to be transient for the duration of a single camera change operation. In other words, edge padding is supposed to only affect the frame of reference for a camera, not directly influence the map’s overall state.
Because mbgl conflates edge padding with content insets, it isn’t possible to work around #15232 by manually passing in the content inset plus a padding. Now the developer has to reset the content inset in the camera change operation’s completion handler.
/cc @astojilj @mapbox/maps-ios @mapbox/navigation-ios @d-prukop
The text was updated successfully, but these errors were encountered: