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

Content insets and edge padding should be additive, not mutually exclusive #15232

Closed

Description

@1ec5

By design, a camera’s edge padding and the map’s content insets are supposed to be additive: every camera change operation is relative to the content insets, and the edge padding can further inset the camera.

In #12818, the -[MGLMapView setCamera:withDuration:animationTimingFunction:edgePadding:completionHandler:] method incorrectly treated the edge padding and content insets as mutually exclusive. If the developer left the edge padding unspecified when changing the camera, then MGLMapView would correctly consider just the content insets. But if the developer passes in an edge padding, MGLMapView would incorrectly ignore the content insets in favor of the edge padding alone. Clients (including the navigation SDK) worked around the bug by explicitly adding the content insets to the edge padding.

#14813 fixed this issue for v5.1.0, but in the same release, #14664 regressed it in mbgl and expanded the issue to flight animations as well:

const EdgeInsets& padding = camera.padding.value_or(state.edgeInsets);
const EdgeInsets& padding = camera.padding.value_or(state.edgeInsets);

/cc @astojilj @mapbox/maps-ios @mapbox/navigation-ios @d-prukop

Activity

  1. added
    Core
    on Jul 26, 2019
  2. added this to the release-queso milestone on Jul 26, 2019
  3. 1ec5 commented on Jul 26, 2019

    @1ec5
    ContributorAuthor

    Additionally, if a padding is explicitly passed into either easeTo() and flyTo(), mbgl persists that padding as the content insets: #15233. Because mbgl conflates the two properties, it isn’t possible even to work around the original issue 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.

  4. added
    navigation
    on Jul 26, 2019
  5. astojilj commented on Jul 27, 2019

    @astojilj
    Contributor

    @1ec5 ,

    We discussed this concern at #12818 (comment) and I should continue work on this.

    By design, a camera’s edge padding and the map’s content insets are supposed to be additive: every camera change operation is relative to the content insets, and the edge padding can further inset the camera.

    As mentioned there, didn't see it defined in documentation and thought it is intuitive to make it behave additive for case of automaticallyAdjustsScrollViewInsets, otherwise no.

    This is related to discussion in #15233 and we should clarify the behavior in documentation. I don't see it requires API changes.

  6. 1ec5 commented on Jul 28, 2019

    @1ec5
    ContributorAuthor

    I don’t think API changes are strictly required, but I do think we need to do more than clarify the documentation. If content insets and edge padding are redundant to each other and one affects the other, then there was no point in fixing #12818, and the situation is especially confusing for someone used to UIKit and MapKit controls.

    The discussion in #12818 (comment) was focused on whether we could get away with making the change without bumping the major version, as required by semantic versioning. A loophole in the documentation meant that we could do so, but it was still necessary to make the various methods consistent.

    automaticallyAdjustsScrollViewInsets is only a convenience for the developer, but the developer can set the insets for exactly the same reason that it would be set automatically. In that case, they should get the same camera behavior as if the map view adjusted the insets automatically.

  7. astojilj commented on Aug 14, 2019

    @astojilj
    Contributor

    Offline agreement on this is that it is confusing to have both content insets and padding since they both use the same implementation to implement Android and iOS code and terms content insets, padding, edge insets are used interchangeably.

    We will reconsider anchor design later.

    @1ec5

    By design, a camera’s edge padding and the map’s content insets are supposed to be additive: every camera change operation is relative to the content insets, and the edge padding can further inset the camera.

    This is left to be covered. I don't see that our documentation covers this. Is the design implied by adopting similar functionality from other APIs/frameworks?

  8. astojilj commented on Aug 14, 2019

    @astojilj
    Contributor

    @1ec5 , @fabian-guerra

    I'm going again through the discussion to split the issues list from the description and title (part of it is related to implementation detail of pre and after #14664.

    The regression tag added here - is it related to #14813 fixing #12818?

    We can close the issue as, from perspective of iOS SDK API, they are additive - not mutually exclusive - all the APIs add content inset to specified padding:

    edgePadding = MGLEdgeInsetsInsetEdgeInset(edgePadding, self.contentInset);

    padding += MGLEdgeInsetsFromNSEdgeInsets(self.contentInset);

    Content inset is stored as separate property of MGLMapView and added to specified padding later - so MGLMapView doesn't ignore it.

  9. astojilj commented on Aug 14, 2019

    @astojilj
    Contributor

    Closing according to #15232 (comment)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Corebughigh prioritynavigationneeds discussionregression

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions