Undead apps, and opting out of App Nap

Just when I thought I was being attacked by zombies, they turn out to be merely the undead.

You will recall my encounter with apps which I thought had quit, but were still hanging around, hiding from the user, waiting for macOS to clean them away. A couple of people have objected to my repurposing the term zombie for them, as it has an established technical meaning which is different in some key respects.

In the absence of anything better, I suggest that they are termed undead apps, which has no other meaning in this context, and should therefore be unambiguous. It also seems a good description as to what they are. And despite my previous assertion, it appears that they can only exist for any length of time in App Nap. Indeed, as I show here, all apps running under macOS Sierra and High Sierra are eligible for App Nap, irrespective of custom settings in their Info.plist file.

Because of the difficulty of looking at the behaviour of such apps, I have created four variants of the same functionless app, StateTest, which are available for download in a single Zip archive from here: StateTestDemo

These differ in two settings in their Info.plist file, for NSSupportsAutomaticTermination and NSAppSleepDisabled. Those are Boolean flags which determine whether the app supports automatic quitting, and whether App Nap should be prevented. Some older versions of OS X allowed you to set the latter in the Finder, but that feature has long been removed.

To discover how these flags affect app state, open each app and ensure that it has a window open, which will prevent it from being quit automatically.

appnap07

All four will then appear where you would expect them to, in the Dock, App Switcher, and the Force Quit dialog. Open Activity Monitor and ensure that you can see the App Nap column there (using the Views/Columns menu). Left in the background, all four will go into App Nap, despite the fact that two of them have NSAppSleepDisabled set to true.

macOS Sierra and High Sierra do not respect the NSAppSleepDisabled flag in Info.plist files: all apps are considered to be eligible for App Nap, provided that they meet its other requirements.

Now, bring each of the four apps to the front, and close their windows, leaving the app to run in the background with no windows open.

appnap08

Two of the apps, those with NSSupportsAutomaticTermination set to true in their Info.plist, will apparently quit. Their icons will be removed from the Dock, they will be lost from App Switcher, and the user will lose access to them. The other two, with NSSupportsAutomaticTermination not set, or set to false, will remain in the Dock and App Switcher.

Leave them in the background for a few minutes, and you will see that, according to Activity Monitor, not only are all four still running, but all four are now in App Nap, irrespective of their NSAppSleepDisabled flags. Prior to that, the two which had apparently ‘quit’ (but had actually become undead) had been undead but not in App Nap, a state which is normally transient.

The final lesson about undead apps comes when you want to be rid of them. Although you can of course force them to quit, on this occasion be nice, and use their Quit command. You now have two apps which have really quit and gone, but two which are undead, and not readily accessible using standard tools such as the Dock or App Switcher. The simplest way is to open their original apps – provided that you are sure that you open the correct version! They appear to load instantly, as they are actually still there, of course. Finally use their Quit command to properly quit each.

When an app’s NSSupportsAutomaticTermination flag is true, if left in the background with no windows open, it will become an undead app.

This only applies to proper apps, and not to command tools, which have to be managed in Terminal.

To recap and update my listing of app states, there are now four basic states for any app in macOS:

  • Running and not napping,
  • Running, in App Nap, and still fully accessible,
  • Running, in App Nap (or shortly to go into it), but hidden from normal user access – undead,
  • Not running at all.

I hope that meets with more general approval.