Apple recently announced iPhone OS 4.0 enabling “multitasking” of a sorts. I want to dig slightly deeper into understanding what they actually mean by this “multitasking”, without talking too much about the nitty gritty details.
There are 7 kinds of “services” they expose for multitasking:
Among all 7 “services” exposed, 6 of them are somewhat already available in the system itself, one way or another, with hidden APIs not exposed for public developer usage. Let’s take a look at each of them, and how they might “save battery” without “slowing down the system”.
The background audio is simply what the iTunes application already does, which is to play audio in the background without having the iTunes application open. This simply means they just expose what iPhone can already do to developers. This does not make any changes to slowing down the system in any way, since people have been using the iTunes application to play background music since the first iteration of the iPhone and iPod Touch. However, understand that the application does not remain open at all, only a small portion of the “application” remains streaming the music.
Voice services has been around ever since the beginning of the iPhone (duh?!?) with the Phone application, running constantly in the background to “receive” calls. This, in fact, is also not a full fledged application at all, but a small part of code that “reacts” to an action by the OS (namely the voice service) to load up the application and “receive” the action to do something about it.
Similarly with the voice service, it is simply a “reaction” or a “response” to an action that the OS has prompted, in this case, your GPS or Wifi location based services. This is probably one of the things that will drain your battery pretty quickly, since these services do take a lot of resources. However, since the control lies with the OS of how and when to serve up this reaction and NOT the application that decides to take over your entire GPS and Wifi location based services into their hands and drain your battery dry, the OS will probably have some battery consideration when location is required, hopefully not letting the application go rogue.
What can I say? It’s been done, and been available since the last iPhone OS 3.0 release. I think it’s just put here for good measure. Once again, it is a “reaction” and not true multitasking.
This is simply the same thing as your “scheduled task” or “timer” for those familiar with the terminologies. This, too, isn’t having your entire application open, but simply just a small part of it that you register to a scheduler to run it when required.
This is slightly interesting because it isn’t a “reaction” to something, but letting a “thread”, “process”, or keeping with this post’s terminology “a small part of the app” running in the background, and when that finishes it just automatically closes the application. This has potential for having a rogue application that simply just continuously have an infinite loop to keep the application open. I’m curious to find out how much is exposed, or only certain services like “downloading” and “uploading” are available.
This is ALSO not true multitasking, where the application once lost focus will save its state, close itself, and not “run” at all. Only after reopening, the state is restored, and the application is once resumed again. So in fact, anything running will have to be resumed, for example connection to the internet and so on. This means that it does not actually continue to run at all. However, with what was covered in the previous 6 ways of multitasking, you can very well achieve seamless “multitasking” with “Task Completion”, “Local Notifications” and so on.
What does this all mean? Steve Jobs has redefined what multitasking actually means and converted the meaning to a consumer terminology. Consumers do not want true multitasking, but a pseudo-version of it with all the benefits of multitasking, and also the benefits of a fast and responsive OS. But does this mean that developers will have more to worry about, trying to work around what’s available to them to create a seamless so-called “multitasking” application? Most of what Apple has announced isn’t anything new at all to the iPhone OS, it is simply just exposing it with a tight grip, disallowing developers to go rogue.
Do note that all this right now is speculation based on what makes sense to me until I actually see the SDK.
Source: JustinLee.SG – High-Level Analysis of iPhone OS 4.0 Multitasking