summaryrefslogtreecommitdiff
path: root/platform/ios/src/MGLMapView.mm
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2019-01-09 23:24:40 -0800
committerMinh Nguyễn <mxn@1ec5.org>2019-01-14 15:07:43 -0800
commit6960cb13f7d3d6564de90f5a25884003c33a4c4f (patch)
tree3ea2b5d32bc2d126be1a0bc6789da83dd33bb19b /platform/ios/src/MGLMapView.mm
parentc8c664fbf376b615b3f1e4b2a4d7f1c99b6097be (diff)
downloadqtlocation-mapboxgl-6960cb13f7d3d6564de90f5a25884003c33a4c4f.tar.gz
[ios] Prevent map view on external display from sleeping in background
When the application enters background mode, only put the map view to sleep if it’s installed on the main screen or hasn’t been added to any window. Otherwise, if it’s targeting an external display, such as via AirPlay or CarPlay, allow the map view to continue rendering.
Diffstat (limited to 'platform/ios/src/MGLMapView.mm')
-rw-r--r--platform/ios/src/MGLMapView.mm12
1 files changed, 11 insertions, 1 deletions
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index 4d4bf39123..d188ffb91f 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -1222,7 +1222,7 @@ public:
self.mbglMap.setConstrainMode(mbgl::ConstrainMode::HeightOnly);
}
- _displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(updateFromDisplayLink)];
+ _displayLink = [self.window.screen displayLinkWithTarget:self selector:@selector(updateFromDisplayLink)];
[self updateDisplayLinkPreferredFramesPerSecond];
[_displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes];
_needsDisplayRefresh = YES;
@@ -1301,6 +1301,16 @@ public:
- (void)sleepGL:(__unused NSNotification *)notification
{
+ // If this view targets an external display, such as AirPlay or CarPlay, we
+ // can safely continue to render OpenGL content without tripping
+ // gpus_ReturnNotPermittedKillClient in libGPUSupportMercury, because the
+ // external connection keeps the application from truly receding to the
+ // background.
+ if (self.window.screen != [UIScreen mainScreen])
+ {
+ return;
+ }
+
MGLLogInfo(@"Entering background.");
MGLAssertIsMainThread();