本文介绍了iOS 6 MKMapView偶尔会在initWithFrame中崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在苹果商店有一个应用程序,在iOS6更新后,我在 MKMapView 中收到了数百份崩溃报告。我无法在我的设备上重现崩溃。看起来像 EAGLContext 的问题。我们不在我们的应用程序中使用OpenGL,但我们在不同的控制器中有多个 MKMapView 的实例。
我在这里发现了类似的问题但是他们使用OpenGL。

I've an app on the apple store and after the iOS6 update I've got hundred of crash report within MKMapView. I cannot manage to reproduce the crash on my devices. It looks like a problem with EAGLContext. We don't use OpenGL in our app but we have more than one instances of MKMapView in different controller.I've found a similar issue here iOS 6 app crashes in EAGLContext when displaying maps but they use OpenGL.

这里有回溯:

Exception Type:  SIGSEGV
Exception Codes: SEGV_ACCERR at 0x1
Crashed Thread:  0

Thread 0 Crashed:
0   libGPUSupportMercury.dylib          0x00000e22 gpus_ReturnNotPermittedKillClient + 10
1   libGPUSupportMercury.dylib          0x3bccc5fb gldCreateContext + 190
2   GLEngine                            0x344c2b15 gliCreateContextWithShared + 676
3   OpenGLES                            0x0000491d -[EAGLContext initWithAPI:properties:] + 1433
4   OpenGLES                            0x000042d7 -[EAGLContext initWithAPI:sharedWithCompute:] + 143
5   VectorKit                           0x00011c81 -[VGLGPU init] + 105
6   VectorKit                           0x000d4659 __24+[VGLGPU sharedInstance]_block_invoke_0 + 49
7   libdispatch.dylib                   0x000014b7 _dispatch_client_callout + 23
8   libdispatch.dylib                   0x000073f7 dispatch_once_f$VARIANT$mp + 43
9   VectorKit                           0x00011c13 +[VGLGPU sharedInstance] + 39
10  VectorKit                           0x00001db1 -[VKMainLoop updateLinkState] + 485
11  VectorKit                           0x00001955 -[VKScreenCanvas _updateDisplayStatus:] + 109
12  UIKit                               0x0001c371 -[UIView initWithFrame:] + 129
13  VectorKit                           0x00010ca5 -[VGLScreenCanvas initWithFrame:context:] + 53
14  VectorKit                           0x00010a7d -[VKScreenCanvas initWithFrame:context:] + 57
15  VectorKit                           0x00010a3f -[VKScreenCanvas initWithFrame:] + 39
16  VectorKit                           0x000106bd -[VKMapCanvas initWithFrame:shouldRasterize:] + 65
17  VectorKit                           0x000104bb -[VKMapView initWithFrame:andGlobe:shouldRasterize:] + 647
18  MapKit                              0x0000dc95 -[MKMapView _commonInitAndEnableLoading:fromIB:] + 725
19  MapKit                              0x0000d811 -[MKMapView initWithFrame:] + 257
.....


推荐答案

当我们弹出一个包含地图子视图的窗口时,我们遇到了类似的问题。由于地图在我们背景时使用openGL调用,因此崩溃似乎正在发生。我们必须将地图子视图创建包装在如下所示的检查中:

We were having a similar problem when user's background our app just as we're popping up a window that includes a map subview. The crash seemed to be happening due to the map using an openGL call while we're backgrounded. We had to wrap the map subview creation in a check like the following:

UIApplicationState appState = [[UIApplication sharedApplication] applicationState];
    if( (appState != UIApplicationStateBackground) && (appState != UIApplicationStateInactive))
    {
        // Do map subview initialization...
    }
    else
    {
        self.attemptedToLoadMap = YES;
    }

我们保存了bool,以便如果应用程序回到前台我们可以添加子视图以供显示。

We saved off the bool so that if the app comes back to the foreground we can add the subview in for display.

您必须在以导致重新绘制操作的方式操作地图时执行此操作(例如,添加注释)。

You have to do this anytime you're manipulating the map in a way that causes a re-draw operation (e.g., adding an annotation).

这篇关于iOS 6 MKMapView偶尔会在initWithFrame中崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 04:38