Device Activity Monitor Extension Sometimes Fails To Launch

The device activity monitor extension sometimes fails to launch when a schedule starts/ends or when an event threshold is reached. This issue may persist for several minutes or hours once it begins.

Currently, the only known workarounds are:

  • Restarting the phone.
  • Waiting for an indeterminate period, ranging from a few minutes to hours, after which the device activity extension may or may not launch.

I've filed a new bug report (FB13556935), which includes a sysdiagnose and precise timestamps of when the issue was reproduced. By looking at the errors, it appears the system is failing to launch the extension because it's looking at an invalid path:

Service could not initialize: access(/private/var/containers/Bundle/Application/C6598B47-8977-447C-870B-4D21BDE8ACF9/Jomo.app/PlugIns/JomoDeviceActivityMonitor.appex/JomoDeviceActivityMonitor, X_OK) failed with errno 2 - No such file or directory, error 0x6f - Invalid or missing Program/ProgramArguments

[u 8104FF60-5C49-45BD-8AFB-97BE88488134:m (null)] [<private>(<private>)] Failed to start plugin; pkd returned an error: Error Domain=PlugInKit Code=4 "RBSLaunchRequest error trying to launch plugin com.jomo.Jomo.JomoDeviceActivityMonitor(8104FF60-5C49-45BD-8AFB-97BE88488134): Error Domain=RBSRequestErrorDomain Code=5 "Launch failed." UserInfo={NSLocalizedFailureReason=Launch failed., NSUnderlyingError=0x5dd8273e0 {Error Domain=NSPOSIXErrorDomain Code=111 "Unknown error: 111" UserInfo={NSLocalizedDescription=Launchd job spawn failed}}}" UserInfo={NSLocalizedDescription=RBSLaunchRequest error trying to launch plugin com.jomo.Jomo.JomoDeviceActivityMonitor(8104FF60-5C49-45BD-8AFB-97BE88488134): Error Domain=RBSRequestErrorDomain Code=5 "Launch failed." UserInfo={NSLocalizedFailureReason=Launch failed., NSUnderlyingError=0x5dd8273e0 {Error Domain=NSPOSIXErrorDomain Code=111 "Unknown error: 111" UserInfo={NSLocalizedDescription=Launchd job spawn failed}}}}

This bug is CRITICAL for all apps relying on the Device Activity framework. It likely explains a range of issues reported since the framework's release. Specifically, due to this bug, end users may encounter problems such as apps not unblocking at the end of a schedule, apps not blocking at the start of a schedule, and time limits not being updated, among others.

This issue seems to be getting worse with each new iOS 17 release. From my debugging, it appears that certain activities like reading / writing to User Defaults, sending analytics events, etc cause the callback functions to terminate early. However the issue is still intermittent. Would love to hear other developers' experience with this issue.

Thank you for contributing to this thread!

I saw in another thread that you were having issues with writing to UserDefaults from the Device Activity Monitor extension. I will check if I can reproduce the issue on my end. Have you filed a bug report with Apple regarding this? If so, could you please provide the report identifier (FBXXXXXXXX) so I can include it in my report?

Regarding the analytics events, if you can reproduce the issue consistently, it's possible that Apple has restricted the ability to make network calls from the extension. If the issue is intermittent, it might be worth examining the memory usage. The Device Activity Monitor extension has a fairly strict memory limit (6MB). I assume you are using a third-party SDK for your analytics. Depending on what they instantiate, along with network calls, you might reach this limit at some point. When that happens, your extension will crash immediately.

Perhaps too unrelated but I'm getting the second error message with the neagent. This happens intermittently and prevents our network extension app from starting properly. Restarting the device seems to solve some of our problems.

Facing the same issue here. For us, the whole process works as expected when we're in debug mode/ when the physical device is connected to Xcode. But when we try the same process after disconnecting the physical device from Xcode or if we try it on release mode, we don't get a callback to the app from the extension where we have the shielding logic in place. Trying to debug this from past 2 days, not able to find any solutions to it.

Same here. Because DeviceActivityMonitor is generally flakey, we emit an event when intervalDidStart isn't called (as determined by intervalDidStart flipping a bit that lives in a UserDefaults container shared with the main app)

Here is a graph of those events, broken down by iOS version on which they occurred.

It is an iOS 17 problem. Contrast that with all app events, broken down by iOS version and which they occurred. iOS 17.4 is way overrepresented in the first, iOS 16.x is way underrepresented.

I think we found a reason on how this can be reproduced - we also only see this happening very often with iOS 17.4 and up.

Please boost: https://forums.developer.apple.com/forums/thread/756959

fyi @_anteloper , @charleswinston , @thomas_maht

Device Activity Monitor Extension Sometimes Fails To Launch
 
 
Q