On Ventura beta11, login item(background item) automatically turned on after reintallation but an agent failed to initialize.

My app contains a daemon and an agent. So once it is downloaded, my deleloper ID shows on System Settings>General>Login Items (Allow in the Background). but even after uninstalling the app, my developer ID still on the list so it can be turned off anyway.(It is understandable.) When I turn off background item(my developer ID) and reinstall the app, the background item turned on automatically but an agent from my app failed to initialize after reinstallation. On the other hand, the daemon from my app works properly.

I'm concerned that if this happen our users will have no idea why the app or the agent doesn't work even though the background item shows 'on' status.

I summarized the steps and the error messages below. It can be reproduced on Ventura beta 10&11.

  1. Install the app
  2. A Background Item is added with my developer ID
  3. Uninstall the app
  4. My app's background item is still in the Login Items section
  5. Turn off my app's background item.
  6. Reinstall my app.
  7. My app's background item turned on after the installation.
  8. An agent in my app is expected to load but it did not show up.

Error messages found from launchd.log are as follows:

2022-10-06 11:19:06.110655 (gui/501/com...**** [32250]) : Service could not initialize: Untrusted spawn was denied for /Library/LaunchAgents/com.ahnlab.v3mac.v3tray.plist, error 0xa1 - Service cannot be launched because of BTM policy 2022-10-06 11:19:06.110667 (gui/501/com...**** [32250]) : initialization failure: 22A5365d: xpcproxy + 21413 [422][59A833C0-060A-3ADE-A0C2-74CD09766F1D]: 0xa1 2022-10-06 11:19:06.110669 (gui/501/com...**** [32250]) : Untrusted service was denied launch by BTM. Removing.

com...**** is my agent in /Library/LaunchaAgents

Should I consider this matter as a bug or am I missing something?

Accepted Answer

I recommend that you file a bug about this. As you said, it’s easy to imagine your users getting confused by it.

Please post your bug number, just for the record.

One thing to keep in mind though: The “Allow in the Background” list is not a list of things that are enabled to run in the background, but a list of things that are allowed to run in the background. You can see this using the test I described in this post.

Oh, one more thing: Are you installing your items using the new SMAppService API? If not, you should give that a try. It may allow the system to track its state better.

Share and Enjoy

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

The bug report number is FB11696339. Please let me know if there's any update on this issue. And thank you for the information about SMAppService API. The document contains more information that I didn't know. Thanks!

Looking at your FB, I suspect that when you uninstalled the app the agent was garbage collected but the daemon was not. You can examine the data that backs Login Items with the Terminal command sfltool dumpbtm. Please add the output of that to your FB. Items are grouped under a "container" and in the dump a container is listed first, then its related items.Note that daemons are tracked globally under user ID -2, and each user ID has a unique container for global items.

In the logs, also look for logs in the subsystem com.apple.backgroundtaskmanagement for more detail.

Also, FYI you can reset the data with sfltool resetbtm and a reboot.

If this info gives you any insights, please add to the FB. Thanks.

Thanks to Eskimo, this issue was automatically solved by adding AssociatedBundleIdentifiers key as described in https://developer.apple.com/documentation/servicemanagement/updating_helper_executables_from_earlier_versions_of_macos?language=objc Sorry for the late reply. I just closed the bug reports(FB11654595, FB11696339). The problem was the other app that is under the same organization name without AssociatedBundleIdentifiers. Thank you.

The system does not detect an uninstalled app immediately, so if you uninstall it and reinstall it soon afterwards, the info in the database is retained. One trigger for cleaning the database is opening of Login Items Settings. So try this procedure:

  1. Quit System Settings
  2. Uninstall your app
  3. Open System Settings > General > Login Items
  4. Wait a few seconds, then look for your items in Background Items

On another note, check out the launchd plist key AssociatedBundleIdentifiers for grouping your agents and daemons under your app in Login Items. See the man page for "launchd.plist".

On Ventura beta11, login item(background item) automatically turned on after reintallation but an agent failed to initialize.
 
 
Q