From f4765a06110f6ad11fc5c050ae218d9a5ed6424a Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Mon, 28 Sep 2020 11:21:03 -0400 Subject: [PATCH 1/6] Fix frame-delay bug affect UIViews. (#483) (cherry picked from commit 86891739543d6cc3049924e68bbc70ec2c1c5870) --- platform/ios/CHANGELOG.md | 6 +++++- platform/ios/src/MGLMapView.mm | 24 ++++++++++++++---------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md index 655a924ca7..75f79892ba 100644 --- a/platform/ios/CHANGELOG.md +++ b/platform/ios/CHANGELOG.md @@ -2,10 +2,14 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONTRIBUTING.md](../../CONTRIBUTING.md) to get started. -## 6.2.1 - September 23, 2020 +## master ### 🐞 Bug fixes +* Fixed a bug with UIViews being incorrectly updated with a one frame delay. ([#483](https://github.com/mapbox/mapbox-gl-native-ios/pull/483)) + +## 6.2.1 - September 23, 2020 + * Fixed an issue where completion blocks were not called until the map was rendered. ([#463](https://github.com/mapbox/mapbox-gl-native-ios/pull/463)) * Fixed an issue that caused a crash when custom location managers did not implement `MGLLocationManager.accuracyAuthorization`. ([#474](https://github.com/mapbox/mapbox-gl-native-ios/pull/474)) * Fixed a crash that occurred when `MGLIdeographicFontFamilyName` was set to `NO`. ([#467](https://github.com/mapbox/mapbox-gl-native-ios/pull/467), [#476](https://github.com/mapbox/mapbox-gl-native-ios/pull/476)) diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index 3a05df553b..da079b36fd 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -1099,7 +1099,7 @@ - (void)setOpaque:(BOOL)opaque } } -- (void)updateViewsPostMapRendering { +- (void)updateViewsWithCurrentUpdateParameters { // Update UIKit elements, prior to rendering [self updateUserLocationAnnotationView]; [self updateAnnotationViews]; @@ -1120,6 +1120,19 @@ - (BOOL)renderSync if (!self.dormant && needsRender) { + // It's important to call this *before* `_rendererFrontend->render()`, as + // that function saves the current `updateParameters` before rendering. If this + // occurs after then the views will be a frame behind. + // + // The update parameters will have been updated earlier, for example by + // calls to easeTo, flyTo, called from gesture handlers. + + MGL_SIGNPOST_BEGIN(_log, _signpost, "renderSync", "update"); + [self updateViewsWithCurrentUpdateParameters]; + MGL_SIGNPOST_END(_log, _signpost, "renderSync", "update"); + + // - - - - - + MGL_SIGNPOST_BEGIN(_log, _signpost, "renderSync", "render"); if (_rendererFrontend) { _numberOfRenderCalls++; @@ -1136,15 +1149,6 @@ - (BOOL)renderSync } } MGL_SIGNPOST_END(_log, _signpost, "renderSync", "render"); - - // - - - - - - - // TODO: This should be moved from what's essentially the UIView rendering - // To do this, add view models that can be updated separately, before the - // UIViews can be updated to match - MGL_SIGNPOST_BEGIN(_log, _signpost, "renderSync", "update"); - [self updateViewsPostMapRendering]; - MGL_SIGNPOST_END(_log, _signpost, "renderSync", "update"); } if (hasPendingBlocks) { From 36035cac750d635c8cc9698fe754c6776b5992d0 Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Mon, 12 Oct 2020 13:00:21 -0400 Subject: [PATCH 2/6] Add compass image as a sublayer (#501) Cherry picked from 97840a684 --- circle.yml | 2 +- platform/ios/CHANGELOG.md | 3 ++- platform/ios/src/MGLCompassButton.mm | 24 +++++++++++++++---- platform/ios/src/MGLCompassButton_Private.h | 1 + platform/ios/src/MGLMapView.mm | 5 +++- .../ios/test/MGLMapViewCompassViewTests.mm | 19 ++++++++++----- 6 files changed, 41 insertions(+), 13 deletions(-) diff --git a/circle.yml b/circle.yml index deb6e66317..62862eb193 100644 --- a/circle.yml +++ b/circle.yml @@ -19,7 +19,7 @@ workflows: - ios-build: matrix: parameters: - xcode: ["11.1.0", "11.7.0"] + xcode: ["11.7.0", "12.0.0"] buildtype: ["Debug", "Release"] - ios-release-template: xcode: "12.0.0" diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md index 75f79892ba..902ba6bd55 100644 --- a/platform/ios/CHANGELOG.md +++ b/platform/ios/CHANGELOG.md @@ -2,10 +2,11 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONTRIBUTING.md](../../CONTRIBUTING.md) to get started. -## master +## 6.2.2 ### 🐞 Bug fixes +* Partly fixed an issue on iOS 14 where `-[UIView layoutSubviews]` was being repeatedly called. ([#501](https://github.com/mapbox/mapbox-gl-native-ios/pull/501)) * Fixed a bug with UIViews being incorrectly updated with a one frame delay. ([#483](https://github.com/mapbox/mapbox-gl-native-ios/pull/483)) ## 6.2.1 - September 23, 2020 diff --git a/platform/ios/src/MGLCompassButton.mm b/platform/ios/src/MGLCompassButton.mm index 5bbd9bf923..4d476247e6 100644 --- a/platform/ios/src/MGLCompassButton.mm +++ b/platform/ios/src/MGLCompassButton.mm @@ -12,6 +12,7 @@ @interface MGLCompassButton () @property (nonatomic, weak) MGLMapView *mapView; +@property (nonatomic) CALayer *imageLayer; @property (nonatomic) MGLCompassDirectionFormatter *accessibilityCompassFormatter; @end @@ -30,8 +31,21 @@ - (instancetype)initWithMapView:(MGLMapView *)mapView { return self; } +- (void)setImage:(UIImage *)image { + self.imageLayer.contents = (id)image.CGImage; +} + - (void)commonInit { - self.image = self.compassImage; + UIImage *image = self.compassImage; + CGRect bounds = (CGRect){CGPointZero, image.size}; + self.bounds = bounds; + + self.imageLayer = [[CALayer alloc] init]; + self.imageLayer.frame = bounds; + self.imageLayer.contentsGravity = kCAGravityResizeAspect; + + self.image = image; + [self.layer addSublayer:self.imageLayer]; self.compassVisibility = MGLOrnamentVisibilityAdaptive; @@ -48,8 +62,6 @@ - (void)commonInit { self.accessibilityCompassFormatter = [[MGLCompassDirectionFormatter alloc] init]; self.accessibilityCompassFormatter.unitStyle = NSFormattingUnitStyleLong; - - [self sizeToFit]; } - (void)setCompassVisibility:(MGLOrnamentVisibility)compassVisibility { @@ -96,7 +108,11 @@ - (void)updateCompass { - (void)updateCompassAnimated:(BOOL)animated { CLLocationDirection direction = self.mapView.direction; CLLocationDirection plateDirection = mbgl::util::wrap(-direction, 0., 360.); - self.transform = CGAffineTransformMakeRotation(MGLRadiansFromDegrees(plateDirection)); + + [CATransaction begin]; + [CATransaction setValue:@(YES) forKey:kCATransactionDisableActions]; + self.imageLayer.transform = CATransform3DMakeRotation(MGLRadiansFromDegrees(plateDirection), 0.0, 0.0, 1.0); + [CATransaction commit]; self.isAccessibilityElement = direction > 0; self.accessibilityValue = [self.accessibilityCompassFormatter stringFromDirection:direction]; diff --git a/platform/ios/src/MGLCompassButton_Private.h b/platform/ios/src/MGLCompassButton_Private.h index 9ef55cfa5b..9f76c558e0 100644 --- a/platform/ios/src/MGLCompassButton_Private.h +++ b/platform/ios/src/MGLCompassButton_Private.h @@ -11,6 +11,7 @@ NS_ASSUME_NONNULL_BEGIN + (instancetype)compassButtonWithMapView:(MGLMapView *)mapView; @property (nonatomic, weak) MGLMapView *mapView; +@property (nonatomic) CALayer *imageLayer; - (void)updateCompass; diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index da079b36fd..9b131f45fe 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -7269,7 +7269,10 @@ - (CGPoint)userLocationAnnotationViewCenter - (void)updateCompass { - [self.compassView updateCompass]; + if ((self.compassView.compassVisibility != MGLOrnamentVisibilityHidden) && + (!self.compassView.isHidden)) { + [self.compassView updateCompass]; + } } - (void)updateScaleBar diff --git a/platform/ios/test/MGLMapViewCompassViewTests.mm b/platform/ios/test/MGLMapViewCompassViewTests.mm index aaec4b0bf7..2c3445417a 100644 --- a/platform/ios/test/MGLMapViewCompassViewTests.mm +++ b/platform/ios/test/MGLMapViewCompassViewTests.mm @@ -1,6 +1,6 @@ #import #import - +#import "MGLCompassButton_Private.h" #import @interface MGLMapView (MGLCompassButtonTests) @@ -84,14 +84,21 @@ - (void)testCompassRotation { for (NSNumber *degrees in @[@-999, @-359, @-240, @-180, @-90, @-45, @0, @45, @90, @180, @240, @360, @999]) { self.mapView.direction = [degrees doubleValue]; CGFloat wrappedDirection = mbgl::util::wrap(-self.mapView.direction, 0., 360.); - CGAffineTransform rotation = CGAffineTransformMakeRotation(MGLRadiansFromDegrees(wrappedDirection)); - XCTAssertTrue(CGAffineTransformEqualToTransform(self.mapView.compassView.transform, rotation), - @"Compass transform direction %f° should equal wrapped transform direction %f° (~%.f°).", [self degreesFromAffineTransform:self.mapView.compassView.transform], [self degreesFromAffineTransform:rotation], wrappedDirection); + CATransform3D rotation = CATransform3DMakeRotation(MGLRadiansFromDegrees(wrappedDirection), 0.0, 0.0, 1.0); + + CGFloat deg1 = [self degreesFromAffineTransform:self.mapView.compassView.imageLayer.transform]; + CGFloat deg2 = [self degreesFromAffineTransform:rotation]; + XCTAssertEqual(deg1, deg2); + XCTAssertTrue(CATransform3DEqualToTransform(self.mapView.compassView.imageLayer.transform, rotation), + @"Compass transform direction %f° should equal wrapped transform direction %f° (~%.f°).", + deg1, + deg2, + wrappedDirection); } } -- (CGFloat)degreesFromAffineTransform:(CGAffineTransform)transform { - CGFloat angle = atan2f(transform.b, transform.a); +- (CGFloat)degreesFromAffineTransform:(CATransform3D)transform { + CGFloat angle = atan2f(transform.m12, transform.m11); return MGLDegreesFromRadians(angle); } From c47a9681e3d4fc1f3b1df2b68d7880b73849d453 Mon Sep 17 00:00:00 2001 From: Lloyd Sheng Date: Thu, 15 Oct 2020 19:12:32 +0800 Subject: [PATCH 3/6] Fix scalebar ornament triggers unnecessary layoutSubviews (#507) Cherry picked from 0bda2d387 --- platform/ios/CHANGELOG.md | 1 + platform/ios/src/MGLMapView.mm | 91 +++++++++++++-------- platform/ios/src/MGLScaleBar.h | 3 + platform/ios/src/MGLScaleBar.mm | 72 ++++++---------- platform/ios/test/MGLMapViewLayoutTests.m | 3 +- platform/ios/test/MGLMapViewScaleBarTests.m | 10 +-- 6 files changed, 88 insertions(+), 92 deletions(-) diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md index 902ba6bd55..f34283463a 100644 --- a/platform/ios/CHANGELOG.md +++ b/platform/ios/CHANGELOG.md @@ -8,6 +8,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT * Partly fixed an issue on iOS 14 where `-[UIView layoutSubviews]` was being repeatedly called. ([#501](https://github.com/mapbox/mapbox-gl-native-ios/pull/501)) * Fixed a bug with UIViews being incorrectly updated with a one frame delay. ([#483](https://github.com/mapbox/mapbox-gl-native-ios/pull/483)) +* Fixed an issue on iOS 14 where scalebar triggers unnecessary `-[UIView layoutSubviews]`. ([#507](https://github.com/mapbox/mapbox-gl-native-ios/pull/507)) ## 6.2.1 - September 23, 2020 diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index 9b131f45fe..8ccadf1d1e 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -866,6 +866,7 @@ + (BOOL)requiresConstraintBasedLayout - (void)setScaleBarPosition:(MGLOrnamentPosition)scaleBarPosition { MGLLogDebug(@"Setting scaleBarPosition: %lu", scaleBarPosition); _scaleBarPosition = scaleBarPosition; + _scaleBar.isOnScreenRight = (scaleBarPosition == MGLOrnamentPositionTopRight || scaleBarPosition == MGLOrnamentPositionBottomRight); [self installScaleBarConstraints]; } @@ -914,7 +915,7 @@ - (void)setAttributionButtonMargins:(CGPoint)attributionButtonMargins { - (void)updateConstraintsForOrnament:(UIView *)view constraints:(NSMutableArray *)constraints position:(MGLOrnamentPosition)position - size:(CGSize)size + sizeConstraints:(NSArray *)sizeConstraints margins:(CGPoint)margins { NSMutableArray *updatedConstraints = [NSMutableArray array]; UIEdgeInsets inset = UIEdgeInsetsZero; @@ -950,15 +951,9 @@ - (void)updateConstraintsForOrnament:(UIView *)view [updatedConstraints addObject: [self.safeTrailingAnchor constraintEqualToAnchor:view.trailingAnchor constant:margins.x + inset.right]]; break; } - - if (!CGSizeEqualToSize(size, CGSizeZero)) { - NSLayoutConstraint *widthConstraint = [view.widthAnchor constraintEqualToConstant:size.width]; - widthConstraint.identifier = @"width"; - NSLayoutConstraint *heightConstraint = [view.heightAnchor constraintEqualToConstant:size.height]; - heightConstraint.identifier = @"height"; - [updatedConstraints addObjectsFromArray:@[widthConstraint,heightConstraint]]; - } + [updatedConstraints addObjectsFromArray:sizeConstraints]; + [NSLayoutConstraint deactivateConstraints:constraints]; [constraints removeAllObjects]; [NSLayoutConstraint activateConstraints:updatedConstraints]; @@ -1034,7 +1029,7 @@ - (void)installCompassViewConstraints { [self updateConstraintsForOrnament:self.compassView constraints:self.compassViewConstraints position:self.compassViewPosition - size:[self sizeForOrnament:self.compassView constraints:self.compassViewConstraints] + sizeConstraints:[self sizeConstraintsForOrnament:self.compassView constraints:self.compassViewConstraints] margins:self.compassViewMargins]; } @@ -1043,7 +1038,7 @@ - (void)installScaleBarConstraints { [self updateConstraintsForOrnament:self.scaleBar constraints:self.scaleBarConstraints position:self.scaleBarPosition - size:CGSizeZero + sizeConstraints:[self sizeConstraintsForOrnament:self.scaleBar constraints:self.compassViewConstraints] margins:self.scaleBarMargins]; } @@ -1052,7 +1047,7 @@ - (void)installLogoViewConstraints { [self updateConstraintsForOrnament:self.logoView constraints:self.logoViewConstraints position:self.logoViewPosition - size:[self sizeForOrnament:self.logoView constraints:self.logoViewConstraints] + sizeConstraints:[self sizeConstraintsForOrnament:self.logoView constraints:self.logoViewConstraints] margins:self.logoViewMargins]; } @@ -1061,29 +1056,56 @@ - (void)installAttributionButtonConstraints { [self updateConstraintsForOrnament:self.attributionButton constraints:self.attributionButtonConstraints position:self.attributionButtonPosition - size:[self sizeForOrnament:self.attributionButton constraints:self.attributionButtonConstraints] + sizeConstraints:[self sizeConstraintsForOrnament:self.attributionButton constraints:self.attributionButtonConstraints] margins:self.attributionButtonMargins]; } -- (CGSize)sizeForOrnament:(UIView *)view - constraints:(NSMutableArray *)constraints { - // avoid regenerating size constraints - CGSize size; - if(constraints && constraints.count > 0) { - for (NSLayoutConstraint * constraint in constraints) { - if([constraint.identifier isEqualToString:@"width"]) { - size.width = constraint.constant; - } - else if ([constraint.identifier isEqualToString:@"height"]) { - size.height = constraint.constant; - } - } +- (NSArray *)sizeConstraintsForOrnament:(UIView *)view + constraints:(NSMutableArray *)constraints { + + NSLayoutConstraint *widthConstraint = nil; + NSLayoutConstraint *heightConstraint = nil; + + if (view == _scaleBar) { + widthConstraint = [NSLayoutConstraint constraintWithItem:_scaleBar + attribute:NSLayoutAttributeWidth + relatedBy:NSLayoutRelationEqual + toItem:self + attribute:NSLayoutAttributeWidth + multiplier:.5 + constant:0]; + heightConstraint = [NSLayoutConstraint constraintWithItem:_scaleBar + attribute:NSLayoutAttributeHeight + relatedBy:NSLayoutRelationEqual + toItem:nil + attribute:NSLayoutAttributeNotAnAttribute + multiplier:1 + constant:16]; } else { - size = view.bounds.size; + // avoid regenerating size constraints + CGSize size; + if(constraints && constraints.count > 0) { + for (NSLayoutConstraint * constraint in constraints) { + if([constraint.identifier isEqualToString:@"width"]) { + size.width = constraint.constant; + } + else if ([constraint.identifier isEqualToString:@"height"]) { + size.height = constraint.constant; + } + } + } + else { + size = view.bounds.size; + } + + widthConstraint = [view.widthAnchor constraintEqualToConstant:size.width]; + widthConstraint.identifier = @"width"; + heightConstraint = [view.heightAnchor constraintEqualToConstant:size.height]; + heightConstraint.identifier = @"height"; } - - return size; + + return @[widthConstraint, heightConstraint]; } - (BOOL)isOpaque @@ -1168,13 +1190,6 @@ - (void)layoutSubviews { [super layoutSubviews]; - // Calling this here instead of in the scale bar itself because if this is done in the - // scale bar instance, it triggers a call to this `layoutSubviews` method that calls - // `_mbglMap->setSize()` just below that triggers rendering update which triggers - // another scale bar update which causes a rendering update loop and a major performace - // degradation. - [self.scaleBar invalidateIntrinsicContentSize]; - [self adjustContentInset]; if (_mbglView) { @@ -1190,6 +1205,10 @@ - (void)layoutSubviews } } + if (self.scaleBar.alpha) { + [self updateScaleBar]; + } + if (self.compassView.alpha) { [self updateCompass]; diff --git a/platform/ios/src/MGLScaleBar.h b/platform/ios/src/MGLScaleBar.h index 77fd6736b5..bdf1268765 100644 --- a/platform/ios/src/MGLScaleBar.h +++ b/platform/ios/src/MGLScaleBar.h @@ -6,4 +6,7 @@ // Sets the scale and redraws the scale bar @property (nonatomic, assign) CLLocationDistance metersPerPoint; +// Sets whether the scale on the right side of screen +@property (nonatomic, assign) BOOL isOnScreenRight; + @end diff --git a/platform/ios/src/MGLScaleBar.mm b/platform/ios/src/MGLScaleBar.mm index 3efa80013f..137a520ab9 100644 --- a/platform/ios/src/MGLScaleBar.mm +++ b/platform/ios/src/MGLScaleBar.mm @@ -87,7 +87,6 @@ @interface MGLScaleBar() @property (nonatomic) MGLScaleBarLabel* prototypeLabel; @property (nonatomic) CGFloat lastLabelWidth; @property (nonatomic) CGSize size; -@property (nonatomic) BOOL recalculateSize; @property (nonatomic) BOOL shouldLayoutBars; @property (nonatomic) NSNumber *testingRightToLeftOverride; @end @@ -201,6 +200,13 @@ - (void)resetLabelImageCache { #pragma mark - Dimensions +- (void)setIsOnScreenRight:(BOOL)isOnScreenRight { + if (_isOnScreenRight != isOnScreenRight) { + _isOnScreenRight = isOnScreenRight; + [self setNeedsLayout]; + } +} + - (void)setBorderWidth:(CGFloat)borderWidth { _borderWidth = borderWidth; _containerView.layer.borderWidth = borderWidth / [[UIScreen mainScreen] scale]; @@ -215,7 +221,7 @@ - (CGFloat)actualWidth { if (unitsPerPoint == 0.0) { return 0.0; } - + CGFloat width = self.row.distance / unitsPerPoint; if (width <= MGLScaleBarMinimumBarWidth) { @@ -229,7 +235,7 @@ - (CGFloat)actualWidth { - (CGFloat)maximumWidth { // TODO: Consider taking Scale Bar margins into account here. CGFloat fullWidth = CGRectGetWidth(self.superview.bounds); - return floorf(fullWidth / 2); + return floorf(fullWidth / 2 - 16); } - (CGFloat)unitsPerPoint { @@ -285,41 +291,14 @@ - (MGLRow)preferredRow { #pragma mark - Setters - (void)setMetersPerPoint:(CLLocationDistance)metersPerPoint { - if (_metersPerPoint == metersPerPoint) { + _metersPerPoint = metersPerPoint; + + if (self.isHidden) { return; } - _metersPerPoint = metersPerPoint; - [self updateVisibility]; - self.recalculateSize = YES; - [self invalidateIntrinsicContentSize]; -} - -- (CGSize)intrinsicContentSize { - // Size is calculated elsewhere - since intrinsicContentSize is part of the - // constraint system, this should be done in updateConstraints - if (self.size.width < 0.0) { - return CGSizeZero; - } - return self.size; -} - -/// updateConstraints -/// -/// The primary job of updateConstraints here is to recalculate the -/// intrinsicContentSize: _metersPerPoint and the maximum width determine the -/// current "row", which in turn determines the "actualWidth". To obtain the full -/// width of the scale bar, we also need to include some space for the "last" -/// label - -- (void)updateConstraints { - if (self.isHidden || !self.recalculateSize) { - [super updateConstraints]; - return; - } - // TODO: Improve this (and the side-effects) self.row = [self preferredRow]; @@ -328,7 +307,6 @@ - (void)updateConstraints { CGFloat totalBarWidth = self.actualWidth; if (totalBarWidth <= 0.0) { - [super updateConstraints]; return; } @@ -344,10 +322,11 @@ - (void)updateConstraints { CGFloat halfLabelWidth = ceil(self.lastLabelWidth/2); - self.size = CGSizeMake(totalBarWidth + halfLabelWidth, 16); - - [self setNeedsLayout]; - [super updateConstraints]; // This calls intrinsicContentSize + CGSize newSize = CGSizeMake(totalBarWidth + halfLabelWidth, self.bounds.size.height); + if (!CGSizeEqualToSize(self.size, newSize)) { + self.size = newSize; + [self setNeedsLayout]; + } } - (void)updateVisibility { @@ -474,12 +453,6 @@ - (void)updateLabels { - (void)layoutSubviews { [super layoutSubviews]; - if (!self.recalculateSize) { - return; - } - - self.recalculateSize = NO; - // If size is 0, then we keep the existing layout (which will fade out) if (self.size.width <= 0.0) { return; @@ -498,21 +471,21 @@ - (void)layoutSubviews { } // Re-layout the component bars and labels of the scale bar - CGFloat intrinsicContentHeight = self.intrinsicContentSize.height; CGFloat barWidth = totalBarWidth/self.bars.count; BOOL RTL = [self usesRightToLeftLayout]; CGFloat halfLabelWidth = ceil(self.lastLabelWidth/2); CGFloat barOffset = RTL ? halfLabelWidth : 0.0; - self.containerView.frame = CGRectMake(barOffset, - intrinsicContentHeight - MGLBarHeight, + CGFloat containerViewX = self.isOnScreenRight ? self.bounds.size.width - totalBarWidth - barOffset : barOffset; + self.containerView.frame = CGRectMake(containerViewX, + self.bounds.size.height - MGLBarHeight, totalBarWidth, MGLBarHeight); [self layoutBarsWithWidth:barWidth]; - CGFloat yPosition = round(0.5 * ( intrinsicContentHeight - MGLBarHeight)); + CGFloat yPosition = round(0.5 * (self.bounds.size.height - MGLBarHeight)); CGFloat barDelta = RTL ? -barWidth : barWidth; [self layoutLabelsWithOffset:barOffset delta:barDelta yPosition:yPosition]; } @@ -548,7 +521,8 @@ - (void)layoutLabelsWithOffset:(CGFloat)barOffset delta:(CGFloat)barDelta yPosit // Label frames have 0 size - though the layer contents use "center" and do // not clip to bounds. This way we don't need to worry about positioning the // label. (Though you won't see the label in the view debugger) - label.frame = CGRectMake(xPosition, yPosition, 0.0, 0.0); + CGFloat labelX = self.isOnScreenRight ? self.bounds.size.width - xPosition : xPosition; + label.frame = CGRectMake(labelX, yPosition, 0.0, 0.0); xPosition += barDelta; } diff --git a/platform/ios/test/MGLMapViewLayoutTests.m b/platform/ios/test/MGLMapViewLayoutTests.m index 5ee01ee5bf..3cdd51c504 100644 --- a/platform/ios/test/MGLMapViewLayoutTests.m +++ b/platform/ios/test/MGLMapViewLayoutTests.m @@ -281,8 +281,7 @@ - (void)testScalebarSubviewPlacement { NSArray *testDataList = [self makeTestDataListWithView:scaleBar margin:margin]; - CGSize initialSize = scaleBar.intrinsicContentSize; - XCTAssert(CGSizeEqualToSize(initialSize, scaleBar.bounds.size)); + CGSize initialSize = scaleBar.bounds.size; for (MGLOrnamentTestData *testData in testDataList) { self.mapView.scaleBarPosition = testData.position; diff --git a/platform/ios/test/MGLMapViewScaleBarTests.m b/platform/ios/test/MGLMapViewScaleBarTests.m index b4f81ef62b..1dc5774bf9 100644 --- a/platform/ios/test/MGLMapViewScaleBarTests.m +++ b/platform/ios/test/MGLMapViewScaleBarTests.m @@ -37,13 +37,13 @@ - (void)testShowsScale { // Scale bar should not be visible at default zoom (~z0), but it should be ready. // Size is not a measure of readiness here though. - XCTAssertTrue(CGSizeEqualToSize(scaleBar.intrinsicContentSize, CGSizeZero)); + XCTAssertTrue(CGSizeEqualToSize(scaleBar.bounds.size, CGSizeZero)); XCTAssertEqual(scaleBar.alpha, 0); self.mapView.zoomLevel = 15; [self.mapView layoutIfNeeded]; XCTAssertGreaterThan(scaleBar.alpha, 0); - XCTAssertFalse(CGSizeEqualToSize(scaleBar.intrinsicContentSize, CGSizeZero)); + XCTAssertFalse(CGSizeEqualToSize(scaleBar.bounds.size, CGSizeZero)); } - (void)testDirectlySettingScaleBarViewHiddenProperty { @@ -53,18 +53,18 @@ - (void)testDirectlySettingScaleBarViewHiddenProperty { XCTAssertFalse(scaleBar.hidden); // Directly setting `.hidden` after the map has finished initializing will not update the scale bar. - XCTAssertTrue(CGSizeEqualToSize(scaleBar.intrinsicContentSize, CGSizeZero)); + XCTAssertTrue(CGSizeEqualToSize(scaleBar.bounds.size, CGSizeZero)); // ... but triggering any camera event will update it. self.mapView.zoomLevel = 1; [self.mapView layoutIfNeeded]; - XCTAssertTrue(CGSizeEqualToSize(scaleBar.intrinsicContentSize, CGSizeZero)); + XCTAssertFalse(CGSizeEqualToSize(scaleBar.bounds.size, CGSizeZero)); XCTAssertEqual(scaleBar.alpha, 0); self.mapView.zoomLevel = 15; [self.mapView layoutIfNeeded]; XCTAssertGreaterThan(scaleBar.alpha, 0); - XCTAssertFalse(CGSizeEqualToSize(scaleBar.intrinsicContentSize, CGSizeZero)); + XCTAssertFalse(CGSizeEqualToSize(scaleBar.bounds.size, CGSizeZero)); }@end From e109b9b6eef1e90848e5f1c990fe020aa53dc944 Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Fri, 16 Oct 2020 17:31:05 -0400 Subject: [PATCH 4/6] Bump version to 6.2.2 --- .../ios/Integration Test Harness/Info.plist | 4 ++-- platform/ios/Integration Tests/Info.plist | 4 ++-- .../Mapbox-iOS-SDK-snapshot-dynamic.podspec | 6 +++--- platform/ios/Mapbox-iOS-SDK-stripped.podspec | 6 +++--- platform/ios/Mapbox-iOS-SDK.podspec | 6 +++--- platform/ios/app/Info.plist | 4 ++-- platform/ios/benchmark/Info.plist | 4 ++-- platform/ios/framework/Info-static.plist | 4 ++-- platform/ios/framework/Info.plist | 4 ++-- platform/ios/ios.xcodeproj/project.pbxproj | 18 +++++++++--------- platform/ios/test/Info.plist | 4 ++-- 11 files changed, 32 insertions(+), 32 deletions(-) diff --git a/platform/ios/Integration Test Harness/Info.plist b/platform/ios/Integration Test Harness/Info.plist index a8bd44b034..992e4bd399 100644 --- a/platform/ios/Integration Test Harness/Info.plist +++ b/platform/ios/Integration Test Harness/Info.plist @@ -17,9 +17,9 @@ CFBundlePackageType APPL CFBundleShortVersionString - 6.2.1 + 6.2.2 CFBundleVersion - 15271 + 15275 LSRequiresIPhoneOS UILaunchStoryboardName diff --git a/platform/ios/Integration Tests/Info.plist b/platform/ios/Integration Tests/Info.plist index ed1e6dedbc..494ebd1271 100644 --- a/platform/ios/Integration Tests/Info.plist +++ b/platform/ios/Integration Tests/Info.plist @@ -15,8 +15,8 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 6.2.1 + 6.2.2 CFBundleVersion - 15271 + 15275 diff --git a/platform/ios/Mapbox-iOS-SDK-snapshot-dynamic.podspec b/platform/ios/Mapbox-iOS-SDK-snapshot-dynamic.podspec index d1e6beb2e2..d9f797cfe3 100644 --- a/platform/ios/Mapbox-iOS-SDK-snapshot-dynamic.podspec +++ b/platform/ios/Mapbox-iOS-SDK-snapshot-dynamic.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |m| - version = '6.2.1' + version = '6.2.2' m.name = 'Mapbox-iOS-SDK-snapshot-dynamic' m.version = "#{version}-snapshot" @@ -10,9 +10,9 @@ Pod::Spec.new do |m| m.homepage = 'https://docs.mapbox.com/ios/maps/' m.license = { :type => 'BSD', :file => 'LICENSE.md' } m.author = { 'Mapbox' => 'mobile@mapbox.com' } - m.screenshot = "https://docs.mapbox.com/ios/api/maps/#{version}/img/screenshot.png" + m.screenshot = "https://docs.mapbox.com/ios/maps/api/#{version}/img/screenshot.png" m.social_media_url = 'https://twitter.com/mapbox' - m.documentation_url = 'https://docs.mapbox.com/ios/api/maps/' + m.documentation_url = 'https://docs.mapbox.com/ios/maps/api/' m.source = { :http => "https://mapbox.s3.amazonaws.com/mapbox-gl-native/ios/builds/mapbox-ios-sdk-snapshot-dynamic.zip", diff --git a/platform/ios/Mapbox-iOS-SDK-stripped.podspec b/platform/ios/Mapbox-iOS-SDK-stripped.podspec index d111e22dde..6d48a50be5 100644 --- a/platform/ios/Mapbox-iOS-SDK-stripped.podspec +++ b/platform/ios/Mapbox-iOS-SDK-stripped.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |m| - version = '6.2.1' + version = '6.2.2' m.name = 'Mapbox-iOS-SDK-stripped' m.version = "#{version}-stripped" @@ -10,9 +10,9 @@ Pod::Spec.new do |m| m.homepage = 'https://docs.mapbox.com/ios/maps/' m.license = { :type => 'BSD', :file => 'LICENSE.md' } m.author = { 'Mapbox' => 'mobile@mapbox.com' } - m.screenshot = "https://docs.mapbox.com/ios/api/maps/#{version}/img/screenshot.png" + m.screenshot = "https://docs.mapbox.com/ios/maps/api/#{version}/img/screenshot.png" m.social_media_url = 'https://twitter.com/mapbox' - m.documentation_url = 'https://docs.mapbox.com/ios/api/maps/' + m.documentation_url = 'https://docs.mapbox.com/ios/maps/api/' m.source = { :http => "https://api.mapbox.com/downloads/v2/mobile-maps/releases/ios/packages/#{version.to_s}/mapbox-ios-sdk-stripped-dynamic.zip", diff --git a/platform/ios/Mapbox-iOS-SDK.podspec b/platform/ios/Mapbox-iOS-SDK.podspec index 34ac6583bc..0fb0a928e5 100644 --- a/platform/ios/Mapbox-iOS-SDK.podspec +++ b/platform/ios/Mapbox-iOS-SDK.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |m| - version = '6.2.1' + version = '6.2.2' m.name = 'Mapbox-iOS-SDK' m.version = version @@ -10,9 +10,9 @@ Pod::Spec.new do |m| m.homepage = 'https://docs.mapbox.com/ios/maps/' m.license = { :type => 'BSD', :file => 'LICENSE.md' } m.author = { 'Mapbox' => 'mobile@mapbox.com' } - m.screenshot = "https://docs.mapbox.com/ios/api/maps/#{version}/img/screenshot.png" + m.screenshot = "https://docs.mapbox.com/ios/maps/api/#{version}/img/screenshot.png" m.social_media_url = 'https://twitter.com/mapbox' - m.documentation_url = 'https://docs.mapbox.com/ios/api/maps/' + m.documentation_url = 'https://docs.mapbox.com/ios/maps/api/' m.source = { :http => "https://api.mapbox.com/downloads/v2/mobile-maps/releases/ios/packages/#{version.to_s}/mapbox-ios-sdk-dynamic.zip", diff --git a/platform/ios/app/Info.plist b/platform/ios/app/Info.plist index 6960fb129d..2bdca71ced 100644 --- a/platform/ios/app/Info.plist +++ b/platform/ios/app/Info.plist @@ -17,11 +17,11 @@ CFBundlePackageType APPL CFBundleShortVersionString - 6.2.1 + 6.2.2 CFBundleSignature MBGL CFBundleVersion - 15271 + 15275 LSRequiresIPhoneOS NSLocationTemporaryUsageDescriptionDictionary diff --git a/platform/ios/benchmark/Info.plist b/platform/ios/benchmark/Info.plist index 2c337a1084..0c5f63038b 100644 --- a/platform/ios/benchmark/Info.plist +++ b/platform/ios/benchmark/Info.plist @@ -17,11 +17,11 @@ CFBundlePackageType APPL CFBundleShortVersionString - 6.2.1 + 6.2.2 CFBundleSignature MBGL CFBundleVersion - 15271 + 15275 LSRequiresIPhoneOS NSHumanReadableCopyright diff --git a/platform/ios/framework/Info-static.plist b/platform/ios/framework/Info-static.plist index b4ef4b1222..bd7349146d 100644 --- a/platform/ios/framework/Info-static.plist +++ b/platform/ios/framework/Info-static.plist @@ -11,11 +11,11 @@ CFBundleName $(PRODUCT_NAME) CFBundleShortVersionString - 6.2.1 + 6.2.2 CFBundleSignature ???? CFBundleVersion - 15271 + 15275 MGLCommitHash $(CURRENT_COMMIT_HASH) MGLSemanticVersionString diff --git a/platform/ios/framework/Info.plist b/platform/ios/framework/Info.plist index e3f51e1cb7..2d1dc65aee 100644 --- a/platform/ios/framework/Info.plist +++ b/platform/ios/framework/Info.plist @@ -15,11 +15,11 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 6.2.1 + 6.2.2 CFBundleSignature ???? CFBundleVersion - 15271 + 15275 MGLCommitHash $(CURRENT_COMMIT_HASH) MGLSemanticVersionString diff --git a/platform/ios/ios.xcodeproj/project.pbxproj b/platform/ios/ios.xcodeproj/project.pbxproj index c806b8c19e..0404c1a206 100644 --- a/platform/ios/ios.xcodeproj/project.pbxproj +++ b/platform/ios/ios.xcodeproj/project.pbxproj @@ -3767,7 +3767,7 @@ CLANG_ENABLE_MODULES = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 15271; + CURRENT_PROJECT_VERSION = 15275; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; GCC_PREPROCESSOR_DEFINITIONS = ""; @@ -3820,7 +3820,7 @@ CODE_SIGN_STYLE = Automatic; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 15271; + DYLIB_CURRENT_VERSION = 15275; DYLIB_INSTALL_NAME_BASE = "@rpath"; ENABLE_BITCODE = YES; GCC_PREPROCESSOR_DEFINITIONS = "NDEBUG=1"; @@ -3844,7 +3844,7 @@ buildSettings = { BITCODE_GENERATION_MODE = bitcode; DEFINES_MODULE = YES; - DYLIB_CURRENT_VERSION = 15271; + DYLIB_CURRENT_VERSION = 15275; LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)", @@ -3966,7 +3966,7 @@ CLANG_ENABLE_MODULES = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 15271; + CURRENT_PROJECT_VERSION = 15275; DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_TESTABILITY = YES; GCC_OPTIMIZATION_LEVEL = 0; @@ -3990,7 +3990,7 @@ CLANG_ENABLE_MODULES = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 15271; + CURRENT_PROJECT_VERSION = 15275; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; GCC_PREPROCESSOR_DEFINITIONS = ""; @@ -4108,7 +4108,7 @@ CODE_SIGN_STYLE = Automatic; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 15271; + DYLIB_CURRENT_VERSION = 15275; DYLIB_INSTALL_NAME_BASE = "@rpath"; ENABLE_BITCODE = YES; INFOPLIST_FILE = framework/Info.plist; @@ -4136,7 +4136,7 @@ DEFINES_MODULE = YES; DEPLOYMENT_POSTPROCESSING = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 15271; + DYLIB_CURRENT_VERSION = 15275; DYLIB_INSTALL_NAME_BASE = "@rpath"; ENABLE_BITCODE = YES; GCC_PREPROCESSOR_DEFINITIONS = "NDEBUG=1"; @@ -4183,7 +4183,7 @@ buildSettings = { BITCODE_GENERATION_MODE = bitcode; DEFINES_MODULE = YES; - DYLIB_CURRENT_VERSION = 15271; + DYLIB_CURRENT_VERSION = 15275; LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)", @@ -4208,7 +4208,7 @@ BITCODE_GENERATION_MODE = bitcode; DEFINES_MODULE = YES; DEPLOYMENT_POSTPROCESSING = YES; - DYLIB_CURRENT_VERSION = 15271; + DYLIB_CURRENT_VERSION = 15275; LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)", diff --git a/platform/ios/test/Info.plist b/platform/ios/test/Info.plist index 6b4d9d7663..b4b6e957b9 100644 --- a/platform/ios/test/Info.plist +++ b/platform/ios/test/Info.plist @@ -15,10 +15,10 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 6.2.1 + 6.2.2 CFBundleSignature ???? CFBundleVersion - 15271 + 15275 From 9016dcf10c8ac4a860f8ca94264d962c530d7414 Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Mon, 19 Oct 2020 10:12:47 -0400 Subject: [PATCH 5/6] Reverse CircleCI change. --- circle.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/circle.yml b/circle.yml index 62862eb193..deb6e66317 100644 --- a/circle.yml +++ b/circle.yml @@ -19,7 +19,7 @@ workflows: - ios-build: matrix: parameters: - xcode: ["11.7.0", "12.0.0"] + xcode: ["11.1.0", "11.7.0"] buildtype: ["Debug", "Release"] - ios-release-template: xcode: "12.0.0" From 965dc28c09e7e0cd9c51895721d9fc5545eee2f9 Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Mon, 19 Oct 2020 10:49:25 -0400 Subject: [PATCH 6/6] Add date. --- platform/ios/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md index f34283463a..29e0483d7e 100644 --- a/platform/ios/CHANGELOG.md +++ b/platform/ios/CHANGELOG.md @@ -2,7 +2,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONTRIBUTING.md](../../CONTRIBUTING.md) to get started. -## 6.2.2 +## 6.2.2 - October 19, 2020 ### 🐞 Bug fixes