Can the iPhone 3G be saved?

Like many others, my iPhone 3G is suffering a bit since I upgraded it to iOS 4. While version 4.0.1 apparently helped a little, even though it only officially delivered the reception bar tweak, it seems to have made my phone slightly snappier. It’s still far from how it felt with iPhone OS 3.2, though.

I still think that Apple shouldn’t have allowed 3G units to run iOS 4. The advantages are negligible: aside from folders, unified inbox and very little extra things, the list of what’s missing is huge. No multitasking, because the phone just can’t handle it; no wallpaper, because the phone just can’t handle drop shadows in real time (well, why not pre-render them once?); no screen lock (why, Apple, WHY?) and so on. Latest news is that it won’t even have Game Center, but then again, most games will probably soon drop support for the 3G entirely. The question remains: why did they let us upgrade? My educated guess is that they can push iAds to our devices, but I cringe at the thought of how pathetic the experience must be. We’re not even getting wallpapers, and they really expect us to navigate ads that are “as fun as apps”? Give me a break.

Going back to 3.2 is possible, but it’s a messy and unsupported procedure, not to mention that most apps have been updated to run on iOS 4 and that can be difficult to circumvent. Sticking with iOS 4 is a painful experience on its own.

This is not the geek in me who wants the latest toy, trust me. I do admit that the iPhone 4 is nice, especially coming from a sorry-I-don’-t-do-videos-at-all iPhone 3G. I am not making up excuses with myself to go and buy an iPhone 4. The truth is the 3G has gotten so slow that it’s impossible to use. I honestly hope I will never need to make an emergency call with it, because I may as well start crying for help instead of wasting time.

It has to be said that not all 3G units are created equal, it seems. Some people have very few problems, while others have pretty much given up. A friend of mine was so fed up that he ditched it and got an HTC Desire (which is a very sweet phone, by the way.)

The general opinion, however, is that iOS on the iPhone 3G, well, sucks. Remedies popped up all over the web, ranging from confirmable attempts, such as disabling Spotlight, to the voodoo ritual of  the “double hard reboot” to clear any leftover cache (which kind of works, but why do it twice? nobody really knows; then again, it’s a ritual.) It seems that a simple reboot does not really help. Rebooting normally apparently saves the state of the phone onto the flash memory as a disk image, similarly to the “deep sleep” feature of modern Macbooks. The hard reboot is much more brutal, and works better.

After a while, though, things start going wrong again. Be it an hour or two days, the slowness creeps back. It becomes unbearable. Sure, you can do the hard reboot again, you can close any Safari window before moving on to other things, but at the end of the day you may be in a rush to do something with your phone, and that’s when Murphy’s law strikes. The problem, in fact, is not just a general sense of sluggishness: it’s that it literally freezes up for a random period of time. Sometimes it’s a few seconds, other times it can stay in its coma for a solid two or three minutes. Again: I am not making this up, and this may be different from phone to phone, but that’s my experience. What’s worst is that it happens in a completely random fashion, and I cannot reproduce it on demand. Sometimes it happens when I’m writing a text message, other times when I’m using Safari, or even as I’m opening up the Settings app to put the phone into airplane mode for the night.

The only consistency I can mention is that gaving the keyboard on the screen makes the phone especially prone to sleepiness. I am able to blindly write a full text message; thankfully, at least with that, it usually catches up and doesn’t miss anything; however, I usually end up making several typos because, being unresponsive, it gives me no suggestions until it wakes up.

Yesterday night I wanted to show a website — ZooBorns — to my father. Bad idea. I was over wi-fi, but bandwidth was limited because my iMac was busy with the network. After noticing it was slow at loading data (it was exclusively a network problem up to that point), I went to the Settings app to disable wi-fi, and it fell asleep after I tapped “Wi-fi”: it had even made the item blue because it had recognized the tap, but it took about 45 seconds to load the next page. I disabled it, tapped the home button, and re-opened Safari. IT started to load over 3G and all was fine, until I scrolled down. I understand that it’s a huge page with lots of pictures, and I can live with the fact that I get the “checkered background” as it’s re-rendering parts of it. But if the whole phone falls completely asleep for over three minutes, and fails to respond to any tap or button press — effectively making it impossible to even force a shutdown — well, it’s a bit too much. I can tell that the phone is completely numb because it doesn’t even dim the screen, which should happen after one minute of inactivity (yes, I am that conservative when it comes to battery life.)

So, are 3G units destined to be useless? No, not necessarily. I think that, while the hardware isn’t up to par with its younger siblings, it can still be decent. I think that iOS 4 has some fundamental flaws on 3G, and maybe even on the 3GS and the iPhone 4; on those units, though, it may not be as easily visible. Of course, it may also be that the problems in question are limited to the 3G. I am talking about memory leaks. Something is extremely wrong in the way memory is handled in iOS 4, but this is my own speculation. I do not develop for the iOS platform, and I don’t know much about its internals. Yet, I have a very concrete way of seeing that memory isn’t released properly: MemoryInfo. It’s a cheap little app that shows the most memory-hungry processes running on an iPhone, and automatically frees memory by killing those processes that it deems killable. Well, with 3.2 my inactive memory count usually went from 7-10 to 35 MB; now it goes from 1-2 to 45-50 MB, even though it quickly decreases to 30 MB free again without even exiting the app.

Whether the culprit is Safari or iOS itself, a memory leak is occurring somewhere for sure, and it manifests itself at random times with freezes that can make everything difficult. Apple is investigating the problem, and that’s a good thing. I’m not sure what their approach will be, but given that the OS is going to grow bigger anyway, they could simply allow it to swap on the flash memory. Right now iOS has no support for virtual memory: the actual RAM is the only memory it can use. Why they decided to do that beats me: sure, smaller units with just 8 GB of flash space can’t really reserve that much for potential swap, but even 5% would be an acceptable trade-off. Back in the old days of Linux, the rule to calculate how much space to reserve for the swap partition was: no less than twice as much as the physical RAM. With 128 MB of physical memory, an extra 400 MB would do wonders, and it wouldn’t even be too slow. It would certainly be faster than using a spinning hard drive, anyway. Let’s see what they come up with. In the meantime, enjoy a sad but true video: