iOS multitasking explained, again
by Justin Horn on Apr 19th, 2010 @ 11:51 amRelated Post: Almost 2 years after I wrote this post, the debate continues. Here’s a great post from Fraser Speirs, backing up my point (aka the truth), “iOS Multitasking in Detail”
There is a lot of confusion surrounding iPhone multitasking. John Gruber of Daring Fireball kicked off the latest round of debate with his article Mobile Multitasking. After reading his article and others like it, I decided to jump into the OS 4 multitasking write-up game.
Most of the multitasking talk centers around the fast app switching dock. I’m going to cover that later, but before we get there I want to review the different app states: closed, suspended, and background.
Closed State Apps
This is how apps work prior to OS 4. When leaving an app by pressing the home button, the app gets about 5 seconds to finish what it’s doing and save any pertinent info. The app is then purged from memory. Currently, all third party apps running on OS 4 beta still operate this way because they haven’t been updated yet. Even though apps returning from the closed state have to load from scratch, they can use the saved info to start right where you left off. The ability to read / write state data to the app’s own disk space is not handled by the system, but the app itself. This is why you already see this save state in current apps like Rolando, with its “iSave” feature, which lets you resume your game right where you left off.
Suspended State Apps
This is a new state introduced as part of OS 4 multitasking and available only on the latest (and future) iPhone and iPod touch models. When a user leaves an app, it’s put into the suspended state instead of closing it. The apps are held in memory and their process kept alive, but are given no CPU time. You can think of them as cryogenically frozen, they still exist and are alive, but can’t do anything until defrosted. Restricting the CPU usage in this way keeps the iPhone from getting bogged down, and more importantly, keeps battery usage close to zero. When returning to suspended apps, they start exactly how you left them without needing to load again. This gives you the feeling they were running the whole time. As nice as this sounds, it’s not truly a background app. No CPU means it cannot process any data in the background. For example, after leaving a Twitter app, it’s no longer updating your stream. When returning to the app, all the latest tweets will need to be downloaded. As most OS 4 compatible apps will fall into this category, it means push notifications are still going to play an important role in iPhone multitasking.
Background State Apps
This is a special state, applicable only to certain types of apps. These are true background apps given CPU time while working behind the scenes, but are only able to use resources to perform a specific task. I think the easiest way to explain this is to discuss the details of how a few apps work.
UPDATE 6.25.2010 Added TomTom example for background navigation.
Pandora (Background Audio)
You are jamming with Pandora as you always have, but then decide to check out a band’s website. You press the home button to leave Pandora and fire up Safari. As a background audio app, Pandora is not put into the suspended state, but remains running as long as it’s streaming audio. When running in the background, the app must only use system resources to process the audio stream. For example, when a song changes, Pandora will not update the screen view to show the new artist info, as this would be a waste of CPU resources for something the user can’t see. A task like this can easily be taken care of when you return to Pandora as it’s moving from the background to the foreground. So after an hour of rocking out with Pandora you notice your battery is getting low, how do you stop it from running in the background? Easy, the same way you do now with the iPod app, just go into the app and hit pause. The only way Pandora is allowed in the background is if there is music streaming, so this time when you leave the app it’s sent to the suspended state.
The multitasking update is currently available [iTunes]
Skype (Background Voip + Background Audio)
There are two different scenarios when dealing with voip: waiting for a call and on a call. Apple’s solution when waiting for a call is perfect for keeping battery usage to a minimum. After logging into Skype and returning to the home screen, the app is not kept in the background like Pandora. Instead Skype enters the suspended state and lets the system monitor its connection to the voip server. When a call comes in, the system moves Skype from the suspended state to the background state. Skype does not automatically open, it’s still only in the background, so what you are currently doing is not interrupted. The call data is then processed and a local notification (another one of the 7 background APIs) is created to alert you a phone call is coming in. If you ignore the call, the connection is handed back to the system and the app returns to the suspended state. If you pick up the call, the app opens in the foreground and the call is connected. If you decide your buddy is boring and you want to check some email while pretending to listen, it’s no longer an issue. When you open up mail, Skype continues to work in the background, very similar to the audio apps. When the call ends, Skype hands the connection back to the system and goes to sleep. To close Skype, just open the app and log out. When leaving Skype with the voip server connection closed, it goes into the suspended state until you login again.
Facebook (Task completion)
This is a hypothetical example of how Facebook could work if programmed to do so. You are finished playing around on Facebook and just waiting for a bunch of pictures to upload. You leave the app and return to the home screen. Instead of immediately suspending the app, cancelling all your uploads, it requests extra time to finish in the background. When the upload is complete, the app is then put into the suspended state.
TomTom (Background Navigation)
Receiving a phone call while navigating is no longer a problem on iOS 4. Now when you take a call, the app will popup request your permission to continue navigating in the background. If granted you will still receive turn by turn direction while on the call. This also works if you leave the app to do something else, like check email (hopefully you aren’t the driver). The app continues to track your current location, but to save battery it’s not updating the map. When you return to TomTom it will take a few seconds to reposition you on the map. What happens when you’ve arrived and want to shut it off so it doesn’t drain the battery? No, you don’t need to manually task manage and force close. When you reach your destination and are no longer navigating, it will automatically stop using the background navigation and go into regular suspend mode when you leave the app. If you leave the app while still in navigation mode and disconnect from power, you’ll soon get a local notification popup asking if you would still like to navigate in the background. Tap no and send TomTom into suspend mode. You can always confirm that it is no longer running in the background by looking for the new GPS arrow icon (see picture below)…if it’s gone, it’s not navigating.
The multitasking update is currently available (Read More) [iTunes]
What is the fast app switcher dock?
The fast app switcher, or hidden dock, is a new task bar that slides up from the bottom of the screen when you double tap the home button. The new dock doesn’t just list your background state apps that are actually running, but contains ALL the apps you’ve opened no matter which state: closed, suspended, or background. To the end user it doesn’t really matter if the apps are technically running or not; I guess that’s why in the OS 4 keynote Steve Jobs said “I can just double click the home button…and the window raises up and it shows me all the apps that are running.” The apps are ordered left to right by most recently used, so you have quick access to the apps you use most.
Wait, wasn’t double tap home button a shortcut for my phone favorites, iPod, or Camera?
Yes, it was. To perform the home shortcuts on OS 4, you just need to double tap and hold. Might be confusing at first, but should catch on pretty quick.
UPDATE This double tap and hold was removed from the final iOS 4 release. There is a new feature for controlling the active audio device. To access this you bring up the fast app dock and move left (see picture). Unfortunately the favorites we all know and love are no longer available.
Is the fast app switcher dock a task manager?
You’ll remember this question for the OS 4 keynote Q&A session:
Q: How do you close applications when multitasking?
A: (Scott Forstall) You don’t have to. The user just uses things and doesn’t ever have to worry about it.
A: (Steve Jobs) It’s like we said on the iPad, if you see a stylus, they blew it. In multitasking, if you see a task manager… they blew it. Users shouldn’t ever have to think about it.(via Engadget)
You can manage your apps manually in the hidden dock by removing them, which sends them to the closed state, but what Steve said still holds true…the users don’t have to think about it. A regular user on OS 4 can get along just fine without closing apps manually or even looking at the hidden dock at all for that matter. All the operations of managing the apps for memory and CPU concerns are taken care of automatically by system, so there is no advantage to closing them yourself. Another important factor is the ability to close apps (stop background processing) through the app’s user interface, like the Pandora and Skype examples earlier. I assume this will be a requirement for every background capable app1. If not, then what Jobs said is no longer vaild.
UPDATE 6.25.2010 1Some apps, like Pandora, close in a very intuitive way…stop the music, stop the multitasking. Other apps need a bit more thought, but properly designed, they won’t need specific close buttons in the user interface. A perfect example of this is the TomTom app I recently added to the background state apps above.
How does OS 4 decide when to close apps?
When a new app is opened that requires more memory than is currently available, OS 4 automatically closes suspended apps in least recently used order. The next time you open an app that was closed by the system, it will need to load again just like it does on OS 3.x. You will lose the quick start up, but if the system closed it you probably hadn’t used the app in some time anyway. If even more memory is required, the system starts closing background apps (like Pandora) in the least recently used order.
Apple’s first step into multitasking looks great to me! Their strategy will automatically grow with the hardware. For example, when the 4th gen iPhone is released with 512MB of memory (I love speculating [no longer speculation, I was right]), it will be able to keep more simultaneous apps suspended / backgrounded. Also, as the hardware improves, additional APIs could be added to allow a wider variety of apps to work in the background.
Follow me on Twitter @justin_horn
View 27 Comments
Featured post, iOS 4, iPhone, Speculation
Recent Post
- More details on the iPad mini new multitouch feature
- iPad Mini predictions
- Zune still the butt of jokes, this time on the Simpsons
- AT&T LTE No Service: Too many LTE iPhone 5 users?
- iPhone 5 cellular usage while on WIFI bug affects AT&T users as well
- Tim Cook responds to iOS 6 Map app issues in public letter
- iPhone 5 screen vs iPhone 4: Really close up
- iPhone 5 line at 5th Ave Apple Store (Updated 11PM)





thanks so much for this article…I now understand how it works and so greatly appreciate your time making this article
cuz I have been going and closing apps on a regular basis because I was afraid they were running down my battery…but I think my battery is running down cuz I use my phone more than I used to…cuz I love showing people OS4…it’s hot
[...] like my wild speculation in my multitasking article back in April was correct: Apple’s first step into multitasking looks great to me! [...]
[...] when you arrive at your destination or are not navigating the app will automatically stop using the GPS in the background and go into regular suspend mode. If you leave the app while navigating and unplug from power, you [...]
I sum up what you said: apps that are in background are suspended and don’t use battery anymore, but as we know, backgrounded apps use RAM so it has to drain battery coz when RAM is busy it uses battery a lot
Martin, when the data is just sitting in RAM and not being accessed it uses an immeasurable about of battery.
What uses battery is moving data in and out of memory from the flash storage and, most of all, the CPU. It actually saves better by not having to load apps in an out of RAM every time because the data is already there, plus it doesn’t need the CPU process all the data and load up the app again.
Hi guys, and thank you for the article. Unfortunately I do not even have the multitasking bar showing. I double tap, double tap and hold, change my settings and so on… I’ve never seen this great feature. Any ideas?
Cheers from Germany,
thomas
Thanks for this post. I’m using ios4 on my iPad currently. And worried that apps showing in the hidden tab will drain my iPad’s battery.
If this is the case, I don’t have to worry about going there and closing apps. Just hope that what you wrote in the post is based from a reliable source. No offense.
Thanks.
Thomas, only the 3GS running iOS 4 or higher can multitask.
Aidil, I researched everything from the iOS documentation provided by Apple.
[...] iPhone OS 4 multitasking explained, again [...]
Excellent – helpful article. Thanks! The technojungle is so crowded with words – your thought organization is super which makes your comments so helpful!
Nice article, but it repeats an Apple myth.
The fast-app-switcher-bar is indeed also a task manager: it has the functionality to kill apps, which is handy especially with older apps that might malfunction under 4.x.
What Jobs really meant was “In multitasking, if people realize that it’s a task manager… you blew it.”
Kevin, you are missing the point.
Yes, you can kill 3rd party apps with the fast app bar, but there is no reason to do that. It is handled automatically by iOS. Basically Jobs is saying you’ve failed if you leave it up to users to manage system resources.
Like you pointed out, the only reason you would need to force quit an app is if it half crashed or something and got stuck in a weird state. You could then use the fast app bar to kill it, or just enter the app, hold power button down until the off slider appears. Then press and hold the home button (same as iOS 3.x).
There is no provision to run the background task for long time. I have tried to use background task for long time and next time when app enter in forground… there is no way to end that task because no method was called which shows that app entered in forground…..
Overall I do not think there is any method to run a background task(like sending location data to website) for long Interval of time..
What a great article!!!! You answered my original question, held my interest, and gave me answers that made me delve deeper into the subject mater you presented. Very well done!
[...] Originally Posted by ChrisGonzales90 multitasking is good, but I don't like how you have to close each one. Why is there no "close all" option? Because you don't need it. iPhone OS 4 multitasking explained, again | When Will Apple? [...]
Thank you so much for this information that was not available anywhere else.
The only detail i see is thar when one has 30 apps opened on has to keep on clicking the close button. Otherwise multitasking on the ipad, phone, etc is awesome. I would love a “close all apps”button. I think that is one little missing thing, but it is still awesome.
Justin, with regard to your reprimand of Kevin and his assertion that the fast-app-switcher-bar is indeed also a task manager, I suggest that YOU have missed the point.
It may not appear to be a task manager, and Jobs/Forstall probably don’t want them to realise that that’s what it is, but it is. And it’s useful, in spite of Forstall’s ‘..you don’t have to’. Arrrgh! Some people just may have old habits, they may be tidy, or they may want to minimise the number of apps they have to scroll through to find the one they’re looking for. Any number of other reasons.
“How can I dry myself off?” “You don’t have to; the sun’s out and there’s a nice wind..” Arrrrgh!
Hokay?
[...] Originally Posted by Remeniz Gotta agree with ironass. I didn't know iphones weren't good at multi tasking and dual core cpu's won't make it much better at it. It's something that's controlled by the OS … See here:- How to Disable Multitasking on iOS4: ALL DEVICES | Iphone 4 Tips and Tricks iPhone OS 4 multitasking explained, again | When Will Apple? [...]
[...] two or three times a day. This link gives some good advice about leaving apps in the running: iPhone OS 4 multitasking explained, again | When Will Apple? Liked [...]
Funny, as I just got off the phone with the second technician from Rogers my service provider, who told me that my data is high because I have to close my apps. I have told them both times that that is untrue. Maybe I will direct them to this site! Lol
[...] tasking (the bar at the bottom of the screen that appears when you double click the home button). iPhone OS 4 multitasking explained, again | When Will Apple? It is very easy to delete a app from on the iPhone. You simple touch the app you are wanting to [...]
[...] Newsstand, iBooks and Siri features are included with the phone by default. The phone can “multitask“ and has a good battery life, in addition to its ability to store up to 64 GB memory entirely on the [...]
Sweet n simple explanation. Many thanks.
-Flami Abs
I have to thank you for the efforts you’ve put in writing this site. I am hoping to check out the same high-grade content by you later on as well. In truth, your creative writing abilities has inspired me to get my own, personal site now
Aw, this was an incredibly nice post. Taking a few minutes and
actual effort to generate a top notch article… but what
can I say… I procrastinate a lot and don’t manage to get anything done.
Tremendous things here. I am very glad to peer
your article. Thanks a lot and I am having a look ahead to touch you.
Will you kindly drop me a e-mail?