app在后台使用URLSession多任务下载,手动唤起app后,下载报错
我在背景URLSession中创建了1800个task,然后让App进入后台,过一段时间后(几分钟),手动唤起app进入前台,就会在URLSession的回调中发生了错误。
以下错误在以下delegate中发生:
func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: Error?) {}
BackgroundSession <B43F4169-5B6D-4928-B90F-6F29BC349A91> error requesting a NSURLSessionDownloadTask from background transfer daemon: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.nsurlsessiond was interrupted, but the message was sent over an additional proxy and therefore this proxy has become invalid." UserInfo={NSDebugDescription=The connection to service named com.apple.nsurlsessiond was interrupted, but the message was sent over an additional proxy and therefore this proxy has become invalid.}
原因分析
** 因为开启的task太多了,在后台持续了几分钟,可能有些task还未开始。
当我把任务数量改为160时,没有任何问题**
网友评论