Detecting Termination and Re-establishing Connection with DeviceActivityReport App Extension

Hello,

I have an iOS app using the DeviceActivityReport app extension. Occasionally, the extension gets terminated (likely due to reaching memory limit**), which in turn disrupts the connection with the main app.

How can the main app detect when the DeviceActivityReport extension has been terminated due to memory constraints, and what's the best way to re-establish the connection afterward?

Thanks in advance for your insights and suggestions!

** I'm also unsure why the extension should be reaching its memory limit. When profiling the extension in XCode, it never reaches above 15MB, and I know the limit is 100MB. It's not doing anything out of the ordinary - and I've seen very similar complaints about DeviceActivityReport terminating on these forums. Any thoughts on how to prevent termination in the first place would also be super helpful!

Hey ! We encounter similar issues in the past, and didn't find any proper documented way to monitor the DeviceActivityReport extension state, or to prevent crashes from happening. You can provide a way for your user to reload the view himself in case of crash using regular SwiftUI methods.

We've opened several radars, some of them more than a year ago, without any answer at the moment. I would suggest you to do the same, the more they are, the more likely they'll fix it !

Regards !

I've encountered the same issue, but based on my testing, it's not because of the 100MB limit. It's actually because iOS, when it's running low on resources, prioritizes cleaning up processes with lower priority. DeviceActivityReport falls into that category. You can try playing games or watching videos, and it's almost a guaranteed way to reproduce the issue. However, successfully reloading it is indeed quite challenging. I wonder how other apps handle this?

How do you know about that limit? Is it documented anywhere?

Detecting Termination and Re-establishing Connection with DeviceActivityReport App Extension
 
 
Q