What is Fast App Switching?ivedoneyourmom said:Marty, you got me to get up and switch to my computer for posting this:
I don't think anyone thinks Apple is perfect, however they get much more scrutiny than is deserved, is it because of their past transgressions back in the 90's, or peoples fear in technological/social change, or is it just fun to gang up on the popular kid; I don't know, however unless you have read the Cocoa Touch/iOS 4 developer documentation I don't think you should be talking about 'flaws' that may or may not exist in the implementation.
So I right now am going to be posting some quotes from the Apple Developer Documentation website so that you can better educate yourself on the implementation; The website can be found here: https://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html (Most likely requires a membership)
Now what that means is that the code that needs to be changed is to make sure it behaves like it used to prior to 4.0, otherwise apps would be limited to only running on 4.0, so most likely a developer would have to add a little bit of case logic to determine what OS it is running on. If it does not do that, it will only work for 4.0 and up.
This means that your app has to be willing to save at any second, because the OS may find it needed to kill it without user intervention.
In fact, if the app is linked against the 4.0 SDK and does not want to actually use the save states or any multitasking features it would get for free from the os the developer has to manually 'opt out'
Feel free to take a look at the documentation and see if you could have came up with a better implementation than Apple, because I think they did a pretty good job with very little compromise, and took most of the burden off of the developers.
*edit* Stupid me, I forgot to hit copy on the last quote.
...That final point is key, especially because it contradicts everything I've said previously in this article. It turns out that in order to participate in multitasking and allow itself to be suspended, every app must be recompiled for iOS 4. An app that doesn't appear to behave any differently when you resume it on iOS 4 from how it behaved when you relaunched it on earlier versions of the system simply hasn't been recompiled yet. That, as a moment's reflection will show, would be the vast, vast majority of apps!
Clearly it will take some time for developers to recompile for iOS 4 and get their updates past Apple's App Store gatekeepers and onto your device. Until they do, you won't see all that much benefit from multitasking on iOS 4. Only Apple's own apps, and those few apps that have already been updated, are acting in a new way.
Moreover, recompiling for iOS 4 is non-trivial (as I just found out while doing it for the TidBITS News app - see "Free TidBITS News iPhone App," 4 January 2010), because it will also require some rewriting. The app instantly participates in multitasking with no changes in code, merely by virtue of linking to the iOS 4.0 frameworks instead of to an earlier version; but that doesn't make it a good multitasking citizen.
One major issue is that an iOS 4-native app is notified when it is suspended, but not when it is terminated. Thus, it must do all the things to save state when it is suspended that it used to when it was terminated, just in case it later is terminated. Another issue is that the app, as it is suspended, needs to stop doing things that might cause trouble later. It must explicitly reduce its memory use if it doesn't want to be a candidate for termination in the background. It must cease any network activity. It may have to cancel a modal state, such as an alert that might not make sense when the user resumes later (possibly days later).
Those are all things I had to worry about when updating the TidBITS News app for iOS 4.0. Basically I had to consider every state the app might be in at the moment the user comes along and suspends it. That turned out to be remarkably difficult - and the TidBITS News app is very simple and small! Imagine, then, how long it will probably take before your favorite third-party apps are updated...
Mind you, both Android and WebOS offer the suspend/'fast app switching' and they handle it differently.