Skip to content

Update UserCourseView instantaneously - #1838

Merged
JThramer merged 4 commits into
masterfrom
fred/instant-puck-updates
Nov 15, 2018
Merged

JThramer merged 4 commits into
masterfrom
fred/instant-puck-updates

Conversation

@frederoni

@frederoni frederoni commented Nov 14, 2018 •

Copy link
Copy Markdown
Contributor

Fixes #1731

  • Update UserCourseView instantaneously when a camera change is triggered by a user interaction.
  • Update UserCourseView instantaneously when the map view’s layout margin changes.
Before After
before after
rotate_before rotate_after

cc @1ec5 @vincethecoder @JThramer

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I would preferably avoid this frame by frame tracking but using updateCourseTracking(location:camera:animated:false) did not mitigate the lag/animation. cc @1ec5

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Perhaps there’s a race condition in which this method gets called before the map view updates its center coordinate to reflect the margin change, so that by the time we convert the user location to a center point within the (non)animation block, the center point still reflects the old margins.

UIView.animate(withDuration: duration, delay: 0, options: [.curveLinear, .beginFromCurrentState], animations: {
self.userCourseView?.center = self.convert(location.coordinate, toPointTo: self)
})

Temporarily enabling frame-by-frame course tracking ensures that the view moves as soon as the map adjusts to the new content insets (since that requires the map view to render another frame):

guard shouldPositionCourseViewFrameByFrame else { return }
guard let location = userLocationForCourseTracking else { return }
userCourseView?.center = convert(location.coordinate, toPointTo: self)

Temporarily reenabling frame-by-frame course tracking isn’t the end of the world, though if it really comes down to this race condition, then I’d think a shorter duration would still be sufficient to work around it.

@frederoni
frederoni force-pushed the fred/instant-puck-updates branch from ce7b1bd to 5d0a34f Compare November 14, 2018 14:28

@JThramer JThramer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

@1ec5 1ec5 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested changelog entry:

Fixed an issue causing UserCourseView to lag behind NavigationMapView whenever the map’s camera or content insets change significantly.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Perhaps there’s a race condition in which this method gets called before the map view updates its center coordinate to reflect the margin change, so that by the time we convert the user location to a center point within the (non)animation block, the center point still reflects the old margins.

UIView.animate(withDuration: duration, delay: 0, options: [.curveLinear, .beginFromCurrentState], animations: {
self.userCourseView?.center = self.convert(location.coordinate, toPointTo: self)
})

Temporarily enabling frame-by-frame course tracking ensures that the view moves as soon as the map adjusts to the new content insets (since that requires the map view to render another frame):

guard shouldPositionCourseViewFrameByFrame else { return }
guard let location = userLocationForCourseTracking else { return }
userCourseView?.center = convert(location.coordinate, toPointTo: self)

Temporarily reenabling frame-by-frame course tracking isn’t the end of the world, though if it really comes down to this race condition, then I’d think a shorter duration would still be sufficient to work around it.

@akitchen akitchen added this to the v0.25.0 milestone Nov 15, 2018
@JThramer
JThramer merged commit 175a214 into master Nov 15, 2018
@1ec5
1ec5 deleted the fred/instant-puck-updates branch December 5, 2019 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants