使用iOS中的NSURLSession,后台上传速度太慢

时间:2021-11-13 21:06:59

I am trying to upload a huge video file using NSURLSession background upload task. I break the file into chunks of 256Kb and upload them. When the app is in foreground the upload of chunks happen real quick (5 seconds for 256Kb). But when the app is pushed to background though the upload continue to happen the speed of it is reduced crazily (5 minutes for 256Kb). Any thing wrong here or any thing I need to take care of ?

我正在尝试使用NSURLSession后台上传任务上传大量视频文件。我将文件分成256Kb的块并上传它们。当应用程序处于前台时,块的上传发生得非常快(256Kb为5秒)。但是当应用程序被推送到后台虽然上传继续发生,但它的速度却疯狂减少(256Kb为5分钟)。这里有什么问题或我需要照顾的任何事情吗?

1 个解决方案

#1


6  

When your app is in the background, the user has indicated that whatever it's doing is not as important as something else. The system will throttle the background network tasks because they are not as important.

当您的应用程序处于后台时,用户已表示无论其正在做什么都不如其他内容重要。系统将限制后台网络任务,因为它们并不重要。

There is also the discretionary property on the configuration object which will, among other things, prefer to download when connected to power and wi-fi. If the download is initiated while the app is in the background, the download will behave as if the discretionary flag were true.

配置对象上还有*选择属性,除了其他功能之外,还需要在连接到电源和Wi-Fi时下载。如果在应用程序处于后台时启动下载,则下载的行为就像任意标记为真。

#1


6  

When your app is in the background, the user has indicated that whatever it's doing is not as important as something else. The system will throttle the background network tasks because they are not as important.

当您的应用程序处于后台时,用户已表示无论其正在做什么都不如其他内容重要。系统将限制后台网络任务,因为它们并不重要。

There is also the discretionary property on the configuration object which will, among other things, prefer to download when connected to power and wi-fi. If the download is initiated while the app is in the background, the download will behave as if the discretionary flag were true.

配置对象上还有*选择属性,除了其他功能之外,还需要在连接到电源和Wi-Fi时下载。如果在应用程序处于后台时启动下载,则下载的行为就像任意标记为真。