iOS 12版本中核心位置发生奇怪的崩溃

时间:2018-12-07 11:06:27

标签: ios swift core-location

我的代码中发生了与核心位置有关的奇怪崩溃。尝试了很多,但无法找出崩溃的原因。

这是崩溃报告的堆栈竞赛:-

   com.apple.main-thread
0  libsystem_kernel.dylib         0x1f0f53ed0 mach_msg_trap + 8
1  libsystem_kernel.dylib         0x1f0f533a8 mach_msg + 72
2  libxpc.dylib                   0x1f102d0c0 xpc_pipe_routine + 388
3  libxpc.dylib                   0x1f1012db8 _xpc_interface_routine + 204
4  libxpc.dylib                   0x1f1013394 _xpc_look_up_endpoint + 224
5  libxpc.dylib                   0x1f1019870 _xpc_connection_bootstrap_look_up_slow + 212
6  libxpc.dylib                   0x1f101be64 _xpc_connection_init + 540
7  libxpc.dylib                   0x1f101aae8 _xpc_connection_activate_if_needed + 100
8  libxpc.dylib                   0x1f101ab7c xpc_connection_resume + 88
9  CoreLocation                   0x1f82c9fa4 CLClientCreateIso6709Notation + 45656
10 CoreLocation                   0x1f82cbfc8 CLClientCreateIso6709Notation + 53884
11 CoreLocation                   0x1f828395c CLClientStopVehicleHeadingUpdates + 32296
12 Quickride                      0x104a76964 LocationChangeListener.startLocationListener() (LocationChangeListener.swift:124)
13 Quickride                      0x104f8cb0c BaseLiveRideMapViewController.viewWillAppear(_:) (BaseLiveRideMapViewController.swift)
14 Quickride                      0x104f8cc40 @objc BaseLiveRideMapViewController.viewWillAppear(_:) (BaseLiveRideMapViewController.swift)
15 UIKitCore                      0x21de8b8ec -[UIViewController _setViewAppearState:isAnimating:] + 584
16 UIKitCore                      0x21de8bfd0 -[UIViewController __viewWillAppear:] + 140
17 UIKitCore                      0x21ddf2dfc -[UINavigationController _startTransition:fromViewController:toViewController:] + 892
18 UIKitCore                      0x21ddf3abc -[UINavigationController _startDeferredTransitionIfNeeded:] + 1184
19 UIKitCore                      0x21ddf4dbc -[UINavigationController __viewWillLayoutSubviews] + 164
20 UIKitCore                      0x21ddd6fac -[UILayoutContainerView layoutSubviews] + 224
21 UIKitCore                      0x21e8f2ea4 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1380
22 QuartzCore                     0x1f59bac70 -[CALayer layoutSublayers] + 184
23 QuartzCore                     0x1f59bfc00 CA::Layer::layout_if_needed(CA::Transaction*) + 324
24 QuartzCore                     0x1f591e718 CA::Context::commit_transaction(CA::Transaction*) + 340
25 QuartzCore                     0x1f594d04c CA::Transaction::commit() + 608
26 QuartzCore                     0x1f594deb4 CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 92
27 CoreFoundation                 0x1f13577a8 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
28 CoreFoundation                 0x1f135243c __CFRunLoopDoObservers + 412
29 CoreFoundation                 0x1f13529dc __CFRunLoopRun + 1264
30 CoreFoundation                 0x1f13521cc CFRunLoopRunSpecific + 436
31 GraphicsServices               0x1f35c9584 GSEventRunModal + 100
32 UIKitCore                      0x21e44d054 UIApplicationMain + 212
33 Quickride                      0x1049b168c main (AppDelegate.swift:29)
34 libdyld.dylib                  0x1f0e12bb4 start + 4

崩溃发生的代码是:-

 func startLocationListener(){
AppDelegate.getAppDelegate().log.debug("startLocationListener()")
let ridePreferences = UserDataCache.getInstance()?.getLoggedInUserRidePreferences()
if ridePreferences?.locationUpdateAccuracy == 0{
    return
}
UIDevice.current.isBatteryMonitoringEnabled = true
if UIDevice.current.batteryLevel > 0 && UIDevice.current.batteryLevel < 0.15{
    AppDelegate.getAppDelegate().log.debug("Battery level is less so not starting location updates")
    return
}

self.locationManager  = CLLocationManager()
locationManager!.requestWhenInUseAuthorization()
self.locationManager!.desiredAccuracy = kCLLocationAccuracyBestForNavigation
if #available(iOS 9.0, *) {
  self.locationManager!.allowsBackgroundLocationUpdates = true
}

if ridePreferences?.locationUpdateAccuracy == 1{
     self.locationManager!.distanceFilter = Double(AppConfiguration.MIN_DISTANCE_CHANGE_FOR_UPDATES_MEDIUM)
}else if ridePreferences?.locationUpdateAccuracy == 2{
     self.locationManager!.distanceFilter = Double(AppConfiguration.MIN_DISTANCE_CHANGE_FOR_UPDATES_HIGH)
}

self.locationManager!.desiredAccuracy = kCLLocationAccuracyBestForNavigation
self.locationManager!.pausesLocationUpdatesAutomatically = true
self.locationManager!.activityType = CLActivityType.automotiveNavigation
self.locationManager!.delegate = self
self.locationManager!.startUpdatingLocation()

let appDelegate : AppDelegate = UIApplication.shared.delegate as! AppDelegate
appDelegate.startLocationManager()


locationUpdateToServerTask = UserLocationUpdateToServerTask()
if locationManager?.location != nil{
  locationUpdateToServerTask?.setLatestLocation(newLocation: (locationManager?.location)!)
  processLocationUpdate(location: (locationManager?.location)!)
}

根据crashlytics报告,此行发生崩溃:-

  self.locationManager!.pausesLocationUpdatesAutomatically = true

有人可以帮我吗?预先感谢

0 个答案:

没有答案