How to find out if an app extension process is alive on iOS?

Hey 👋

I have an extension of type "Device Activity Report Extension".

Is there a way to know from the parent app if the extension process is alive? the process name is DeviceActivityReportService

Why would I like to detect that?

The extension sometimes crashes due to memory pressure and I would like to reload the view automatically when this happens.

This issue happens under normal app use — the user switches quickly between two tabs that have DeviceActivityReport. I filed a bug for this with a sample project to replicate (12192929)

Here is an output from the Console app when the DeviceActivityReportService is killed and the UI disappears:

kernel	memorystatus: killing process 33061 [DeviceActivityReportService] in high band FOREGROUND (100) - memorystatus_available_pages: 68660
kernel	DeviceActivityReportService[33061] Corpse allowed 1 of 5
SpringBoard	[xpcservice<com.apple.DeviceActivityUI.DeviceActivityReportService([application<com.labalab.Screen-Time.marcin>:33046])>:33061] Workspace connection invalidated.
SpringBoard	[xpcservice<com.apple.DeviceActivityUI.DeviceActivityReportService([application<com.labalab.Screen-Time.marcin>:33046])>:33061] Now flagged as pending exit for reason: workspace client connection invalidated
SpringBoard	[FBInterfaceOrientationServiceServer] Removing client xpcservice<com.apple.DeviceActivityUI.DeviceActivityReportService([application<com.labalab.Screen-Time.marcin>:33046])>:33061.
SpringBoard	Removed client for observing orientation events: <FBServiceFacilityServerClientHandle: 0x281fa23a0; com.apple.frontboardservices.orientation-observer; xpcservice<com.apple.DeviceActivityUI.DeviceActivityReportService([application<com.labalab.Screen-Time.marcin>:33046])>:33061: remote>
kernel	266908.072 memorystatus: killing_specific_process pid 33061 [DeviceActivityReportService] (per-process-limit 100) 35873KB - memorystatus_available_pages: 68793
Screen Time	Terminating interface and invalidating assertion: identifier: com.apple.DeviceActivityUI.DeviceActivityReportService; assertion: 0x282316b70
Screen Time	Terminating interface and invalidating connection: identifier: com.apple.DeviceActivityUI.DeviceActivityReportService; assertion: 0x0

Do you have a solution to the same problem we both encountered?

When talking about app extensions there are two different terms in play:

  • The container app is the one in which the app extension is embedded.

  • The host app is the one using the app extension.

Note It’s not uncommon for these to be the same app, but the distinction matters.

The container app and the app extension are created by the same developer. Given that, they may be able to share an app group. A shared app group opens up a variety of IPC options.

The one thing I’m not sure about here is the sandbox for the Device Activity Report extensions. I don’t support Family Controls, so I’m not 100% sure about this, but IIRC these extensions run in a restricted sandbox that prevents it from sharing an app group with its container app.

My suggestion right now is that you try to set up this shared app group. If that fails, this entire line of thought is irrelevant. OTOH, if that works, we can talk about how you might use that app group.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

How to find out if an app extension process is alive on iOS?
 
 
Q