Why AIR Applications Auto-Exit on Mac OS

A user on the Adobe AIR forums recently requested that we change the default behavior of AIR applications running on Mac OS so that they don’t exit when the last window is closed. This changed behavior would, of course, be consistent with the majority of Mac OS applications.

Contrary to what you might suspect, the current behavior was not an oversight on our part; nor was it a result of porting a Windows design to Mac OS. (We have several individuals on our team with significant Mac OS experience and I assure you they wouldn’t stand for that kind of thing.)

The decision makes more sense if you think about it in light of some observations about actual AIR application development:

  • Although the default behavior of Windows applications is to exit when all windows are closed, many developers want to write Windows applications that keep running in this case.
  • Although the default behavior of Mac OS applications is to keep running when all windows are closed, many developers want to write Mac OS applications that exit in this case.
  • An application running without windows open is often a stumbling block for developers coming up to speed on the platform because, when they try to launch the application again, nothing happens by default.

From this one can, I claim, reasonably conclude that defaulting to platform-specific behavior in this case is not worthwhile: most applications either want to keep running on all platforms or exit on all platforms. Second, to ease that developer stumbling block, the default had better be to exit. Thus, NativeApplication.autoExit defaults to “true” on Mac OS, Windows, and Linux.

Any chance we’ll change this in a future release? Not likely. Although patterns of development change, to insure forward compatibility we’d have to keep the current behavior for old applications and introduce the new behavior only for new applications. Even just the switch would introduce yet another thing for developers to learn—and another potential stumbling block. In practice the cost of changing an API’s behavior is quite high, and I don’t think this change would make the cut.

5 Responses to Why AIR Applications Auto-Exit on Mac OS

  1. Rosyna says:

    An application running without windows open is often a stumbling block for developers coming up to speed on the platform because, when they try to launch the application again, nothing happens by default.There is a ‘rapp’ (reopen application) AppleEvent that gets sent just for these type of situations.The user clicks the dock icon, ‘rapp’ is sent to the application, the application sees no windows are open, then it does the same action it would have done if the application was launched after it had quit.

  2. Chris Espinosa says:

    The third point was addressed in Mac OS 8 (!) over a decade ago. Reopening an already-open application sends the kAEReopenApplication event, which your application should respond to by opening a new untitled window, or performing some other “as if just launched” behavior.

  3. Oliver Goldman says:

    I should clarify: When an AIR application is (re-)opened, AIR does deliver an InvokeEvent to the application. Yes, applications can and should respond to this. Furthermore, a framework for building AIR applications could make this its default behavior. But there’s no default behavior for this event, and that’s what sometimes trips up new developers.

  4. Chris Espinosa says:

    Then one might consider that a design bug in the framework, rather than a rationale for deviating from the platform UI standards.

  5. NativeApplication.nativeApplication.autoExit=!NativeApplication.supportsMenu; . I think the way that a Mac AIR application cancels shutdown is a bigger issue. (Possible solved in Cosmo? – I haven’t looked into it).