Skip to content
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

Simplify anchor point calculation and puck centering #2211

Merged
merged 5 commits into from
Oct 2, 2019
Merged

Conversation

astojilj
Copy link
Contributor

@astojilj astojilj commented Aug 12, 2019

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.

Link to video showing current state.

EDIT 9/9/2019:
Work around mapbox-gl-native/15574. Panning fix.

Fix CarPlay puck positioning, panning away from navigation, navigation -> overview transitions.
Remove syncing safeArea to contentInset, contentInset is to be used to position puck and this causes map position sudden change when panning.

Work around mapbox-gl-native/15574: should be future proof as the mapbox/mapbox-gl-native#15574 exists only with MGLMapView.contentInset.

Addresses: mapbox/mapbox-gl-native#15232, mapbox/mapbox-gl-native#15233

Related to: #2165,

Fixes: #2145, #2190


if overviewing {
insets += NavigationMapView.courseViewMinimumInsets

let routeLineWidths = MBRouteLineWidthByZoomLevel.compactMap { $0.value.constantValue as? Int }
insets += UIEdgeInsets(floatLiteral: Double(routeLineWidths.max() ?? 0))
} else if mapView.tracksUserCourse {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RouteMapViewController is used by NavigationViewController but not CarPlayNavigationViewController. Developers are also responsible for implementing their own preview map or free-driving map using a standalone NavigationMapView. So this code would need to be duplicated in CarPlayNavigationViewController and application code. It would be better to keep the code in NavigationMapView if possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After 98551dd

CarPlayNavigationViewController and NavigationViewController contentInset() functions are very close and seems feasible to extract common part to NavigationMapView.
As I don't have enough understanding of navigation-ios API surface. it is better if someone else from navigation-ios team continue on formulating the API, that is if the workarounds taken here are fine.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We’re going to address duplication between CarPlayNavigationViewController and NavigationViewController overall in a separate PR ahead of v1.0.

@@ -194,8 +183,6 @@ open class NavigationMapView: MGLMapView, UIGestureRecognizerDelegate {
if let userCourseView = userCourseView {
if let location = userLocationForCourseTracking {
updateCourseTracking(location: location, animated: false)
} else {
userCourseView.center = userAnchorPoint
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the need to specify center for puck view - use the approach where content inset is keeping it centered.

We need to check whether undoing #2047 ends up regressing #1731 and #1949. Also, does the puck consistently remain at userAnchorPoint when simulation is sped up?

/ref @frederoni

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, does the puck consistently remain at userAnchorPoint when simulation is sped up?

Yes, it remains. It is always centered to padding area and no need to reposition it. Attached video to show:
https://www.dropbox.com/s/wori62tfhp69feg/RPReplay_Final1565767435.mp4?dl=0

Also, the issue here is fixed: mapbox/mapbox-gl-native#15233 (comment)

@1ec5
Copy link
Contributor

1ec5 commented Aug 14, 2019

Addresses: mapbox/mapbox-gl-native#15232, mapbox/mapbox-gl-native#15233

This is at most a workaround. A downstream change does not fix an upstream regression.

astojilj added a commit that referenced this pull request Sep 9, 2019
… safeArea. Panning fix.

Fix CarPlay puck positioning, panning away from navigation, navigation -> overview transitions.

The workaround should be future proof as the mapbox/mapbox-gl-native#15574 exists only with MGLMapView.contentInset.
Additionally, it simplifies the code as it doesn't need to ensure that safeArea and contentInset are kept in sync: according to work in #2211, contentInset is to be used to position puck and this causes map position sudden change when panning.

Fixes: #2190
@astojilj astojilj requested a review from 1ec5 September 9, 2019 07:42
@noway
Copy link

noway commented Sep 26, 2019

When this will be merged? We can no longer use mapbox navagtion 0.34 with mapbox ios sdk 5.0.0 because it fails to compile with Swift 5.1 (which is forced with Xcode 11.0). Having to update to 0.37, this is a critical bug which blocks any releases we can do to our app. 😣

Having this bug in production is not an option because it critically deteriorates the user experience which was working well before.

If there is any work around, or if this issue can be prioritised, that would be greatly appreciated.

@astojilj
Copy link
Contributor Author

astojilj commented Sep 26, 2019

When this will be merged? We can no longer use mapbox navagtion 0.34 with mapbox ios sdk 5.0.0 because it fails to compile with Swift 5.1 (which is forced with Xcode 11.0). This is a critical bug for us which blocks any releases we can do to our app. 😣

Having this bug in production is not an option because it critically affects the user experience

It is currently in review and some manual verification is needed. Did you try if it fixes the issues in your application?
Thanks.

cc @frederoni @1ec5 @fabian-guerra

@noway
Copy link

noway commented Sep 26, 2019

WORKS FABULOUSLY! Even closing the top nav bar stopped crashing the app!

For anyone who's coming across this, the commit id for this PR's branch is:

github "mapbox/mapbox-navigation-ios" "98551ddcbf5934226702dc0ce710266d86f809ce"

Thanks!

@1ec5
Copy link
Contributor

1ec5 commented Sep 27, 2019

This PR will go in as soon as we’re able to verify that it doesn’t break navigation on a CarPlay device. In the meantime, if you don’t use CarPlay functionality, feel free to use this branch as described above.

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
… safeArea. Panning fix.

Fix CarPlay puck positioning, panning away from navigation, navigation -> overview transitions.

The workaround should be future proof as the mapbox/mapbox-gl-native#15574 exists only with MGLMapView.contentInset.
Additionally, it simplifies the code as it doesn't need to ensure that safeArea and contentInset are kept in sync: according to work in #2211, contentInset is to be used to position puck and this causes map position sudden change when panning.

Fixes: #2190
Copy link
Contributor

@1ec5 1ec5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again for contributing these workarounds! As noted above, the changes do address the map SDK regressions. #2246 and #2247 track regressions caused by this PR that, compared to #2145 and #2190, are relatively minor. #2248 tracks the removal of the workarounds added in this PR.

@1ec5 1ec5 merged commit 7ff86d9 into master Oct 2, 2019
@1ec5 1ec5 deleted the astojilj-15233 branch October 2, 2019 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove workarounds adding content inset when setting map camera
3 participants