Post

Replies

Boosts

Views

Activity

Query background audio permissions
Is there a way for me to programmatically query whether if my AVAudioSession is able to play even when app is minimized/screen is locked? I need this to debug background audio permissions as my AVAudioSession keeps getting paused while app goes into background and it resumes once it goes into the foreground. Moreover, when I try to call setActive for AVAudioSession in didEnterBackground, it gives me the error code 561015905 which says it is permission related. My Info.plist already has <key>UIBackgroundModes</key> <array> <string>audio</string> </array> added to it.
0
0
923
Feb ’22
Downloading many files in the background using NSURLSession
Good day, I have a use case that I am currently facing problems with. I am currently implementing a downloader service that uses some c++ code to download in the foreground, and when the user backgrounds the app, NSURLSession kicks in. Due to chunking, we have a bunch of endpoints that contain ~1mb worth of data for each chunk, and these chunks make up a full file when processed. Small files would be downloaded as is. As such, there might potentially be ten thousands worth of endpoints that NSURLSession might need to download from in the background. From what I've read around here, there are four things to take note of. Resume Rate Limiter Number of tasks queued into nsurlsessiond Number of concurrently running tasks NSUrlSessionDownloadTask creation My current implementation is to create a bunch of tasks in applicationDidEnterBackground(_:) and then starting them all at once. However, NSUrlSessionDownloadTask creation is very expensive. As a reference, it takes 3.7 seconds to create 400 tasks on my iPhone 7+. Upwards of 500 task creation and it runs into the territory of the OS terminating my app as I did not return out of applicationDidEnterBackground(_:) in five seconds. Creation of new tasks when the first batch ends is also not an option because of resume rate limiter. According to here, the delay is really heavy and is something I would like to avoid. Are there any viable solutions that would solve my problem of downloading many files in the background? Thanks in advance!
6
0
2.9k
Feb ’22
Query background audio permissions
Is there a way for me to programmatically query whether if my AVAudioSession is able to play even when app is minimized/screen is locked? I need this to debug background audio permissions as my AVAudioSession keeps getting paused while app goes into background and it resumes once it goes into the foreground. Moreover, when I try to call setActive for AVAudioSession in didEnterBackground, it gives me the error code 561015905 which says it is permission related. My Info.plist already has <key>UIBackgroundModes</key> <array> <string>audio</string> </array> added to it.
Replies
0
Boosts
0
Views
923
Activity
Feb ’22
Downloading many files in the background using NSURLSession
Good day, I have a use case that I am currently facing problems with. I am currently implementing a downloader service that uses some c++ code to download in the foreground, and when the user backgrounds the app, NSURLSession kicks in. Due to chunking, we have a bunch of endpoints that contain ~1mb worth of data for each chunk, and these chunks make up a full file when processed. Small files would be downloaded as is. As such, there might potentially be ten thousands worth of endpoints that NSURLSession might need to download from in the background. From what I've read around here, there are four things to take note of. Resume Rate Limiter Number of tasks queued into nsurlsessiond Number of concurrently running tasks NSUrlSessionDownloadTask creation My current implementation is to create a bunch of tasks in applicationDidEnterBackground(_:) and then starting them all at once. However, NSUrlSessionDownloadTask creation is very expensive. As a reference, it takes 3.7 seconds to create 400 tasks on my iPhone 7+. Upwards of 500 task creation and it runs into the territory of the OS terminating my app as I did not return out of applicationDidEnterBackground(_:) in five seconds. Creation of new tasks when the first batch ends is also not an option because of resume rate limiter. According to here, the delay is really heavy and is something I would like to avoid. Are there any viable solutions that would solve my problem of downloading many files in the background? Thanks in advance!
Replies
6
Boosts
0
Views
2.9k
Activity
Feb ’22