From b6a0450ef6394da5c5123be41dab51d8af75fb6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Tue, 30 Jun 2015 15:35:04 -0700 Subject: [PATCH] Go dormant before termination Speculative fix for #1460 per https://github.com/mapbox/mapbox-gl-native/issues/1460#issuecomment-99959434. --- platform/ios/MGLMapView.mm | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm index 4957a0329..982a3e297 100644 --- a/platform/ios/MGLMapView.mm +++ b/platform/ios/MGLMapView.mm @@ -367,6 +367,7 @@ std::chrono::steady_clock::duration secondsAsDuration(float duration) // observe app activity // + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(willTerminate) name:UIApplicationWillTerminateNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sleepGL:) name:UIApplicationWillResignActiveNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sleepGL:) name:UIApplicationDidEnterBackgroundNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(wakeGL:) name:UIApplicationWillEnterForegroundNotification object:nil]; @@ -709,6 +710,18 @@ std::chrono::steady_clock::duration secondsAsDuration(float duration) #pragma mark - Life Cycle - +- (void)willTerminate +{ + MGLAssertIsMainThread(); + + if ( ! self.isDormant) + { + self.dormant = YES; + _mbglMap->pause(); + [self.glView deleteDrawable]; + } +} + - (void)sleepGL:(__unused NSNotification *)notification { MGLAssertIsMainThread();