From 24eff45af20e8fa7bbdd567a9c03da6228cd6678 Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Mon, 16 Sep 2019 11:04:59 -0400 Subject: [ios] report error if rendering takes > 1 second. --- platform/darwin/src/MGLTypes.h | 4 +++- platform/ios/src/MGLMapView+OpenGL.mm | 23 ++++++++++++++++++----- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/platform/darwin/src/MGLTypes.h b/platform/darwin/src/MGLTypes.h index 7e0dd27141..df3c61a61c 100644 --- a/platform/darwin/src/MGLTypes.h +++ b/platform/darwin/src/MGLTypes.h @@ -55,7 +55,9 @@ typedef NS_ENUM(NSInteger, MGLErrorCode) { /** Source is in use and cannot be removed */ MGLErrorCodeSourceIdentifierMismatch = 8, /** An error occurred while modifying the offline storage database */ - MGLErrorCodeModifyingOfflineStorageFailed = 9 + MGLErrorCodeModifyingOfflineStorageFailed = 9, + /** An error occurred while rendering */ + MGLErrorCodeRenderingError = 10, }; /** Options for enabling debugging features in an `MGLMapView` instance. */ diff --git a/platform/ios/src/MGLMapView+OpenGL.mm b/platform/ios/src/MGLMapView+OpenGL.mm index e599024e26..ad30b608e5 100644 --- a/platform/ios/src/MGLMapView+OpenGL.mm +++ b/platform/ios/src/MGLMapView+OpenGL.mm @@ -2,6 +2,11 @@ #import "MGLLoggingConfiguration_Private.h" #import "MGLMapView+OpenGL.h" +#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR +#import "MMEConstants.h" +#import "MGLMapboxEvents.h" +#endif + #include #import @@ -96,7 +101,7 @@ void MGLMapViewOpenGLImpl::setPresentsWithTransaction(const bool value) { void MGLMapViewOpenGLImpl::display() { auto& resource = getResource(); -#ifdef MGL_RECREATE_GL_IN_AN_EMERGENCY + // See https://github.com/mapbox/mapbox-gl-native/issues/14232 // glClear can be blocked for 1 second. This code is an "escape hatch", // an attempt to detect this situation and rebuild the GL views. @@ -106,14 +111,22 @@ void MGLMapViewOpenGLImpl::display() { CFTimeInterval after = CACurrentMediaTime(); if (after - before >= 1.0) { +#ifdef MGL_RECREATE_GL_IN_AN_EMERGENCY dispatch_async(dispatch_get_main_queue(), ^{ emergencyRecreateGL(); }); - } - } - else +#else + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + NSError *error = [NSError errorWithDomain:MGLErrorDomain + code:MGLErrorCodeRenderingError + userInfo:@{ NSLocalizedFailureReasonErrorKey : + @"https://github.com/mapbox/mapbox-gl-native/issues/14232" }]; + [[MMEEventsManager sharedManager] reportError:error]; + }); #endif - { + } + } else { [resource.glView display]; } } -- cgit v1.2.1