Hi all,
I've been trying to test the suspension -> resume behaviour of our app, on iPad (iPadOS 18.3.1), however I'm unable to reliably get the application into a suspended state.
Things I've read that do not work reliably:
- Backgrounding the application and waiting ~1 minute
- Backgrounding the application and opening a bunch of other applications
Sometimes it will work consistently, then other times I can be waiting for 30 minutes or more and it still won't suspend.
If it matters - I'm launching the app via xcode & it's also a capacitor app with a web sockets connection.
Is there any way to reliably suspend an app?
Thanks
Unless your app is using an API that is keeping it running in the background (like location updates), it will suspend quickly.
One exception to this is running the app attached to Xcode, in which case background suspension timings and rules will be relaxed (in order to be able to test/debug app functionality in the background).
Without Xcode app will suspend. But we also need to clarify what you mean by suspend.
"Suspension" technically means the app will still stay in memory but will not be given runtime. When it moves to the foreground (or gets activated in the background due to a background capability), it will resume as it was from where it left.
In your case while testing Backgrounding the application and opening a bunch of other applications, you are likely experiencing a "jetsam", which means the process is terminated and removed from memory. In that case, when the app needs to be activated (either by the user or due to a supported background capability), then it will be relaunched from scratch.
So, you should be clear about what you mean by "suspend". Whether you mean the app is in memory but has stopped running, or the app has been removed from memory in the background.
For true "suspend" all you need is to detach from Xcode, send the app to background and wait. If you have a background capability which is keeping the app running in the background, you may need to temporarily disable that.
To test removal from memory after being suspended, all you need to do is stop the app from Xcode. That will terminate the process right away.
Argun Tekant / DTS Engineer / Core Technologies