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

Commit c037edf

Browse files
committed
Create GLKView before binding it and resuming
Or: don’t resume the map until the application has entered the foreground. UIApplicationWillEnterForegroundNotification is posted before UIApplicationDidBecomeActiveNotification, while the application is still in the background. That caused -createGLView to bail but did not cause the rest of -wakeGL: to bail. We would create the GLKView only after attempting to bind it (a no-op), resulting in a black view. Fixes #1855.
1 parent 987d961 commit c037edf

File tree

1 file changed

+4
-18
lines changed

1 file changed

+4
-18
lines changed

platform/ios/MGLMapView.mm

+4-18
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,6 @@ - (void)commonInit
213213
[self createGLView];
214214
}
215215

216-
217216
self.accessibilityLabel = @"Map";
218217
self.backgroundColor = [UIColor clearColor];
219218
self.clipsToBounds = YES;
@@ -251,7 +250,7 @@ - (void)commonInit
251250
//
252251
_annotationIDsByAnnotation = [NSMapTable mapTableWithKeyOptions:NSMapTableStrongMemory valueOptions:NSMapTableStrongMemory];
253252

254-
_annotationImages = [NSMutableDictionary new];
253+
_annotationImages = [NSMutableDictionary dictionary];
255254

256255
std::string defaultSymbolName([MGLDefaultStyleMarkerSymbolName UTF8String]);
257256
_mbglMap->setDefaultPointAnnotationSymbol(defaultSymbolName);
@@ -376,9 +375,7 @@ - (void)commonInit
376375

377376
- (void)createGLView
378377
{
379-
if (_context || [UIApplication sharedApplication].applicationState == UIApplicationStateBackground) {
380-
return;
381-
}
378+
if (_context) return;
382379

383380
// create context
384381
//
@@ -415,17 +412,6 @@ - (void)createGLView
415412
});
416413
}
417414

418-
- (void)viewWillEnterForeground
419-
{
420-
[[NSNotificationCenter defaultCenter] removeObserver:self
421-
name:UIApplicationWillEnterForegroundNotification
422-
object:nil];
423-
[[NSNotificationCenter defaultCenter] removeObserver:self
424-
name:UIApplicationDidBecomeActiveNotification
425-
object:nil];
426-
[self commonInit];
427-
}
428-
429415
- (void)reachabilityChanged:(NSNotification *)notification
430416
{
431417
MGLReachability *reachability = [notification object];
@@ -797,11 +783,11 @@ - (void)wakeGL:(__unused NSNotification *)notification
797783
{
798784
MGLAssertIsMainThread();
799785

800-
[self createGLView];
801-
if (self.isDormant)
786+
if (self.isDormant && [UIApplication sharedApplication].applicationState != UIApplicationStateBackground)
802787
{
803788
self.dormant = NO;
804789

790+
[self createGLView];
805791
[MGLMapboxEvents validate];
806792

807793
self.glSnapshotView.hidden = YES;

0 commit comments

Comments
 (0)