diff options
author | m-stephen <truestyle2005@163.com> | 2019-09-20 10:14:44 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-20 10:14:44 +0800 |
commit | 8128d709b62189e0745ea64be3d35e8c6dab59fa (patch) | |
tree | 0cc8d278b0a1f7ca626f5a0e67a4287d4da18ab5 /platform/ios | |
parent | da6a7e9318e911ab03cacde781235b50326770ec (diff) | |
download | qtlocation-mapboxgl-8128d709b62189e0745ea64be3d35e8c6dab59fa.tar.gz |
[ios]Add errors reporting (#15391)
* add errors reporting
* [ios] report error if rendering takes > 1 second. (#15633)
Diffstat (limited to 'platform/ios')
-rw-r--r-- | platform/ios/src/MGLMapView+Impl.mm | 7 | ||||
-rw-r--r-- | platform/ios/src/MGLMapView+OpenGL.mm | 23 |
2 files changed, 25 insertions, 5 deletions
diff --git a/platform/ios/src/MGLMapView+Impl.mm b/platform/ios/src/MGLMapView+Impl.mm index 9cdab4dc63..0b9ab75699 100644 --- a/platform/ios/src/MGLMapView+Impl.mm +++ b/platform/ios/src/MGLMapView+Impl.mm @@ -3,6 +3,10 @@ #import "MGLStyle_Private.h" #import "NSBundle+MGLAdditions.h" +#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR +#import "MMEEventsManager.h" +#endif + std::unique_ptr<MGLMapViewImpl> MGLMapViewImpl::Create(MGLMapView* nativeView) { return std::make_unique<MGLMapViewOpenGLImpl>(nativeView); } @@ -61,6 +65,9 @@ void MGLMapViewImpl::onDidFailLoadingMap(mbgl::MapLoadError mapError, const std: NSLocalizedFailureReasonErrorKey: @(what.c_str()), }; NSError *error = [NSError errorWithDomain:MGLErrorDomain code:code userInfo:userInfo]; +#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR + [[MMEEventsManager sharedManager] reportError:error]; +#endif [mapView mapViewDidFailLoadingMapWithError:error]; } 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]; } } |