2012-10-03 59 views
28

我在苹果商店有一个应用程序,在iOS6更新后,我有MKMapView内的数百个崩溃报告。我无法设法在我的设备上重现崩溃。它看起来像EAGLContext的问题。我们不在应用中使用OpenGL,但在不同的控制器中有多个MKMapView实例。 我在这里发现了一个类似的问题iOS 6 app crashes in EAGLContext when displaying maps但他们使用OpenGL。偶尔iOS 6 MKMapView在initWithFrame中崩溃

这里有回溯:

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 
..... 
+0

你确定这不是因为内存泄漏吗?我遇到了类似的问题,但我已经确定了原因。 iOS 6 MKMapView比以前的版本多用10倍的内存。我的应用程序全都是关于在地图上显示的东西,其占地面积从30MB增加到280MB。我试图解决它,但还没有线索。 – Trein

+0

嗨@trein,例外情况是SIGSEGV,据我所知,这应该是由不良的内存访问引起的。 – Breezeight

回答

25

当用户的背景是我们的应用程序,就像我们弹出一个包含地图子视图的窗口一样,我们遇到了类似的问题。由于地图使用openGL调用,而我们在后台进行,崩溃似乎正在发生。我们必须包装在如下所示的查地图子视图的创建:

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

我们节省掉布尔因此,如果应用程序又回到前台,我们可以在添加子视图来显示。

无论何时,当您以导致重绘操作(例如,添加注释)的方式操作地图时,您都必须执行此操作。

+0

嗨@stuckj,它修复你的崩溃? – Breezeight

+0

仍在等待批准... – stuckj

+0

应用程序在周末获得批准。而且,似乎它已经解决了它。在崩溃报告中没有看到它的报告。 – stuckj

2

我面临着类似的堆栈跟踪。我注意到,在控制台中,它给出了有关实际问题的更多细节:在背景中不能使用GPU。 iOS 5的地图基于图块,因此我假设不使用GPU,但iOS 6中的新地图使用矢量图形,因此使用GPU。因此,过去在背景中的任何地图工作都不再可以。

+0

嗨@hunterhacker,我从用户那里得到这个堆栈跟踪。我无法设法在自己的设备上重现崩溃。你能帮助我重现错误吗? – Breezeight

+0

我无法在模拟器中重新创建它,可能是因为模拟器不使用GPU生成地图。每当我尝试在后台运行时创建新的地图视图以获取有关新用户位置的回调时,轨迹就会可靠地发生。对不起,延迟回复,不知道我应该如何通知评论的答案,但我没有得到它。 – hunterhacker

3
+2

我不使用OpenGL,但Apple为iOS 6地图提供了支持。也许他们应该在这种情况下遵循自己的技术问答?伊克。 –

+0

不好的单词选择。它稍微解释了发生的情况,但在Apple提供的框架(MapKit)负责的情况下,它并不解释如何“解决”问题 –

3

我们发现这种情况的原因在我们的应用程序,所以我想后的情况下,该解决方案将帮助其他人。我们的主视图控制器在显示时监视重要的位置变化,并在隐藏时停止监视。我们的一些用户在此屏幕上遇到了无关的崩溃,这使应用程序无法监控。当一个应用程序注册了重要的位置更改更新时,如果iOS没有运行该应用程序来告诉它新的位置,它实际上会将该应用程序启动到后台。由于我们的应用在第一次出现时会显示地图,因此导致了崩溃。 Apple支持向我们证实,在运行iOS 8.x的32位设备上存在一个错误,如果在应用程序处于后台时更新MapView(或其他OpenGL上下文),则可能会导致崩溃。

我们更改了我们的代码,以便如果应用程序因显着的位置更改而启动,我们会立即停止监视并抛出异常以使应用程序崩溃。这对用户来说是完全不可见的,所以他们没有注意到崩溃,并且防止了进一步的崩溃事件的发生。

- (void)validateLaunchWithOptions:(NSDictionary *)launchOptions 
{ 
    if (launchOptions[@"UIApplicationLaunchOptionsLocationKey"]) { 
     // the app was launched due to a significant location change, which is not valid and causes crashes 
     // prevent this from happening again by disabling significant location monitoring 
     CLLocationManager *locationManager = [[CLLocationManager alloc] init]; 
     [locationManager stopMonitoringSignificantLocationChanges]; 

     // intentionally crashing the app here; it is not in a good state and it needs to be prevented from 
     // getting to any code that would re-enable significant location monitoring 
     @throw [NSException exceptionWithName:@"com.redacted.significantLocationLaunch" 
             reason:@"app may not be launched due to significant location changes" 
            userInfo:@{}]; 
    } 
} 

我们看到上千此崩溃的但无法复制它在我们的测试设备,直到我们想出的原因。如果您想复制它(并确认修复),则在应用程序开始监视重大位置更改后立即发生异常。应用程序崩溃后,请开车。只要您的手机切换手机信号塔,iOS将在后台启动应用程序,您将得到崩溃。我们能够掌握我们的用户手机之一并检查崩溃日志。所有的碰撞事故都是在上下班途中发生的。