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

Improve user location annotation performance #6019

Merged
merged 3 commits into from Aug 16, 2016

Conversation

friedbunny
Copy link
Contributor

@friedbunny friedbunny commented Aug 15, 2016

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

@friedbunny friedbunny added iOS Mapbox Maps SDK for iOS performance Speed, stability, CPU usage, memory usage, or power usage annotations Annotations on iOS and macOS or markers on Android labels Aug 15, 2016
@friedbunny friedbunny added this to the ios-v3.4.0 milestone Aug 15, 2016
@friedbunny friedbunny self-assigned this Aug 15, 2016
@@ -291,13 +292,21 @@ - (void)drawDot
if (accuracyRingSize > MGLUserLocationAnnotationDotSize + 15)
{
_accuracyRingLayer.hidden = NO;

id shouldNotAnimateAccuracyRingChange = (_oldHorizontalAccuracy == self.userLocation.location.horizontalAccuracy) ? (id)kCFBooleanTrue : (id)kCFBooleanFalse;
Copy link
Contributor

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?

Copy link
Contributor Author

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. 👍

@friedbunny friedbunny force-pushed the 5039-MGLUserLocationAnnotationView-refactor branch from 824c09f to 634f680 Compare August 16, 2016 14:42
@friedbunny friedbunny changed the base branch from 5039-MGLUserLocationAnnotationView-refactor to master August 16, 2016 19:28
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.
@friedbunny
Copy link
Contributor Author

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.

@friedbunny friedbunny merged commit 1de65e2 into master Aug 16, 2016
@friedbunny friedbunny deleted the fb-user-dot-performance branch August 16, 2016 21:38
@friedbunny
Copy link
Contributor Author

Merged without Travis (re-)approval because Travis is having a major outage today.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
annotations Annotations on iOS and macOS or markers on Android iOS Mapbox Maps SDK for iOS performance Speed, stability, CPU usage, memory usage, or power usage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants