Created attachment 558026 [details] [diff] [review]
During a firstrun after installing or updating, Firefox Mobile will extract a small set of files out of the APK to the filesystem. We do this because some parts of Gecko can't load those resources from a JAR. Examples currently include:
* application.ini and other app/update files (these are usually small)
* Add-on XPIs
* Hyphenation files (these are usually large and we have ~20 files)
Once these files are extracted, subsequent launches skip the unpacking stage.
This patch streamlines the unpacking method:
* Moves the splash screen update out of the function. We don't need to render the splash screen for each file. Once is enough.
* Drops a file.exist() check since the file.lasModified() check will accomplish the same thing.
* Fixes a bug where we attempt to create the parent directory structure, if it doesn't exist. The current code checks to see if the new file exists and if it doesn't, we create the parent directories. This will always fail, so we always attempt to create the parent directories, This hurts when 20+ files are in the same folder.
* Increases the buffer from 8KB to 32KB. The hyphenation files are usually >100KB, so a larger buffer helps a little.
* Moves the check for zombies outside the unpack function. We only want to check once anyway.
Using this patch, I tested the unpacking time on 3 devices. I made 3 runs, and had to uninstall/reinstall before each run, so the unpacking process was forced to happen. Below are the averages of the 3 runs, with and without the patch
device w/o w/ improvement
Galaxy Tab 8206ms 7058ms 1148ms
Nexus One 1727ms 1353ms 374ms
Acer A500 615ms 144ms 451ms
Remember, this is just the unpacking time, not the complete time for startup. The patch makes a sizeable dent in firstrun startup time after install/update.