I cannot find any documentation regarding this, and even though it makes kind of sense, I find it hard to understand the reasoning behind the difference between the background/default session configurations.
Consider this playground code:
import Foundation
import PlaygroundSupport
let config = URLSessionConfiguration.background(withIdentifier: "test")
var urlSession = URLSession(configuration: config)
let taskOne = urlSession.dataTask(with: URL(string: "url-one")!) // No resume
let taskTwo = urlSession.dataTask(with: URL(string: "url-two")!) // No resume
let taskThree = urlSession.dataTask(with: URL(string: "url-three")!) // Resume
taskThree.resume()
urlSession.getAllTasks { tasks in
let count = tasks.count
}
PlaygroundPage.current.needsIndefiniteExecution = true
Line 11 prints 3 when using a background session configuration, and 1 when using the default one.
How come?
This is not the specific case I'm seeing in my code, but this example illustrates the difference that caused an automatic resume bug for me.