diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index 9831c379a12..5ae2d79fc41 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -508,6 +508,9 @@ - (void)dealloc [[NSNotificationCenter defaultCenter] removeObserver:self]; [_attributionButton removeObserver:self forKeyPath:@"hidden"]; + // Removing the annotations unregisters any outstanding KVO observers. + [self removeAnnotations:self.annotations]; + [self validateDisplayLink]; if (_mbglMap) diff --git a/platform/osx/src/MGLMapView.mm b/platform/osx/src/MGLMapView.mm index 6ef93b70cf2..c707ef25719 100644 --- a/platform/osx/src/MGLMapView.mm +++ b/platform/osx/src/MGLMapView.mm @@ -450,6 +450,9 @@ - (void)dealloc { [self.calloutForSelectedAnnotation close]; self.calloutForSelectedAnnotation = nil; + // Removing the annotations unregisters any outstanding KVO observers. + [self removeAnnotations:self.annotations]; + if (_mbglMap) { delete _mbglMap; _mbglMap = nullptr;