在 applicationDidEnterBackground 方法中停止 MKMapView 位置服务时,我很少遇到崩溃。(我这样做是为了确保我的应用在后台运行时不使用定位服务。)
导致崩溃的代码如下所示:
- (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)。但是我怀疑我的应用程序是否属于这种情况:我已经尝试故意添加带有无效 lat/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)