Speed up iPhone 3G under iOS 4.0

Please note: This article was written for use with the iPhone 3G, although it may be applicable with a varying degree to other Apple iDevices.

Recently, after upgrading a friends iPhone 3G to iOS 4.0 I found the phone had slowed to the point where it was almost unusable. Naturally my friend wasn’t happy with this, so I was faced with two options:

1. Downgrade the device back to 3.1.3
2. Find a way to speed up the device on iOS 4.0

After undertaking some research, I chose option two, as my friend wished to keep the new features they had gained in the iOS 4.0 firmware upgrade. In the remainder of this post I will describe the steps I undertook to speed up the device, and and the reason for each step, but before we start I will say that although I have done all these modifications myself successfully, (and safely), I am not responsible should you damage or break your device attempting these modifications. You do so under your own risk. (The majority of problems caused by making a mistake in modifying your device can be fixed by restoring the device in iTunes.) Jailbreaking your iDevice may void your warranty, however if you own a 3G it is likely your warranty has expired anyway.

Step 1: Restore the device to a clean install of iOS 4.0
As with many other devices, the iPhone will slow down over time, as it gets bogged down with remnants from firmware upgrades, large cache files, and other such issues cause the device to become sluggish. Restoring the device in iTunes can have varying degrees of effectiveness, depending on the underlying cause of your device’s issues. However I would recommend this as a first step, as it the most simple of the tips I will be giving here.

Procedure: Connect the device to iTunes, right click on it, and click “Backup” Once that has finished, click Restore, and follow the on-screen prompts.
When the device has finished restoring, make sure you choose to restore your phone from the backup you just made, or you wont get to keep your data.

Step 2: Clear Safari’s cache files and replace your email accounts.
To clear the cache that Safari keeps, simple load the Settings application, then select Safari and then the “clear cache” option.
I noticed that when I upgraded to iOS 4.0 that my email accounts were not working correctly, I fixed this by removing them from the device, and adding them again, not sure what was wrong, possibly a glitch in the upgrade process, but I did notice improved performance in the email app after doing this. While you do this consider whether you need all the accounts on your device. You can increase battery life by having less email accounts, and getting them to fetch email less often.

Step 3: Free Disk space and Spotlight
You should ensure that your device has at least 500mb free space on it, this will allow apps room to store extra data, and speed up the time taken to back up your device in iTunes.

Turning off spotlight should turn off the iPhone’s indexing service, which runs in the background and slows down your device. To turn off the spotlight service:

Settings.app -> General -> Spotlight Search – > Uncheck each option.

Step 3: Jailbreak your device.
There used to be a stigma around jailbreaking, it was considered dangerous, and risky to attempt doing it on your device. However, the process is now very simple and largely risk free. My personal iPhone is not Jailbroken, as I require an unmodified one for development, but there are distinct advantages to jailbreaking your device. If you wish to read about the advantages of jailbreaking visit this link or this link.

There is a decent guide for iOS 4.0 jailbreak with the tool redsn0w here. Simply follow the steps, the whole process takes under ten minutes.

When asked, select to ENABLE multitasking, but do NOT enable background wallpaper, as this does not work well on the 3G. I will explain why we are enabling multitasking later.

Once jailbroken, load the new app you have on your device called “Cydia” and once it has finished updating, install the package OpenSSH.

Step 4. Remove Launch Deamons
Daemons are small programs that run in the background on your device, and are responsable for doing certain tasks. Some of these daemons are not necessary, and removing them can have a significant impact on improving the performance of your device.

The guide I used for removing daemons is here

However, should that link be unavailable, I will summarise the steps quickly here.

  1. Download an SSH client for your computer,
    (I recommend WinScp for Windows, and CyberDuck for Mac.)
  2. Find the IP address of your device (needs to be on the same network as your computer). If you dont know how, follow this guide.
  3. On the device, navigate to /System/Library/LaunchDaemons/
  4. Copy the contents of this folder, on to your computer as a backup.
    Then delete the following .plist files:
com.apple.DumpPanic.plist - Dumps crashes for evaluation by Apple.
com.apple.ReportCrash.(Different Things).plist - There are 5 of these daemons, and they collect data about what caused a crash, what programs were running at the time, etc.
com.apple.CrashHouseKeeping.plist - Also deals with crashes.
com.apple.aslmanager.plist - This daemon manages system logs.
com.apple.syslogd.plist - Logs system events.
com.apple.powerlog.plist - This is used to monitor any incompatibilities with 3rd party chargers.
com.apple.stackshot.server.plist - This daemon's function is currently unknown, but removing it has no adverse effects on one's device. Some more information can be found here, although the page is quite technical and isn't very useful to an end-user.
com.apple.tcpdump.server.plist - This daemon is apparently used to dump traffic on a network (Source), but I don't know what that means, exactly. Removing this daemon has no adverse effects on one's device.
com.apple.iqagent.plist - This daemon's function is currently unknown, but removing it has no adverse effects on one's device.
com.apple.mobile.profile_janitor.plist - This daemon's function is currently unknown, but removing it has no adverse effects on one's device.
com.apple.chud.chum.plist - This daemon is thought to relate to Apple's CHUD (Computer Hardware Understanding Developer) tools. Removing this daemon will have no adverse effects on your device, unless you are a developer.
com.apple.chud.pilotfish.plist - This daemon is also thought to relate to Apple's CHUD tools. Removing this daemon will have no adverse effects on your device, unless you are a developer.

You won’t notice any change until you reboot your phone, but don’t do that yet.

Step 5. Remove unnecessary languages from your device.
If you are like me, and only use your device in English, you can gain a performance boost for your apps by removing the unnecessary languages developers put into their apps in order to make them useable for non English speakers.

There is an easy way of doing this, via a script that I found on the modmyi.com forums here:

Here is a sumary of the post (follow the steps exactly, using copy/paste):

PLEASE READ CAREFULLLY. I AM NOT RESPONSIBLE IF THIS DAMAGES YOUR iPHONE - USE AT YOUR OWN RISK!! PLEASE BACK UP YOUR APPLICATIONS FOLDER

These scripts will back up your language files (except English and Japanese) and will delete all language files except English and Japanese.
Make Sure you set your iPhone to Never sleep!

Step 1) SSH into your iPhone with root access (puddy is a good windows ssh program)
Step 2) mkdir /private/var/stash/langBackup/
Step 3) cd to your /private/var/stash/Applications.whatever programs dir
Step 4) Copy and paste this into your ssh program and run it:

for file in `find . -type d -name "*.lproj" -not -iname "en*.lproj" -not -iname "ja*.lproj" -exec echo {} \; | sed -e 's/\.\///'`; do tar -rf /private/var/stash/langBackup/langBackup.tar ./$file ; done

This will back your languages in a tar file located here /private/var/stash/langBackup/langBackup.tar PLEASE VERIFY THIS FILE BEFORE DOING THE NEXT STEP. (should be around 10-15 megs)

Step 5)Copy and paste this into your ssh program and run it:

for file in `find . -type d -name "*.lproj" -not -iname "en*.lproj" -not -iname "ja*.lproj" -exec echo {} \; | sed -e 's/\.\///'`; do rm -vr ./$file ; done

This command will delete all language files except English and Japanese.

These scripts can also be run in your /private/var/mobile/Applications dir to remove languages from 3rd party app store apps. Please NOTE: some 3rd party programs are using spaces in their directory names. These scripts will NOT work on those apps. (will not back up them, but also should not delete their language files)
I have also tried these scripts on /System/Library directory. The back up takes a long time around 15-20 minutes. But deleting is Fast! (carrier bundles, quick time and a few other directories are not backed up/deleted do to spaces in the names)

Please use and modify as you see fit.
Have fun and be careful.
SOURCE: http://modmyi.com/forums/general-iphone-chat/678106-dramatically-increase-performance-firmware-3-0-a-21.html#post4882267

Step 6. Install Virtual Swap Memory on your Device
It has been debated as to whether this has a detrimental affect on the life of your device, some say it will break the flash drive of your device after five years, others say it won’t have an affect at all. Either way my friend had no intention of keeping the device for that long, and would prefer a performance boost right now. If you wish to know more about the risks from this method, please search search Google for “iPhone virtual memory”.

There are two types of virtual memory for your device, it is generally accepted that the second type, the PLIST method is the safest, so this is the one I will be explaining.
Basically it works by telling the device to move items that are normally kept inĀ  memory, but not used very often, on to the flash drive of the device rather than the device’s memory (RAM). This frees up the device’s RAM for other uses, and leads to a greater amount of memory for the device’s apps to use, making them load faster and respond quicker.

Download the plist file from this link or this link:

Go back to your ssh program, and copy the plist file you just downloaded into the /System/Library/LaunchDeamons/ folder you accessed earlier.
At this point, reboot your device.

Step 7. Test for Improvements.
Does the device seem more responsive to you? I found it was, apps that had taken upwards of 6/8 seconds to load before, now have far more reasonable load times.
In addition, with the extra memory the device has from the virtual memory modification the 3G now supports multitasking, and fast app switching quite nicely.
As a result, apps like the SMS.app will suspend rather than close, and so will launch much faster than before.

That is it for now, If I discover any other tricks I will modify this post.
In the meantime, have you had any luck with any of these methods? Please let me know.

VN:F [1.9.3_1094]
Rating: 8.0/10 (1 vote cast)
VN:F [1.9.3_1094]
Rating: +1 (from 1 vote)
Posted in Apple, Jailbreak, iOS, iPhone | Tagged , , , , , , | View Comments

iPhone Audio Sessions – iPodMusicPlayer and AVAudioPlayer

While working on a iPhone project recently, I was looking for a way of playing sound effects via AVAudioPlayer at the same time as music playback via iPodMusicPlayer and had been running into problems until I found this blog post from Sputnik Games (thanks guys!) which solved my problem. Add the following code to the application-didFinishLaunchingWithOptions method in your app delegate in order to solve the problem:

OSStatus result = AudioSessionInitialize(NULL, NULL, NULL, self);
if (result) {
  // Init error, handle error here
 } else {
  UInt32 category = kAudioSessionCategory_AmbientSound;
  result = AudioSessionSetProperty(kAudioSessionProperty_AudioCategory,
                                     sizeof(category), &category);

  if (result) {
    // set audio session error, handle error here
  } else {
    result = AudioSessionSetActive(true);
    if (result) {
      // Set audio session active error, handle error here
    }
  }
}
VN:F [1.9.3_1094]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.3_1094]
Rating: +1 (from 1 vote)
Posted in Objective C, iOS, iPhone | Tagged , , , | View Comments