How iOS multitasking really works

By Fraser Speirs, Macworld |  Software, Apple, Apple iOS

Let's take an app that downloads largish files from the Web, such as Instacast, my favorite podcast app. When Instacast is Active, it can start to download new podcasts. By default, if I hit the home button on my iPhone, Instacast would get five seconds to run in the Background state before it would be moved to Suspended. That would interrupt the download of my podcasts, which can take some time. (They're large files.)

But iOS allows apps such as Instacast, which have time-intensive tasks that can run in the background, to ask for a reprieve. The app declares its downloading of podcasts as a "background task." This allows Instacast an extra period of Background running, after I hit the home button, to complete its downloads.

Instacast doesn't have all day. An app gets about ten minutes of Background running time before it is forcibly suspended by iOS. But regardless, this isn't a feature regular users should worry about.

Indefinite background running

So all apps get five seconds of Background running, to clean things up, and some apps (such as Instacast) can request a ten-minute extension. There are, however, a small number of apps that genuinely need to run indefinitely in the background, and iOS allows this.

There are exactly five kinds of apps allowed to run indefinitely in the Background state in iOS 5:

Apps that play audio while in the Background state. A good example is Instacast while it's playing a podcast.

Apps that track your location in the background. For example, you still want voice prompts from your turn-by-turn GPS navigation app, even if another app is Active.

Apps that listen for incoming voice-over-IP (VOIP) calls. If you use Skype on iOS, you can receive incoming Skype calls while the app is in the background.

Newsstand apps that are downloading new content.

Apps that receive continuous updates from an external accessory in the background.

All well-written apps in the above categories should become Suspended when they are no longer performing the task in hand. When Instacast finishes playing a podcast, it should be Suspended. There are some built-in apps that also run continuously in the background on iOS—the most-used one is probably Mail.

As long as these apps are running in the Background state, they will consume memory, CPU time, and power. It's also important to know that an app which is enabled to run indefinitely in the background can do anything that it can do when it's Active. This may include much more than just playing audio or tracking your location. For example, as long as Instacast is playing audio it can also continue to download new episodes in the background.


Originally published on Macworld |  Click here to read the original story.
Join us:
Facebook

Twitter

Pinterest

Tumblr

LinkedIn

Google+

Answers - Powered by ITworld

Join us:
Facebook

Twitter

Pinterest

Tumblr

LinkedIn

Google+

Ask a Question