summaryrefslogtreecommitdiff
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
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.
-rw-r--r--platform/ios/CHANGELOG.md2
-rw-r--r--platform/ios/src/MGLMapView.mm12
2 files changed, 12 insertions, 2 deletions
diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md
index bcd54800c8..58413b3184 100644
--- a/platform/ios/CHANGELOG.md
+++ b/platform/ios/CHANGELOG.md
@@ -9,7 +9,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT
* Fixed a bug where the `animated` parameter to `-[MGLMapView selectAnnotation:animated:]` was being ignored. ([#13689](https://github.com/mapbox/mapbox-gl-native/pull/13689))
* Reinstates version 11 as the default Mapbox Streets style (as introduced in 4.7.0). ([#13690](https://github.com/mapbox/mapbox-gl-native/pull/13690))
* Added the `-[MGLShapeSource leavesOfCluster:offset:limit:]`, `-[MGLShapeSource childrenOfCluster:]`, `-[MGLShapeSource zoomLevelForExpandingCluster:]` methods for inspecting a cluster in an `MGLShapeSource`s created with the `MGLShapeSourceOptionClustered` option. Feature querying now returns clusters represented by `MGLPointFeatureCluster` objects (that conform to the `MGLCluster` protocol). ([#12952](https://github.com/mapbox/mapbox-gl-native/pull/12952)
-
+* `MGLMapView` no longer freezes on external displays connected through AirPlay or CarPlay when the main device’s screen goes to sleep or the user manually locks the screen. ([#13701](https://github.com/mapbox/mapbox-gl-native/pull/13701))
## 4.7.1 - December 21, 2018
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();