2012-10-03 177 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將在後臺啓動應用程序,您將得到崩潰。我們能夠掌握我們的用戶手機之一併檢查崩潰日誌。所有的碰撞事故都是在上下班途中發生的。