Application Lifecycle

Every Wii U application must go through a general lifecycle:

  1. Starting Up
  2. Running
  3. Shutting Down

Starting Up

Your application must follow specific procedures to startup. For more information on starting up your application, see Starting Up.

Running Your Application

When an application completes the startup procedure, it is running in the foreground.

The Wii U now has the capability of allowing the user to pause and hide an application. If the user presses the HOME Button, your application needs to move to the background. This move is signaled by your application receiving a RELEASE_FOREGROUND message from the system message queue. For more information, see Multicore Processing and the ProcUI Library.

In terms of foreground and background switching, your application has four states:

  1. Running in the Foreground (normal)
  2. Requested to move to Background
  3. Running in the Background
  4. Requested to move to Foreground

Running in the Foreground

When your application is running in the foreground, its operation is normal and all resources are available. For more information on what your application can perform while running in the foreground, see Foreground State.

Request to Move to Background

When the user presses the HOME Button, a RELEASE_FOREGROUND message is sent to your application and you are required to process this event message. This transition is facilitated by transition system messages. For more information about transition messages, see Transition Messages. For more information about the tasks you must perform when your application receives a RELEASE_FOREGROUND message, see Request to Move to the Background. For more information on what your application can perform while running in the background, see Background State.

Request to Move to Foreground

At some point, your background application may receive a ACQUIRED_FOREGROUND message. You must process this message and move back to the foreground. For more information about the tasks you must perform when your application received an ACQUIRED_FOREGROUND message, see Request to Move to the Foreground.

For an overview of process switching, see Multicore Processing on the Wii U.

Shutting Down

Your application must follow specific procedures to shut down. For more information about shutting down your application, see Shutting Down.

Application Process State Diagram

The following diagram shows the possible states that an application goes through in its lifecycle.

  1. This is when main is called
  2. RELEASE_FOREGROUND is retrieved from the system message queue
  3. OSReleaseForeground is called from all three cores
  4. ACQUIRED_FOREGROUND is retrieved from the system message queue
  5. EXIT is retrieved from the system message queue. Application exits from background.
  6. Process is moving to the foreground.
  7. EXIT is retrieved from the system message queue. Application exits from foreground.
IMPORTANT:
When exiting from the background, all three cores are scheduled in a round-robin fashion. This is the only time that a Game can get CPU time on cores 0 and 1 in the background!

Recommendations

Consider two types of games:

Games that put all tasks that must run in background mode and their dependencies on Core 2 avoid the need for complex logic when switching between foreground and background modes.

If the game distributes FS and NET access among all 3 cores, a deadlock situation may occur when the game is in background mode for two reasons:

Games that distribute FS and NET operations among all three cores must carefully synchronize operations when switching to background mode without causing unnecessary delay to the foreground switch. Operations on Core 2 continue to run in background mode after the foreground switch and cannot perform further synchronization with cores 0 and 1 until the game returns to foreground mode.

See Also

Foreground State
Background State
Request to Move to the Background
Request to Move to the Foreground
Transition Messages
Multicore Processing
Creating an Application

Revision History

2013/08/08 Created


CONFIDENTIAL