1 Reply
      Latest reply on May 29, 2019 8:04 AM by eskimo
      OCS1 Level 1 Level 1 (0 points)

        Gentlemen, I'd be grateful for some advice.

         

        We have got a pretty standard setup of an application with a login item helper launched through SMLoginItemSetEnabled. Works properly when we test it, works properly for a vast majority of our users — but for a very small number of users for whom the helper does not launch at all.

         

        In an attempt to find the culprit, I have added (otherwise unnecessary) LMCopyAllJobDictionaries and in the returned dictionaries am searching for one with a "Label" equal to our bundle ID. The result is logged out.

         

        For the unlucky (very rare, but alas sometimes occurring) user case our logs say it works like this:

        1. we call SMLoginItemSetEnabled(bundleID, YES), get return value YES;
        2. we check LMCopyAllJobDictionaries and do get an item with our bundle ID;
        3. the helper does not run though. We wait a long time (a full minute), but the helper still does not launch;
        4. then we clean up and retry: we call SMLoginItemSetEnabled(bundleID, NO), get return value YES;
        5. now we check again LMCopyAllJobDictionaries and this time do not get an item with our bundle ID;
        6. go to 1.

         

        It seems the helper does not launch-and-crash; looks like it is not launched at all (or at most, it crashes before its first log, which happens in one of the +load methods, i.e., very very soon; also, the user for whom the problem happens never seen the helper in the Activity Monitor).

         

        To be frank, we are out of ideas how to find the culprit. Will be very grateful for any reasonable advice what to do to find (and potentially fix) the issue. Is there e.g., some kind of launchd detailed log which would tell us why precisely the helper is not launched upon SMLoginItemSetEnabled(bundleID, YES)?

         

        Thanks!

        OC

        • Re: SMLoginItemSetEnabled fails to launch the helper (rarely)
          eskimo Apple Staff Apple Staff (11,485 points)

          Gentlemen, I'd be grateful for some advice.

          Don’t assume that everyone reading your post falls under the category of gentleman (-:

          Oh, you mean technical advice…

          but for a very small number of users for whom the helper does not launch at all.

          It’s seems very likely that this is the result of a problem in the OS itself.  Does restarting the Mac help?

          If you have a user who’s willing to help, you should send them a minimal test app to see see if this affects all apps using SMJobBless or just your product.  This is useful for two reasons:

          • If your test app fails, you can include it in your bug report.

          • If not, it could still be a bug in the OS but it’d be worthwhile taking a good long look at the difference between your main app and the test app.

          If you file a bug, make sure to include a sysdiagnose log.  See our Bug Reporting > Profiles and Logs page for more.

          Share and Enjoy

          Quinn “The Eskimo!”
          Apple Developer Relations, Developer Technical Support, Core OS/Hardware
          let myEmail = "eskimo" + "1" + "@apple.com"