Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Go dormant before termination #1805

Merged
merged 1 commit into from
Jul 1, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions platform/ios/MGLMapView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ - (void)commonInit

// 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];
Expand Down Expand Up @@ -709,6 +710,18 @@ - (void)layoutSubviews

#pragma mark - Life Cycle -

- (void)willTerminate
{
MGLAssertIsMainThread();

if ( ! self.isDormant)
{
self.dormant = YES;
_mbglMap->pause();
[self.glView deleteDrawable];
}
}

- (void)sleepGL:(__unused NSNotification *)notification
{
MGLAssertIsMainThread();
Expand Down