Related 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.
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.
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
- 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)