From 59076c830051e1fde26c6353406b04748a7c9b00 Mon Sep 17 00:00:00 2001 From: Jason Wray Date: Wed, 6 Sep 2017 16:24:26 -0400 Subject: [ios] Disable implicit animation of heading indicators 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. --- platform/ios/src/MGLFaux3DUserLocationAnnotationView.m | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/platform/ios/src/MGLFaux3DUserLocationAnnotationView.m b/platform/ios/src/MGLFaux3DUserLocationAnnotationView.m index 158bb01d8e..7001569b30 100644 --- a/platform/ios/src/MGLFaux3DUserLocationAnnotationView.m +++ b/platform/ios/src/MGLFaux3DUserLocationAnnotationView.m @@ -71,7 +71,7 @@ { // 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; @@ -261,7 +261,12 @@ // Don't rotate if the change is imperceptible. if (fabs(rotation) > MGLUserLocationHeadingUpdateThreshold) { + [CATransaction begin]; + [CATransaction setDisableActions:YES]; + _headingIndicatorLayer.affineTransform = CGAffineTransformRotate(CGAffineTransformIdentity, rotation); + + [CATransaction commit]; } } } @@ -283,10 +288,10 @@ _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; -- cgit v1.2.1