Post

Replies

Boosts

Views

Activity

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 log messages. 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 UIScreenDelegate, 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? Here's the screenshot of my battery usage page.  i.imgur.com/4XLx3De.jpg  You can see there are two apps running in the background for several hours. It occurs randomly, the only way I know to reproduce this issue is to switch between foreground and background several times and play with it a little bit while. This is the log file screenshot. i.imgur.com/6csMpGF.png As you can see there's a App enters background line which represents the app is in background state. But it's still running in the background. After 2.5 seconds I set my app into a nap state to save battery life. It keeps running for almost an hour.
2
0
2.4k
Jun ’20