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

Commit

Permalink
[ios] Disable implicit animation of heading indicators
Browse files Browse the repository at this point in the history
The update steps for the heading indicator are typically small, so animations tend to pile up and cause performance issues. Disabling actions is a slight regression when it comes to large steps (they're not animated now, where they previously were) and this should eventually be addressed.

Also consistently use provided API for disabling CATransaction actions.
  • Loading branch information
friedbunny committed Sep 7, 2017
1 parent cb1309a commit 59076c8
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions platform/ios/src/MGLFaux3DUserLocationAnnotationView.m
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ - (void)updatePitch
{
// disable implicit animation
[CATransaction begin];
[CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];
[CATransaction setDisableActions:YES];

CATransform3D t = CATransform3DRotate(CATransform3DIdentity, MGLRadiansFromDegrees(self.mapView.camera.pitch), 1.0, 0, 0);
self.layer.sublayerTransform = t;
Expand Down Expand Up @@ -261,7 +261,12 @@ - (void)drawDot
// Don't rotate if the change is imperceptible.
if (fabs(rotation) > MGLUserLocationHeadingUpdateThreshold)
{
[CATransaction begin];
[CATransaction setDisableActions:YES];

_headingIndicatorLayer.affineTransform = CGAffineTransformRotate(CGAffineTransformIdentity, rotation);

[CATransaction commit];
}
}
}
Expand All @@ -283,10 +288,10 @@ - (void)drawDot
_accuracyRingLayer.hidden = NO;

// disable implicit animation of the accuracy ring, unless triggered by a change in accuracy
id shouldDisableActions = (_oldHorizontalAccuracy == self.userLocation.location.horizontalAccuracy) ? (id)kCFBooleanTrue : (id)kCFBooleanFalse;
BOOL shouldDisableActions = _oldHorizontalAccuracy == self.userLocation.location.horizontalAccuracy;

[CATransaction begin];
[CATransaction setValue:shouldDisableActions forKey:kCATransactionDisableActions];
[CATransaction setDisableActions:shouldDisableActions];

_accuracyRingLayer.bounds = CGRectMake(0, 0, accuracyRingSize, accuracyRingSize);
_accuracyRingLayer.cornerRadius = accuracyRingSize / 2;
Expand Down

0 comments on commit 59076c8

Please sign in to comment.