偶尔我的应用程序会在启动时崩溃。
这似乎与失败的后台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> )
任何帮助都将不胜感激。
答案 0 :(得分:0)
请参阅https://github.com/AFNetworking/AFNetworking/issues/3380
我认为这将在他们发布AFNetworking 3.1.1(3.1.0是当前版本)时得到解决。
Backporting 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>