为什么连接回一个iOS背景NSURLSession需要太长时间等待锁,崩溃的应用程序? [英] Why does connecting back to an iOS background NSURLSession take too long waiting on a lock, crashing the app?

查看:620
本文介绍了为什么连接回一个iOS背景NSURLSession需要太长时间等待锁,崩溃的应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么通过其配置连接一个NSURLSession需要这么长的时间,它会崩溃的应用程序启动时:未及时启动?

Why would connecting with an NSURLSession through its configuration take so long that it would crash the app on start up: 'failed to launch in time'?

在许多iOS应用程序中看到类似的崩溃转储,包括NY Times iOS应用程序和Evernote应用程序。

I've seen similar crash dumps in many iOS apps including NY Times iOS app and Evernote app.

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

这是堆栈跟踪:

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


推荐答案

应用程序特定信息:应用程序无法及时启动(iOS )?

基本上有两件事要注意:

Basically there are 2 things to keep in mind:


  1. 启动时,您只需几秒钟即可完成启动过程。

  1. Upon startup, you only have a few seconds to finish the startup procedure. Any longer running code should be called asynchronously after the app has started.

请务必确保回调/封锁/关闭等中的任何UI程式码。 。在主线程上调用。您必须强制它这样做。

Make absolutely sure that any UI code in your callbacks/blocks/closures/etc... is called on the main thread. You must force it to do so.

这篇关于为什么连接回一个iOS背景NSURLSession需要太长时间等待锁,崩溃的应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆