Why is iOS NSURLSession background connection waiting too long to block, application crash?

Why does connecting to NSURLSession through its configuration take so much time that when it starts, the application will be damaged: "failed to start on time"?

I have seen similar crash dumps in many iOS apps, including the NY Times iOS app and the Evernote app.

[NSURLSession sessionWithConfiguration:configuration delegate:self delegateQueue:queue] 

Here's the stack trace:

 Thread 0: 0 libsystem_kernel.dylib 0x3afb7aa0 semaphore_wait_trap + 8 1 libdispatch.dylib 0x3af04d3d _dispatch_semaphore_wait_slow + 173 2 CFNetwork 0x2febd8e3 -[__NSCFBackgroundSessionBridge setupBackgroundSession] + 379 3 CFNetwork 0x2fef18a1 +[__NSCFSessionBridge bridgeForConfiguration:session:queue:] + 153 4 CFNetwork 0x2fef6497 -[__NSCFURLSession initWithConfiguration:delegate:delegateQueue:] + 395 5 CFNetwork 0x2fef6eb7 +[__NSCFURLSession sessionWithConfiguration:delegate:delegateQueue:] + 295 
+6
source share
1 answer

See Specific Application Information: The application failed to start on time (iOS)? .

There are basically two things to keep in mind:

  • At startup, you only have a few seconds to complete the startup procedure. Any longer executable code should be called asynchronously after the application starts.

  • Make sure any UI code in your callbacks / blocks / closes / etc ... is called in the main thread. You have to get it done.

+1
source

Source: https://habr.com/ru/post/974868/


All Articles