summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Loer <chris.loer@gmail.com>2018-02-13 14:33:07 -0800
committerChris Loer <chris.loer@mapbox.com>2018-02-14 10:55:16 -0800
commitd4df044ffe2234e3d14d1d86727372cd8e4953d8 (patch)
treea563444294e026ee4e2e55cabf6b6838a4cb2ce4
parenta11b277bc19bdf142dcc85927f4e7d7acaeb3ff1 (diff)
downloadqtlocation-mapboxgl-d4df044ffe2234e3d14d1d86727372cd8e4953d8.tar.gz
[ios] Release cached tiles on entering background.
Retain current render tiles for fast restart. Waiting for a memory warning doesn't work because we can't make GL release calls once we're in the background.
-rw-r--r--platform/ios/src/MGLMapView.mm7
1 files changed, 7 insertions, 0 deletions
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index e6712ba5e6..6f2d5039be 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -1158,6 +1158,13 @@ public:
- (void)sleepGL:(__unused NSNotification *)notification
{
MGLAssertIsMainThread();
+
+ // Ideally we would wait until we actually received a memory warning but the bulk of the memory
+ // we have to release is tied up in GL buffers that we can't touch once we're in the background.
+ // Compromise position: release everything but currently rendering tiles
+ // A possible improvement would be to store a copy of the GL buffers that we could use to rapidly
+ // restart, but that we could also discard in response to a memory warning.
+ _rendererFrontend->reduceMemoryUse();
if ( ! self.dormant)
{