-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Improve user location annotation performance #6019
Conversation
@@ -291,13 +292,21 @@ - (void)drawDot | |||
if (accuracyRingSize > MGLUserLocationAnnotationDotSize + 15) | |||
{ | |||
_accuracyRingLayer.hidden = NO; | |||
|
|||
id shouldNotAnimateAccuracyRingChange = (_oldHorizontalAccuracy == self.userLocation.location.horizontalAccuracy) ? (id)kCFBooleanTrue : (id)kCFBooleanFalse; |
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.
Nit: always express variable names in the positive, for easier reasoning. How about shouldDisableActions
, along with a comment?
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.
Sounds good to me... fought with myself a bit here and I like your solution. 👍
83721f2
to
2f58d22
Compare
824c09f
to
634f680
Compare
Improves perceived and actual performance by eliminating the implicit animation that occurred when the accuracy ring changed size during zooms. This previously would pile up animations as the zoom changed, causing an unsightly wobbling effect.
Supposed performance enhancement and also improves edge smoothness.
2f58d22
to
1e5b15f
Compare
Changing the target branch was a bit rougher than I hoped — it didn’t recognize that #5882 had been squash-merged and showed all of the squashed commits again here. Fixed and rebased onto master. Will merge after tests go green. |
Merged without Travis (re-)approval because Travis is having a major outage today. |
User location annotation performance wasn’t bad previously, but there are some small tweaks we can make to improve both perceived and actual performance.
This PR is proposed against
5039-MGLUserLocationAnnotationView-refactor
until #5882 lands. We can now change the base branch of existing pull requests, so I’ll try that out before merging this.Accuracy ring
The biggest improvement is to the accuracy ring: instead of queueing up implicit animations while zooming, now we only animate changes to the ring’s size (i.e., when the horizontal accuracy changes). This fixes the wobbling effect you could see at the edges of the ring when zooming.
We’re able to disable the implicit animation during zooms because we already update the user dot ourselves in
-[MGLMapView updateUserLocationAnnotationViewAnimatedWithDuration:]
— sometimes almost every frame.Shadow paths
Per Apple, pre-calculating the paths of shadows can provide better performance.
Rasterize pulsating inner dot
This stops the dot from being rendered off-screen and smoothes its edges (which could at times appear squarish).
/cc @1ec5 @boundsj @frederoni @incanus