From ec987ca434dbef232102903f16cef5dc189abf4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Wed, 15 Apr 2015 10:18:15 -0700 Subject: [PATCH] Assert that snapshot view obscures GL view when it exists MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Just in case the host app mucks around with `MGLView`’s internal view hierarchy. --- platform/ios/MGLMapView.mm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm index d2ccd7396..e0680df56 100644 --- a/platform/ios/MGLMapView.mm +++ b/platform/ios/MGLMapView.mm @@ -562,7 +562,16 @@ mbgl::DefaultFileSource *mbglFileSource = nullptr; // This is the delegate of the GLKView object's display call. - (void)glkView:(GLKView *)view drawInRect:(CGRect)rect { - if (!self.glSnapshotView) + if (self.glSnapshotView) + { + NSUInteger snapshotIdx = [self.subviews indexOfObject:self.glSnapshotView]; + NSUInteger glIdx = [self.subviews indexOfObject:self.glView]; + NSAssert(snapshotIdx > glIdx, + @"The snapshot view is the %luth subview, behind the GL view, which is the %luth. " + @"The snapshot view should obscure the GL view to prevent crashing while the app is in the background.", + (unsigned long)snapshotIdx, (unsigned long)glIdx); + } + else { mbglView->resize(rect.size.width, rect.size.height, view.contentScaleFactor, view.drawableWidth, view.drawableHeight); mbglMap->renderSync();