Apps on iOS 13 not suspending while backgrounded.?

Recently while doing some debug testing for pushKit VOIP events due to iOS 13 changes around push events waking the app, and while profiling the app in instruments, I came across that it appears that iOS 13 is not suspending my threads the normal 30 seconds or so after the app has been backgrounded. while testing from xcode 10.3 on an iOS 12.4.2 iPhone 6 and iPhone 5s, i saw behavior as i would expect, with a consistent halting of the threads after approx 30 seconds in the background. When i side load the same build from xcode 10.3 archived using a developer release build to an iOS 13.1.3 iPhone X and iPhone 8 device i saw it behave odd. When backgrounding, the threads kept running indefinately, and never suspended.


To rule out something strange with my setup, i build a brand new app, in xcode 10.3 and added a simple run loop callback method from the app delegate:

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        wastetime()
        return true
    }

    func wastetime() {
        delay(0.5) { [weak self] in
            print("wasting time")
            let _ = malloc(300000)
            self?.wastetime()
        }
    }
    
    lazy var dispatchQueue: DispatchQueue = DispatchQueue(label: "test queue")
    
    func delay(_ delay: Double, closure: @escaping () ->()) {
        let deadline = DispatchTime.now() + Double(Int64(delay * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)
        dispatchQueue.asyncAfter(deadline: deadline) {
            DispatchQueue.main.async(execute: closure)
        }
    }


I then ran this on an iOS 12.4.2 device and got the expected behavior. ran it on an iOS 13.1.3 device, and got the non suspending behanvior. I did archive builds signed with a developer cert to rull out any debuging. I then tried in xcode 11 doing the same process and seeing the same behavior where the iOS 12 device suspended its threads and the iOS 13 device did not.


Did something fundametally change with how iOS 13 is suspending applications? This seems like either a really bad bug, or something must have changed fundamental to the understanding of background and app suspension in iOS 13 that does not match any documentation that I can find. ALL documentaton seems to be aligned with the iOS 12 behavior, which is what I expect. iOS 13 behanvir is bad for battery life, and appears to be causing our app to be bing killed bucause it is using to much CPU In the background due to it not being suspended. Is anyone else seeing this behavior? Am I missing something?


Termination Description: SPRINGBOARD, scene-create watchdog transgression: application<redacted>:373 exhausted CPU time allowance of 4.80 seconds | ProcessVisibility: Background | ProcessState: Running | WatchdogEvent: scene-create | WatchdogVisibility: Background | WatchdogCPUStatistics: ( | "Elapsed total CPU time (seconds): 7.260 (user 7.260, system 0.000), 69% CPU", | "Elapsed application CPU time (seconds): 5.230, 50% CPU" | )
Triggered by Thread:  0

Yes! We are seeing this too in our app, what is up with this? We've seen the same behaviour with our React Native application (and also a fresh React Native app with nothing in it). In xcode Instruments tool, we clearly see that the app is going to sleep (and is not using any CPU) after couple of seconds after the app is put in background on iOS 12. On iOS 13, this is a complete different story. The CPU usage is indefinitely up and running.


(Duh... it seems I cannot include any files in there to show you my two instruments saved process)

I read here:

h ttps://medium.com/swlh/handling-background-tasks-in-ios-13-67f717d94b3d


that the value has rbeen educed in iOS13 to 30 s

As you can read from the above code snippit, there is no Background task scheduling, and they are being launched not as a debug build but archived and sideloaded as a developer signed build using the release configuration, so i would expect them to be suspended immediately or within about 30 seconds. instead i have gone 10 to 20 minutes with all threads still active, and a heartbeat of "wasting time" printing to the device console about every half second. This is the same in any device with iOS 13 that i run it on from xcode 10.3 or xcode 11. When i run on iOS 12 devices, it behaves as expected, and according to this article.


If iOS 13 runs this way, there is no need for background task execution, because all my threads are live indefinately, even in the background.


I do agree with the article. Quinn "The Eskimo!" is amazing.

"zeus2366". were you able to figure out anything here?
Apps on iOS 13 not suspending while backgrounded.?
 
 
Q