summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Rex <julian.rex@mapbox.com>2019-09-16 11:04:59 -0400
committerJulian Rex <julian.rex@mapbox.com>2019-09-16 11:04:59 -0400
commit24eff45af20e8fa7bbdd567a9c03da6228cd6678 (patch)
tree0fd4f8a3318d980d46cb510cece62764c3de8684
parent636a2df540ee69a14c8c4d8eed8267c4935840b1 (diff)
downloadqtlocation-mapboxgl-upstream/jrex/ios-error-report-tweak.tar.gz
[ios] report error if rendering takes > 1 second.upstream/jrex/ios-error-report-tweak
-rw-r--r--platform/darwin/src/MGLTypes.h4
-rw-r--r--platform/ios/src/MGLMapView+OpenGL.mm23
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 <mbgl/gl/renderable_resource.hpp>
#import <GLKit/GLKit.h>
@@ -96,7 +101,7 @@ void MGLMapViewOpenGLImpl::setPresentsWithTransaction(const bool value) {
void MGLMapViewOpenGLImpl::display() {
auto& resource = getResource<MGLMapViewOpenGLRenderableResource>();
-#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];
}
}