XTubeManager error in background?

I experience a lot of crashes in XTubeManager (it seems to be CFNetwork internal). Unfortunately, console logs are not available, but only the call stack (see below).

Questions:

  • I could imagine that my application crashes in the background, so no console logs are written, do you think this is an opportunity?
  • Should I handle the expiration of backgroundTask differently, for example. by canceling all my NSURLRequests ? (see code below)

Background

I regularly wake up in the background (or with a background click) and run the background task as follows:

 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; }); 

This is usually called in applicationDidEnterBackground

Callstack

 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 
+7
ios objective-c nsurlconnection nsurlrequest
source share
1 answer

Some objects within the NSURLConnection stack disappear. Some things to check:

  • Make sure you do not start the connection twice. (If you are not using ... startImmediately:NO , make sure you never call start .)
  • Make sure that you do not start the connection, and then release your last link until the connection is completed.
  • Make sure you are not using synchronous NSURLConnection calls (ever).

In addition, I have seen similar accidents before, and in many cases there is no obvious reason. If you don’t see the high frequency of crashes, you may not be able to fix this except to report a bug, and I hope that Apple will figure out a way to fix it for everyone.

+1
source share

All Articles