Are iOS 4 background API really the best solution to multitasking?

Multitasking was widely rumored to be coming to the iPhone with iOS 4, but instead of a traditional "leave full apps running in the background" approach, Apple instead chose to implement a more restricted but, they felt, better performing and power friendly solution involving 7 specific background API (application programming interfaces.) Is that, however, the best solution to the multitasking challenge as Apple claims? I spoke to several developers during WWDC 2010 and asked them that question.

First, we'll review what Apple is doing in iOS 4, then we'll see if developers think it works as well in reality as as Apple says it does on stage.

How does Apple say iOS 4 multitasking works?

In addition to the existing push notification service from Apple's servers, which provide sound, badges, and alert popups for everything from IM to game challenges, iOS 4 adds local notifications so something like an alarm-clock app could register an alert that would sit in the background, on-device until the proper time, then activate. That takes the online server out of the equation which is good for tasks that don't need additional data from the cloud, and so don't have to activate the radios.

There's another API for task completion so that, for example, if you're uploading a picture to Twitter and leave the app, it can register a thread to keep uploading the picture in the background while you do something else. That means the entire app doesn't have to keep running, freeing up memory and lightening battery load, and even the thread will terminate when the upload is done.

Fast task switching deals with the perceptive speed that multitasking offers. With previous versions of iOS, if you left an App Store app it would shut down completely and if you went back -- regardless if it was a second or a week or later, it would usually restart not from where you left off but from essentially the beginning. (A few developers tried to add persistence on their own, so they'd save your place when you came back as best as previous OS versions allowed, but most didn't -- especially games which was aggravating when phone calls pulled you unexpectedly out of them). Likewise, if you closed one app and went to another, you could theoretically be stuck swiping back or forth between 11 home screen pages.

Saved state is now built into iOS 4 so all developers can more easily have their apps remember exactly where you were when you left and put you right back at that position when you return, Apple has also added a fast app switcher UI that, when you double tap the home button, lifts up to show you your apps "in the background" sorted in order of last usage. That means, if you're moving between a set of commonly used apps, they're most likely right next to each other and not screens and screens away. These two elements combine together to make launching apps perceptively much faster, even though the apps don't have to be running in the background consuming resources just for that convenience.

Lastly, but perhaps most famously, Apple is allowing apps to register three specific types of the threads for persistent backgrounding (they can just keep running until you close them). Again, this isn't the whole app running, just one thread from the app, so the idea is it won't slow down performance, use up memory, or drain battery to the same degree. These API are for streaming music, location, and VoIP (voice over IP).

This means you can listen to Pandora, Slacker, etc. while surfing the web. Navigon, TeleNav,TomTom, etc. can keep using the GPS and alert you to directions while you're on the phone, and to further save resources, non-critical location apps like FourSquare, Gowalla, Loopt, etc. can be alerted when you change cell towers. Fring, Skype, Line2, etc. can answer calls and receive messages when you're not in the app, making the. More equal telephony citizens.

How do developers think iOS multitasking really works?

Of the developers I spoke to during WWDC -- and I certainly didn't speak to them all -- they were remarkably pleased with how iOS multitasking was working out in practice. For those who made large, resource intesive apps, they actually preferred Apple solution since they didn't want to be blamed for performance hits on other apps while they were in the background (especially performance hits for other intensive apps like games). So far, they were also excited by the relatively low impact on battery life compared to traditional, full-on app backgrounding.

In terms of implementation, the devs I spoke with were really happy about how quickly they could implement the background APIs in their apps -- really quickly, much faster than they thought.

(if you're a developer with a different opinion, send it our way so we can get as well-rounded a sampling as possible).

How will users think iOS 4 multitasking works for them?

Like with copy and paste, it's possible Apple really did take their time to get multitasking right. It's also possible that, like many other Apple solutions, it will be outstanding at what it does, but limited or non-functional for those who want to do more -- like have an SSH session stay open in the background, or have their Twitter, IM, or RSS timelines be ready and waiting, just like mail, when they open an app.

We've heard from Apple, we've heard from developers, and starting June 21 when iOS 4 goes live for end users, we'll here how it works for all of them in the real world.

That, of course, will be the true test.

Have something to say about this story? Leave a comment! Need help with something else? Ask in our forums!

Rene Ritchie

EiC of iMore, EP of Mobile Nations, Apple analyst, co-host of Debug, Iterate, Vector, Review, and MacBreak Weekly podcasts. Cook, grappler, photon wrangler. Follow him on Twitter and Google+.

More Posts



← Previously

Official Twitter for iPad will be the best Tweetie yet

Next up →

Appigo talks Todo for iPad - TiPb at WWDC 2010

Reader comments

Are iOS 4 background API really the best solution to multitasking?


I'm totally pleased with Apples solution.. I use backgrounder and proswitcher right now.. And find myself constantly closing apps cause I dont want to use up my resources.. I like the fact that apples solution makes me not have to worry about it.. Apple gets an A+ for this one!

It looked good to me, I'll all for saving battery life and I can only see one app on the screen at a time, so as long as I can stream music in the background and still get directions with navigation I'm happy, the background uploading is nice too. Push notifications took care of getting instant messages.

I agree with Damien. I use backgrounder and proswitcher as well. Although I don't brackground many apps often, I do notice an increased battery drain when I leave two or three open for an extended period of time. I believe Apple's solution to multitasking is going to go very well with both developers and end users. I can't wait!

I'm an end user using the GM seed food online ad overall, I am very pleased with the multitasking in iOS4. It's very responsive on my 3GS

I'm very pleased with how Apple has delivered multitasking. My few gripes with iOS 4.0 is that there are several native apps (Weather, Clock, Calendar) that need dire redesigning. The weather and clock apps should be showing live feeds of the current weather and time, as the calendar does with the date. The calendar still has no "go to" button to click. I don't understand how apple has overlooked these small, but powerful features.
The second thing I am frustrated with is the notifications system. Android and Web OS have different, but still extremely effective versions. TiPb has pointed out several times that each new push notification will obliterate the last, leaving no evidence that it was ever there, and that bothers me. There should be some sort of list of the most recent notifications that I can easily click and review. I am staying with Apple and upgrading from an iPhone 3G to iPhone 4 only because I think this is going to happen in the future. Palm's notification guy moving to Apple should be worth it.

It seems ok. It remains to be seen how this works for the average user (performace, battery life, etc)
As a user, my pet peeve is that I still can't multi-task Beejive in the background. Yes I will still get an alert. But I will STILL have to load up Beejive again, it will STILL have to connected to it's server and all the chat clients I am using. I would have loved for persistenance to work for that too, so Beejive could keep-alive connections to it's server and my chat clients.
Maybe the release of iOS 5?

@Gary: I think Rene assumed we knew that there are multiple background API's, thus referring to the "API" as a set of APIs -- plural. As such, he is correct to you "are" as opposed to "is."

This was exactly how I thought it could work so I am happy with what they have implemented. I can see a case for some way of keeping network links alive in the background as well though (like for SSH/VNC and IM, etc).
The only issue is that it may take a while for everyone to update their apps and nothing will support multi-tasking until they do.

I love Apple, a lot. But they're a year too late with multitasking. This should of been included in OS 3.0; same way MMS and video recording should of been introduced in 2.0. I will continue saying this all the time.
No matter how efficient Apple is doing multitasking, I don't find myself bragging to my buddies about our new feature that Apple has finally decided to give us while other smart phones have been doing this since 2008.

Should be interesting to see exactly how Apple implements the background services. For example, Android uses onPause, onStop, onResume and OnChangedInstanceState to handle events such as those mentioned. If they do something similar (obviously not implemented exactly the same way), it should do much for increased performance while avoiding the scenario Rene mentioned regarding leaving an App Store app.

The proof will be in the pudding, though it seems promising, based not only on early reports but from the mostly positive history of Android's similar bundles/services model. To nobody's surprise, Android's model is still more flexible, while Apple chose to be more restrictive.
This is not a dig at Apple -- they deliberately chose this tradeoff in part to improve battery life, and I have no reason to doubt their claims a more restrictive model will be more battery-friendly. However, there will be a class of apps iOS4 will simply not be able to do, such as the persistent network apps MrC suggested, as well as (I think, but have not yet fully examined the changes) moderately sophisticated multifunction background apps like Android's location-aware-garage-door-opener. Those aside, Apple seems to have a nice UI for task switching, and they certainly are not going to be hurt by their restrictions and the apps they make impossible unless developers come up with a large number of killer apps in those specific categories.

I haven't used it yet can't wait but there is another pressing issue. NOTIFICATIONS. At best it sucks. It could work if it pushed like RIM but even if several come in your lost there is no where to go to unify it all. So because they rehired someone from Palm to work on it you possibly will see this fixed in iOS5. That really is terrible. I love my iPhone but damn that was more pressing than FaceTime. You can only use that on WiFi until next year. Come on Apple.

"we’ll here how it works " - I believe you meant "we'll HEAR" about reviewing what you've written before posting Rene.

Im using GM Seed of iOS4 and love it very fast really nice options. Love the lock screen. ONe thing I did notice, and if anyone else with a 3GS has this issue please respond, but i no longer can edit videos in the camera app. Hopefully they did not take that option away in favor of iMovie. Also locate my iphone for mobile me is not working. when i try to pull up location it says no devices registered but everything else on mobile me syncs and works perfectly. Also everything I do on phone is much more quicker and responsive. Any solutions to above issues please let me know

Haha... People will always find something to complain about. The more Apple offers us the more we want. Is it not enough that we are even getting a multitasking solution? I'm pretty happy with what Apple has offered us. I would much rather have more battery life than full on multitasking. That's just me tho

As always, great job Rene. The persistent connection in the background to an IM client is exactly what drains battery life, so I don't see that coming anytime soon.
Apple's implementation solves the only 2 things I've ever wanted multi-tasking for: Tom-Tom and Pandora. I'm glad everything else dies in the background. When I was using WinMo, I felt like I constantly had to go to the Task Manager to kill apps. Glad those days are over.

Local notifications are great for another case: iPod Touch and non-3G iPads. Allows an alarm clock app to function even when there is no WiFi around.
regarding background network apps like IM or SSH - IM is a no-brainer, push notifications work, and state saving will increase their load time... which already is pretty good for many apps. Re: SSH - oh well! I use SSH, Logmein, RDP, etc all the time... if it was running in the background, you KNOW the battery would drain quickly. As it is, I remember to hit home before going away, lest the connection stay open.

" they actually preferred Apple solution since they didn’t want to be blamed for performance hits on other apps while they were in the background (especially performance hits for other intensive apps like games). So far, they were also excited by the relatively low impact on battery life compared to traditional, full-on app backgrounding."
Nuff said

Backgrounded tasks with persistent connections do not take any more battery than Apple's own Push notifications.
All of these require an open socket. But the radio need not be ON for the duration. It only needs to re-awaken about ever 12 to 18 minutes.
If the socket has traffic, it will become readable, and the system will return control to the app owning the socket, which was in a read-wait instruction.
If the socket times out (12 to 18 minutes later) the app will again be notified that the socket needs attention, and the app will re-establish the read-wait, and go back to sleep.
Where Apple's method shines, is that it essentially creates a single notification socket, and all applications ride on that single socket with a single piece of system software to monitor it.
In the typical approach, several programs would be watching their own socket, and, if they were not time-synchronized (as they are in Android), they MIGHT keep the radio on a larger percent of the time as each socket times out at different intervals.
So Apple's approach seems more aimed at saving memory, than battery. Because restarting a frequently triggered app takes WAY WAY more processing than just waking an idle one.

@E$F. I use a 3Gs and have 4.0 GM Candidate on mine and I can trim video recordings with no issues. However I have to open them in photo library and edit. I can't do it directly in the camera app.
As far as multitasking, I like it and I hate it. It's good that they added it, but I find myself much more conscious of what programs are running and routinely open the task manager and close things. Yes, I said task manager. If I am able to open a program and terminate programs within it, I am managing background tasks. That being said, Apple blew it since Jobs said that any phone that uses one blew it.
However I don't stream anything, I don't use navigation programs like Tom Tom and am patient enough to wait the few seconds it takes to upload photos on photobucket. We'll see what happens.

UPDATE @ GHOSTFACE. I figured it out. When i first loaded iOS4 and restored from backup it did not load my pictures or videos. so i had to reload them from iPhoto. i guess you can not edit those if they are uploaded from your computer only the ones you take on your phone directly, even if they were originally on your phone if you loaded em on iphoto erased your phone then loaded them back from iphoto you can not edit them. the only ones you can edit are the ones in the camera roll album.

It's the best solution for Apple's priorities, which seem to be:

  1. Protect battery life. They believe a mobile device that has a good likelihood of draining fast is worse than not offering the capability, for the vast majority of their customers.
  2. Keeping the UI simple. They believe a mobile device that is easy and pleasurable to use is better than offering more capability, for the vast majority of their customers.
  3. Keeping the UI fast. They believe UI responsiveness is more important than offering more capability, for the vast majority of their customers.

If a company believes prospective customers value the opposite more, than that's what you get with webOS, Android OS and Windows Phone. All of them have implemented more capable multitasking, and all of them have consequences with occasional lags, low scrolling frame-rates, battery drains. Apple believes most customers value better battery life, easier and fun to use, and fast UI more than great multitasking capability.
It's inevitable though. Maybe not this year or next year, but they'll gradually expand background services in the API so that they'll cover 99% of the usage cases out there. The 3 or 4 in iOS 4 is a good start. They'll probably add a couple more next year like for IM.

Ghostface147, the fast app switcher IS NOT a task manager. It's a shortcut to recently used apps, "closing" them simply removes it from the list.

Great article.
IMO, Apple's solution for multitasking is the best one out there. From what I understand about e.g. Android's multitasking, apps simply run until you close them. That gives no options for developers and makes users manage their own system resources. This is not the most horrible thing by any means.
Apple's solution for iPhone multitasking forces developers to think about how their particular apps run, what they can and should do while not running as the main app, etc. It's better not because it removes control from the user or because managing one's own system resources is so complicated or time consuming, but because the developers have options to customize their apps and to construct apps that work intelligently on a mobile system.
I'm not sure that Apple has covered every possible kind of circumstance with their APIs, but the strategy is sound, and it sounds like developers are pleased so far.

One additional thought: I expect to see this basic strategy adopted in part or in full by other mobile OSs, like Android, etc. That's how smart I think it is. It doesn't surprise me that Apple would generate something of what I consider to be of great value -- this is the area where Apple excels.

I like what apple did with multitasking but they need to work on the notifications system. I hate having to leave an app to answer a text message. hopefully the guy they hired that designed webOS' notifications system does somethign similar for iOS.

Ummm...Apple did not invent this approach; Android had this strategy well before Apple did. They called it Bundles and Services, see for an overview from a few months ago. Bundles/Services is the preferred way to "multitask" on Android, and has been since well before Apple announced their version version in iOS.

One again Apple implemented a non solution. This is not multi-tasking at all. I am not sure what to call it, but multi-tasking would not fit. I suppose this is better than nothing, but why not do it right. Web OS has the best multi-tasking hands down. You would think Apple could at least come close.

How is it not multitasking? Here is the definition (1. (computing) The simultaneous execution of multiple tasks (programs) under the control of an interrupt-driven operating system.) thats from wikipedia. Just because the whole program is not running in the background doesn't mean its not multitasking. As a former palm pre plus user I will give you that it looks a lot cooler on the pre but also my battery would be lucky to last half a day of use.

It is a flavor of multitasking, just not what people think of when they refer to multitasking. The fast task switching is not multitasking at all -- the app is effectively terminated with its state saved, theoretically quickly enough that people would not appreciate a difference. The backgroundable service threads are a form of multitasking, though not with the full power or flexibility as "true" multitasking. And that's ok -- on the current generation of mobile devices, that power have have deleterious effects on the battery power, so those limitations may be a fair trade.
It would have been nice had Apple picked another term, or at least another adjective to identify this particular take on multitasking, rather than just overload and confuse the base "multitasking" term, sort of like the old days when people argued "preemptive" vs "cooperative" multitasking. Yes, assuming it works as advertised, consumers will not care, but a differentiator would be useful for those who work and study in the field.

You're "sort of" right about Android's life cycle. As long as resources permit, yes it will allow it to run. If the app is in the foreground it will not be killed. If it is no longer visible and the system needs resources, it will kill the app and save the state as (Copy of) Dev explained. At that point the onPause, onResume, onRestart, blah, blah, blah kicks in if the developer chooses to use those methods.
But I think that's the key: Android or iOS... it's up to the developer to use the API provided to most effectively/efficiently use the multi-tasking of the OS.
Some are making more of an issue of this than necessary. The saved instance states work best in scenarios where you're entering or transferring data or doing something where the data is constantly changing such as a game. Most people won't even know the difference which means Apple's approach will be hailed with open arms because it does what they need.

Like I sad I use proswitcher and backgrounder "full multitasking" and it sucks compared to apples approach..I don't need my apps running fully in the background I just need certain things to happen, like my web page to finish loading when I switch to a different app or my music to continue playing, or an app to load quickly when I switch back.. They have created the illusion of multitasking and that's fine with me.. As long as I'm able to do what I want to do I don't care that it's not REAL multitasking. Oh and guess what? I get to use my phone longer without having to charge it every few hours.

there is an amazing amount of confusion about how multitasking is going to work, you have to figure apple is choosing the solution that works best for the user though. no, it's not true multitasking, but most people can't tell the difference, they just want to be able to re-open an app and have the prior still still in existence quickly, while playing music or something in the background.

@ (copy of) Dev and Tallbruva:
I just read a comparison between iOS4 and Android (one of those "which one is better?" blog posts) that gave me the impressions I had about Android's multitasking. So that part was totally wrong, apparently. Anyway, thanks. It's really difficult to avoid getting wrong information about the two OSs.

There are still more drawbacks to AMOLED then LCD. Power-wise, the savings are generally when displaying blacks, and that's about it. When showing white or color, AMOLED can waste more power than LCDs.
And besides, Android battery performance is generally worse the iPhoneOS. If anything, you should be complaining to Google about Android's worse performance instead of complaining about Apple's design decisions. A lot of Android devices have bigger batteries than iPhones and this supposed power saving AMOLED technology, yet have worse battery performance if Anandtech's comparisons is anything to go by.

I think it is a major fail, I wanted true multitasking. We should be moving closer to the power of a PC, meaning true multitasking. Hate to say it but, webos is a multitasking machine!

I'm more than ok with everyone saying that iOS 4 isn't multitasking. When everyone says the word "multitasking", they generally mean desktop style preemptive multitasking.
If so, doesn't that mean AndroidOS, webOS, Symbian, etc, don't technically qualify either?
Last time I checked, desktop operating systems keep the full applications open and don't kill them in memory starved situations. So why does AndroidOS's client/server model get a pass here?
In the end, it only matters so much. Apple is covering usage cases while trading on things that are important to them. With iOS 4, they've covered Internet radio, VOIP, clock and location timers, and long completions. There are still edge cases, but they are more than happy giving them up in favor for of battery and responsiveness.
If you need those edge cases, well, it's pretty clear getting a device that gives you that is the right thing to do.