我在XTubeManager中遇到大量崩溃(似乎是CFNetwork内部)。不幸的是,控制台日志不可用,只有调用堆栈(见下文)。
NSURLRequests
? (见下面的代码)我经常在后台(或通过后台推送)醒来并运行这样的后台任务:
NSString *myTaskName = @"some.random.task.name";
__block UIBackgroundTaskIdentifier taskID = [UIApplication.sharedApplication beginBackgroundTaskWithName:myTaskName expirationHandler:^{
[UIApplication.sharedApplication endBackgroundTask:taskID];
taskID = UIBackgroundTaskInvalid;
}];
dispatch_queue_t q = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_async(q,
// doing some NSURLRequests stuff here
[UIApplication.sharedApplication endBackgroundTask:taskID];
taskID = UIBackgroundTaskInvalid;
});
这通常在applicationDidEnterBackground
Thread : Crashed: com.apple.NSURLConnectionLoader
0 libobjc.A.dylib 0x183599b90 objc_msgSend + 16
1 CFNetwork 0x184513300 XTubeManager::withTubeManager(CoreSchedulingSet const*, void (GlueTubeManager*) block_pointer) + 96
2 CFNetwork 0x18451149c -[__NSURLSessionLocal _withConnectionCache_enqueueRequest:forProtocol:scheduling:options:] + 128
3 CFNetwork 0x1845c3798 HTTPProtocol::asynchronouslyCreateAndOpenStream_WithMessage_AfterCookiesAndAuthenticatorHeaders(__CFHTTPMessage*) + 2000
4 CFNetwork 0x1845c2ef8 HTTPProtocol::asynchronouslyAddAuthenticatorHeadersAndContinue(__CFHTTPMessage*) + 144
5 CFNetwork 0x1845c4ba4 ___ZN12HTTPProtocol35asynchronouslyAddCookiesAndContinueEP15__CFHTTPMessage_block_invoke_2 + 28
6 libdispatch.dylib 0x18396d47c _dispatch_client_callout + 16
答案 0 :(得分:2)
NSURLConnection堆栈内的一些对象正在消失。有些事要检查:
startImmediately:NO
,请确保永远不要致电start
。)除此之外,我之前见过类似的崩溃,在很多情况下没有明显的原因。除非你看到高频率的崩溃,否则除了提交错误之外,可能没有任何方法可以修复它,并希望Apple找到一种方法来解决它。