Kimi Chiu
Kimi Chiu

Reputation: 2173

iOS stops moving apps to suspended state in iOS 13.5.1(Keeps running in the background)

I did a little bit more tests today. And I found that iOS does not really suspend the app while it's in the background state anymore. Here's how I test it.

while(true){
    napLock.wait(timeout: .now() + napDelay)
    looperLog.i("running")
}

It's running on a worker thread. When the app is in the background state, the iOS will suspend all activities of this app before iOS 13.5. So there should be no more logs in the console. But after several switching between the foreground state and background state, iOS stops moving this app to the suspended state, so the app keeps running in the background. I think that's why there are so many apps showing a long running background activities in the battery usage page. Because all the apps are in background state rather than suspended state, so the system sees them as running in the background. I haven't migrated to the new UISceneDelegate, so I'm still using AppDelegate to manage window and transitions. If there's some new features about it, shouldn't be applied to my app. This kind of thing changed the whole lifecycle, but there's nothing about it in the release notes. Is there a new implementation while the app entering the background state? How to force my app to be moved to suspended state?

Upvotes: 2

Views: 1351

Answers (1)

narso310
narso310

Reputation: 9

We're seeing this in our app too. The only solution we've found so far is to manually stop things that were running on a timer/schedule that normally would have just been handled by the app being suspended by the OS. Hoping Apple releases a fix for this soon...

Upvotes: 1

Related Questions