2

有时我的应用程序在启动时会崩溃。

它似乎与失败的后台 NSURL 会话活动有关。此消息在 Crashlytics 日志中相当一致地出现:

_block_invoke line 233 $ Error Domain=NSURLErrorDomain Code=-997 "Lost connection to background transfer service"

我对如何在 xCode 中调试此问题感到困惑,因为当我的测试设备连接到我的计算机时,我无法让它发生。

我没有在我的应用程序中使用 KVO;也许这是 AFNetworking 本身的问题?

以下是 Crashlytics 报告的崩溃消息:

Fatal Exception: NSInternalInconsistencyException
An instance 0x14f97ef00 of class __NSCFBackgroundDataTask was deallocated while 
key value observers were still registered with it. 
Current observation info: <NSKeyValueObservationInfo 0x14f97f320> ( <NSKeyValueObservance 0x14f841ea0: Observer: 0x14e777340, Key path: countOfBytesReceived, Options: <New: YES, Old: NO, Prior: NO> Context: 0x0, Property: 0x14e650010> <NSKeyValueObservance 0x14e6e1770: Observer: 0x14e777340, Key path: countOfBytesExpectedToReceive, Options: <New: YES, Old: NO, Prior: NO> Context: 0x0, Property: 0x14f81c090> <NSKeyValueObservance 0x14f80e030: Observer: 0x14e777340, Key path: countOfBytesSent, Options: <New: YES, Old: NO, Prior: NO> Context: 0x0, Property: 0x14f97e880> <NSKeyValueObservance 0x14e5ca9c0: Observer: 0x14e777340, Key path: countOfBytesExpectedToSend, Options: <New: YES, Old: NO, Prior: NO> Context: 0x0, Property: 0x14f97cf20> )

任何帮助,将不胜感激。

4

1 回答 1

0

https://github.com/AFNetworking/AFNetworking/issues/3380

我认为这将在他们发布 AFNetworking 3.1.1 时得到解决(3.1.0 是当前版本。)

反向移植https://github.com/AFNetworking/AFNetworking/commit/ff228fad3addd141cc668891b6c3bb9b1b1c4271.patch为我解决了这个问题。

添加这个以防它帮助其他人找到这个问题

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'An instance 0x7fdcb4d099f0 of class __NSCFBackgroundDataTask was deallocated while key value observers were still registered with it. Current observation info: <NSKeyValueObservationInfo 0x60000002da80> (
<NSKeyValueObservance 0x60000005b2d0: Observer: 0x600000283110, Key path: countOfBytesReceived, Options: <New: YES, Old: NO, Prior: NO> Context: 0x0, Property: 0x60000005b300>
<NSKeyValueObservance 0x60000005b660: Observer: 0x600000283110, Key path: countOfBytesExpectedToReceive, Options: <New: YES, Old: NO, Prior: NO> Context: 0x0, Property: 0x60000005b690>
<NSKeyValueObservance 0x60000005b870: Observer: 0x600000283110, Key path: countOfBytesSent, Options: <New: YES, Old: NO, Prior: NO> Context: 0x0, Property: 0x60000005b8a0>
<NSKeyValueObservance 0x60000005ba20: Observer: 0x600000283110, Key path: countOfBytesExpectedToSend, Options: <New: YES, Old: NO, Prior: NO> Context: 0x0, Property: 0x60000005ba50>
于 2016-11-04T18:22:17.967 回答