summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Bounds <jesse@rebounds.net>2017-10-24 17:40:47 -0700
committerJesse Bounds <jesse@rebounds.net>2017-10-25 13:10:59 -0700
commitb19e7d75629bf876343fce00644c7bfbfba77b66 (patch)
tree508e67129755acfcfce5fcffbe534a18b3ffbff2
parentc9d7951e0d0ab85614ab296573e583ed44dbe7c0 (diff)
downloadqtlocation-mapboxgl-upstream/cherry-pick-10277.tar.gz
[ios] Move scale bar content size invalidation to map viewupstream/cherry-pick-10277
-rw-r--r--platform/ios/src/MGLMapView.mm8
-rw-r--r--platform/ios/src/MGLScaleBar.mm3
2 files changed, 8 insertions, 3 deletions
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index d0d34dbfa9..740555840f 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -1015,6 +1015,14 @@ public:
// This gets called when the view dimension changes, e.g. because the device is being rotated.
- (void)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 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. The only time the scale bar's intrinsic content size _must_ invalidated
+ // is here as a reaction to this object's view dimension changes.
+ [self.scaleBar invalidateIntrinsicContentSize];
+
[super layoutSubviews];
[self adjustContentInset];
diff --git a/platform/ios/src/MGLScaleBar.mm b/platform/ios/src/MGLScaleBar.mm
index 1cf1caf0fe..139dffdfab 100644
--- a/platform/ios/src/MGLScaleBar.mm
+++ b/platform/ios/src/MGLScaleBar.mm
@@ -230,9 +230,6 @@ static const CGFloat MGLFeetPerMeter = 3.28084;
CGRectGetMinY(self.frame),
size.width,
size.height);
-
- [self invalidateIntrinsicContentSize];
- [self setNeedsLayout];
}
- (void)updateVisibility {