iOS 8 NSInternalInconsistencyException

23
我收到以下崩溃报告。它们只会在iOS 8设备上发生。请注意消息:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'this request has been neutered - you can't call -sendResponse: twice nor after encoding it'

崩溃报告:

Date/Time:       2014-08-31T01:39:15Z
OS Version:      iPhone OS 8.0 (12A4345d)
Report Version:  104

Exception Type:  SIGABRT
Exception Codes: #0 at 0x1964cb270
Crashed Thread:  0

Application Specific Information:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'this request has been neutered - you can't call -sendResponse: twice nor after encoding it'

Last Exception Backtrace:
0   CoreFoundation                       0x0000000186192084 CFDateGetTimeIntervalSinceDate + 19604
1   libobjc.A.dylib                      0x0000000195d3c0e4 objc_exception_throw + 56
2   CoreFoundation                       0x0000000186191f44 CFDateGetTimeIntervalSinceDate + 19280
3   Foundation                           0x0000000187075e20 _NSSetExceptionRaiser + 340
4   BaseBoard                            0x000000018c1deb90 BSMainScreenOrientation + 4856
5   libdispatch.dylib                    0x000000019638d254 0x19638c000 + 4692
6   libdispatch.dylib                    0x0000000196395d50 dispatch_barrier_sync_f + 1176
7   BaseBoard                            0x000000018c1deae4 BSMainScreenOrientation + 4684
8   UIKit                                0x000000018ac9df88 _UIBackdropViewSettingsColorCancelRed + 28984
9   libdispatch.dylib                    0x000000019638d294 0x19638c000 + 4756
10  libdispatch.dylib                    0x000000019638d254 0x19638c000 + 4692
11  libdispatch.dylib                    0x000000019639103c _dispatch_main_queue_callback_4CF + 952
12  CoreFoundation                       0x00000001861498dc CFRunLoopTimerSetTolerance + 4196
13  CoreFoundation                       0x0000000186147984 _CFRunLoopGet2b + 3316
14  CoreFoundation                       0x0000000186075664 CFRunLoopRunSpecific + 392
15  GraphicsServices                     0x000000018f0a75a4 GSEventRunModal + 164
16  UIKit                                0x000000018a82e164 UIApplicationMain + 1484
17  Taptalk                              0x00000001000bfccc main (main.m:21)
18  libdyld.dylib                        0x00000001963b2a08 _tlv_bootstrap + 232

我无法重现它,但似乎是在从后台启动应用程序时发生的。 我应该从哪里开始寻找?


你的代码中有没有调用 -sendResponse: 方法? - Moxy
不,看起来像是内部调用。 - Jorn van Dijk
你能调试它吗?还是有人给你发送了崩溃报告? - Moxy
在所有异常上设置断点并跟踪堆栈返回到您的代码。看起来是在 BSMainScreenOrientation 中的某个地方。 - Brad Allred
我从HockeyApp获取这些崩溃报告,但它在我的设备或模拟器上并没有发生。感谢您的提示。 - Jorn van Dijk
1个回答

32

以下回调函数存在漏洞:

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler

在iOS8之后,当您两次调用completionHandler时会导致崩溃。


你是如何触发这个方法的?它是NSNotification协议的一部分吗? - Steven
这应该是以下内容:- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler因此,它是由远程通知触发的 UIApplication 委托方法。 - Jorn van Dijk
1
在我的应用程序中,completionHandler() 被调用了两次,因为它是一个 @escaping 函数,所以所有内容都被获取,导致崩溃。 - Sourabh Shekhar
有没有人有这个函数的Swift变体? - tseboho
它也可以是-(void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler,该方法还使用了一个UIBackgroundFetchResult完成处理程序。 - Michaël

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接