Go dormant before termination

Speculative fix for #1460 per https://github.com/mapbox/mapbox-gl-native/issues/1460#issuecomment-99959434.
This commit is contained in:
Minh Nguyễn
2015-06-30 15:35:04 -07:00
parent 6532438fe4
commit b6a0450ef6

View File

@@ -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();