Sunday, November 27, 2022
HomeIOS Developmentswift - Crash on iOS 16+ _nw_path_evaluator_call_update_handler_block_invoke NWPathMonitor.pathUpdateHandler callback in Community framework...

swift – Crash on iOS 16+ _nw_path_evaluator_call_update_handler_block_invoke NWPathMonitor.pathUpdateHandler callback in Community framework of apple


Making an attempt to watch community modifications in iOS app with Community framework from apple.

import Basis
import Community

protocol NWPathMonitorInterface {
    var pathUpdateHandler: ((_ newPath: NWPath) -> Void)? {get set}
    func begin(queue: DispatchQueue)
    func cancel()
}

extension NWPathMonitor: NWPathMonitorInterface {}

remaining class ReachabilityManager {
   
   personal(set) var isNetworkAvailable: Bool = false
   personal(set) var connectionType: NWInterface.InterfaceType?
   
   personal let queue: DispatchQueue
   personal var monitor: NWPathMonitorInterface?
   
   public var onUpdateNetworkStatus: ((Bool) -> Void)?
   static let shared = ReachabilityManager(monitor: NWPathMonitor(),
                                           queue: DispatchQueue(label: "com.rapido.networkMonitoring"))

   deinit {
       stopMonitoring()
   }
   
   init(monitor: NWPathMonitorInterface,
        queue: DispatchQueue) {
       self.monitor = monitor
       self.queue = queue
   }
   
   enum ConnectionType {
       case wifi
       case mobile
       case ethernet
   }
   
   public func startMonitoring() {
       if monitor == nil {
           monitor = NWPathMonitor()
       }
       self.monitor?.begin(queue: queue)
       self.monitor?
           .pathUpdateHandler = { [weak self] path in
               guard let self = self else { return }
               self.updateStatus(standing: path.standing)
               self.updateConnectionType(interface: path
                   .availableInterfaces
                   .map(.kind))
       }
   }
   
   
   func updateStatus(standing: NWPath.Standing) {
       isNetworkAvailable = standing == .happy ? true : false
       onUpdateNetworkStatus?(isNetworkAvailable)
   }
   
   func updateConnectionType(interface: [NWInterface.InterfaceType]) {
       connectionType = interface.first
   }
   
   func stopMonitoring() {
       monitor?.cancel()
       monitor = nil
   }
}

Begin Monitoring when utility state change to foreground and cease monitoring when utility enter background

 func applicationDidBecomeActive(_ utility: UIApplication) {
          ReachabilityManager.shared.startMonitoring()
 }

 func applicationDidEnterBackground(_ utility: UIApplication) {
        ReachabilityManager.shared.stopMonitoring()
 }

crash

Including crash log

Crashed: com.apple.root.default-qos
0  libswiftCore.dylib             0x3da1bc _swift_release_dealloc + 32
1  libswiftNetwork.dylib          0x372a4 closure #1 in NWPathMonitor.init(requiredInterfaceType:) + 296
2  libswiftNetwork.dylib          0x2470 thunk for @escaping @callee_guaranteed (@assured OS_nw_path) -> () + 52
3  Community                        0x91dad8 __nw_path_evaluator_call_update_handler_block_invoke + 336
4  libdispatch.dylib              0x24b4 _dispatch_call_block_and_release + 32
5  libdispatch.dylib              0x3fdc _dispatch_client_callout + 20
6  libdispatch.dylib              0x70c8 _dispatch_queue_override_invoke + 788
7  libdispatch.dylib              0x15a6c _dispatch_root_queue_drain + 396
8  libdispatch.dylib              0x16284 _dispatch_worker_thread2 + 164
9  libsystem_pthread.dylib        0xdbc _pthread_wqthread + 228
10 libsystem_pthread.dylib        0xb98 start_wqthread + 8

One unusual factor about crash occur solely in iOS 16+ units and 23% background state. I’m not capable of reproduce this nonetheless domestically as frequency could be very low. Any assistance is appreciated.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments