2012-09-17 28 views
0

在applicationDidEnterBackground方法中停止MKMapView位置服務時,我收到了非常罕見的崩潰。 (我這樣做是爲了保證當應用程序在後臺我的應用程序不使用位置服務)停止MKMapKit位置服務時發生定期崩潰

這引起了崩潰的代碼如下所示:

- (void)MyAppDelegate applicationDidEnterBackground:(UIApplication *app) { 
    [self.baseAppViewController stopUserTracking]; 
} 

的stopUserTracking方法執行以下操作:

-(void)stopUserTracking { 
    [baseAppViewController.mapView setUserTrackingMode:MKUserTrackingModeNone]; 
    [baseAppViewController.mapView setShowsUserLocation:NO]; 
} 

請注意,baseAppViewController永遠不會被應用程序釋放; mapView也不是。 baseAppViewController是其mapView的代表。代表從未設置爲零。

以下是堆棧跟蹤,以對MKNormalizedPointForLayer的調用結束。我在其他地方讀過MKNormalizedPointForLayer可能是由於一個無效註釋latlng(http://stackoverflow.com/questions/9766272/error-in-main-thread-mknormalizedpointforlayer)。不過,我懷疑這是我的應用程序的情況:我試圖有目的地添加註釋與無效的經度/ lngs,並沒有得到這個錯誤。由於MKTilesRequireGoogleLegalNotices調用而發生這一事實,這一事實很有趣,但卻令人費解。有什麼想法嗎?

Thread 0 Crashed: 
0 MapKit        0x32b5de94 MKNormalizedPointForLayer + 28043 
1 MapKit        0x32b5dd8f MKNormalizedPointForLayer + 27782 
2 MapKit        0x32b5dca3 MKNormalizedPointForLayer + 27546 
3 MapKit        0x32b6b901 MKTilesRequireGoogleLegalNotices + 44500 
4 MapKit        0x32b69eed MKTilesRequireGoogleLegalNotices + 37824 
5 MapKit        0x32b50673 MKTileSupportsTileSetStyle + 15378 
6 MyApp       0x00040061 -[BaseAppViewController stopUserTracking] (BaseAppViewController.m:785) 
7 MyApp       0x0001e3c9 -[MyAppDelegate applicationDidEnterBackground:] (MyAppDelegate.m:325) 
8 UIKit        0x334fd235 -[UIApplication _handleApplicationSuspend:eventInfo:] + 760 
9 UIKit        0x3348deff -[UIApplication handleEvent:withNewEvent:] + 2094 
10 UIKit        0x3348d567 -[UIApplication sendEvent:] + 54 
11 MyApp       0x000fcb41 -[UIApplication(HMCustom) customSendEvent:] + 85 
12 UIKit        0x3348cf3b _UIApplicationHandleEvent + 5826 
13 GraphicsServices     0x3764c22b PurpleEventCallback + 882 
14 CoreFoundation      0x35a2d523 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 38 
15 CoreFoundation      0x35a2d4c5 __CFRunLoopDoSource1 + 140 
16 CoreFoundation      0x35a2c313 __CFRunLoopRun + 1370 
17 CoreFoundation      0x359af4a5 CFRunLoopRunSpecific + 300 
18 CoreFoundation      0x359af36d CFRunLoopRunInMode + 104 
19 GraphicsServices     0x3764b439 GSEventRunModal + 136 
20 UIKit        0x334bbcd5 UIApplicationMain + 1080 
21 MyApp       0x000026d3 main (main.m:27) 

Thread 1: 
0 libsystem_kernel.dylib    0x362ff3a8 kevent + 24 
1 libdispatch.dylib     0x348e9c29 _dispatch_mgr_wakeup + 0 

Thread 2: 
0 libsystem_kernel.dylib    0x362ff004 mach_msg_trap + 20 
1 CoreFoundation      0x35a2d3f3 __CFRunLoopServiceMachPort + 126 
2 CoreFoundation      0x35a2c12b __CFRunLoopRun + 882 
3 CoreFoundation      0x359af4a5 CFRunLoopRunSpecific + 300 
4 CoreFoundation      0x359af36d CFRunLoopRunInMode + 104 
5 WebCore        0x318aeca3 _ZL12RunWebThreadPv + 402 
6 libsystem_c.dylib     0x32e1c735 _pthread_start + 320 

Thread 3: 
0 libsystem_kernel.dylib    0x362ff004 mach_msg_trap + 20 
1 CoreFoundation      0x35a2d3f3 __CFRunLoopServiceMachPort + 126 
2 CoreFoundation      0x35a2c12b __CFRunLoopRun + 882 
3 CoreFoundation      0x359af4a5 CFRunLoopRunSpecific + 300 
4 CoreFoundation      0x359af36d CFRunLoopRunInMode + 104 
5 MyApp       0x00033823 LoggerWorkerThread (LoggerClient.m:494) 
6 libsystem_c.dylib     0x32e1c735 _pthread_start + 320 

Thread 4: 
0 libsystem_kernel.dylib    0x3630f570 __select + 20 
1 libsystem_c.dylib     0x32e1c735 _pthread_start + 320 

Thread 5: 
0 libsystem_kernel.dylib    0x362ff004 mach_msg_trap + 20 
1 CoreFoundation      0x35a2d3f3 __CFRunLoopServiceMachPort + 126 
2 CoreFoundation      0x35a2c12b __CFRunLoopRun + 882 
3 CoreFoundation      0x359af4a5 CFRunLoopRunSpecific + 300 
4 CoreFoundation      0x359af36d CFRunLoopRunInMode + 104 
5 Foundation       0x354e8bb9 +[NSURLConnection(Loader) _resourceLoadLoop:] + 308 
6 Foundation       0x354e8a81 -[NSThread main] + 72 
7 Foundation       0x3557c591 __NSThread__main__ + 1048 
8 libsystem_c.dylib     0x32e1c735 _pthread_start + 320 

Thread 6: 
0 libsystem_kernel.dylib    0x362ff004 mach_msg_trap + 20 
1 CoreFoundation      0x35a2d3f3 __CFRunLoopServiceMachPort + 126 
2 CoreFoundation      0x35a2c12b __CFRunLoopRun + 882 
3 CoreFoundation      0x359af4a5 CFRunLoopRunSpecific + 300 
4 CoreFoundation      0x359af36d CFRunLoopRunInMode + 104 
5 MapKit        0x32b4de1d MKTileSupportsTileSetStyle + 5052 
6 Foundation       0x354e8a81 -[NSThread main] + 72 
7 Foundation       0x3557c591 __NSThread__main__ + 1048 
8 libsystem_c.dylib     0x32e1c735 _pthread_start + 320 

Thread 7: 
0 libsystem_kernel.dylib    0x362ff004 mach_msg_trap + 20 
1 CoreFoundation      0x35a2d3f3 __CFRunLoopServiceMachPort + 126 
2 CoreFoundation      0x35a2c12b __CFRunLoopRun + 882 
3 CoreFoundation      0x359af4a5 CFRunLoopRunSpecific + 300 
4 CoreFoundation      0x359af36d CFRunLoopRunInMode + 104 
5 MyApp       0x0007e78b +[ASIHTTPRequest runRequests] + 171 
6 Foundation       0x354e8a81 -[NSThread main] + 72 
7 Foundation       0x3557c591 __NSThread__main__ + 1048 
8 libsystem_c.dylib     0x32e1c735 _pthread_start + 320 

Thread 8: 
0 libsystem_kernel.dylib    0x362ff004 mach_msg_trap + 20 
1 CoreFoundation      0x35a2d3f3 __CFRunLoopServiceMachPort + 126 
2 CoreFoundation      0x35a2c12b __CFRunLoopRun + 882 
3 CoreFoundation      0x359af4a5 CFRunLoopRunSpecific + 300 
4 CoreFoundation      0x359af36d CFRunLoopRunInMode + 104 
5 WebCore        0x318d80d9 _ZN7WebCoreL15runLoaderThreadEPv + 128 
6 libsystem_c.dylib     0x32e1c735 _pthread_start + 320 

Thread 9: 
0 libsystem_kernel.dylib    0x3630fcd4 __workq_kernreturn + 8 

Thread 10: 
0 libsystem_c.dylib     0x32e16cc8 start_wqthread + 0 

Thread 11: 
0 libsystem_kernel.dylib    0x3630fcd4 __workq_kernreturn + 8 

Thread 12: 
0 libsystem_kernel.dylib    0x3630fcd4 __workq_kernreturn + 8 

Thread 13: 
0 libsystem_kernel.dylib    0x3630fcd4 __workq_kernreturn + 8 

Thread 14: 
0 libsystem_kernel.dylib    0x362ff004 mach_msg_trap + 20 
1 CoreFoundation      0x35a2d3f3 __CFRunLoopServiceMachPort + 126 
2 CoreFoundation      0x35a2c12b __CFRunLoopRun + 882 
3 CoreFoundation      0x359af4a5 CFRunLoopRunSpecific + 300 
4 CoreFoundation      0x359af36d CFRunLoopRunInMode + 104 
5 Foundation       0x354dcb75 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 256 
6 MyApp       0x0011d50d +[FlurryHTTPEater sendMethod:to:body:headerFields:timeoutInterval:useWebView:] (FlurryHTTPEater.m:67) 
7 MyApp       0x00126ae9 +[FlurrySession sendSessionsToServerWithTimeout:useWebView:requestAppCircleAds:requestVideoAds:requestAppSpotAds:requestReengageAds:sendCurrentSession:] (FlurrySession.m:1053) 
8 MyApp       0x001265c7 +[FlurrySession sendSessionsToServerForAppCircle] (FlurrySession.m:1016) 
9 Foundation       0x354e8a81 -[NSThread main] + 72 
10 Foundation       0x3557c591 __NSThread__main__ + 1048 
11 libsystem_c.dylib     0x32e1c735 _pthread_start + 320 

Thread 15: 
0 libsystem_kernel.dylib    0x3630fcd4 __workq_kernreturn + 8 

Thread 16: 
0 libsystem_kernel.dylib    0x3630fcd4 __workq_kernreturn + 8 

Thread 17: 
0 libsystem_kernel.dylib    0x3630fcd4 __workq_kernreturn + 8 

Thread 0 crashed with ARM Thread State: 
    r0: 0x00000000  r1: 0x00000000  r2: 0x00000000  r3: 0x41a00000 
    r4: 0x003b3520  r5: 0x003b3520  r6: 0xfffffffc  r7: 0x2fea761c 
    r8: 0x3f01fae8  r9: 0x00000000 r10: 0x0eaec170 r11: 0x3f485f10 
    ip: 0xbff00000  sp: 0x2fea7610  lr: 0x32b548ef  pc: 0x32b5de94 
    cpsr: 0x20080030 

Binary Images: 
    (truncated) 
+0

你曾經解決過這個問題嗎?我面臨着類似的問題。 –

+0

我認爲我們做到了,但從未想出真正的原因。我們關閉了地圖滾動和縮放動畫,並且似乎已經修復了它。我知道不是很滿意。 –

回答

0

我不是100%確定它可能是這樣,但是您的問題可能來自「委託」問題。 嘗試撥打這條線在你的方法stopUserTracking:

baseAppViewController.mapView.delegate = nil; 

這可以防止從地圖信息發送到您的釋放視圖控制器的實例,從而導致你的應用程序崩潰。 一定要添加,當您的應用程序重新加載從後臺此行,以確保您的應用程序能夠正常運作(也許在viewWillAppear中?):

baseAppViewController.mapView.delegate = self; 

如果不解決您的問題,儘量使「殭屍對象」在這裏提到的配置選項中:How do I set up NSZombieEnabled in Xcode 4?它有助於理解在應用程序中發生此類意外錯誤時發生了什麼。