Decrease startup time

Member
Posts: 61
Joined: 2009.01
Post: #1
Hey all,

Don't worry, this isn't a 3.0 question. Wink

Do you guys know of any way to decrease the startup time for an app? My game has a very long (about 12 second) startup time because I have so much stuff in the Resources folder. On other platforms, I would just be loading images and sounds and the like in as desired, but it seems that the iPhone appears to first put absolutely everything in resources into the RAM, which obviously takes a very long time.

Any idea how I can selectively put things into RAM and leave everything else out of it? It's clear that other apps are able to do that (they start up very quickly, then have a separate load screen). Where do I put all these extra resources in order to make that happen correctly?

Thanks a lot.

PS - Maybe I need to use Nib files to specify bundles? If so, do people usually have one nib file per level or something like that? Even so, I would prefer just being able to treat the resources directory as if it's a big file directory, then load everything manually from there as I desire (just because that's what meshes well with my level editor). Any way to do that?
Quote this message in a reply
Member
Posts: 161
Joined: 2005.07
Post: #2
Wait, how are you sure it's loading your entire resources folder? It sounds a lot more likely that the iPhone is just a lot slower at loading your textures and sounds than your computer.

My game took about that long to load when I first compiled it for the iPod (I was previously using the simulator), but I quickly realized the problem was that my iPod was choking on the six 256x256 textures I told it to load when launching. If I commented out those lines, the game would launch instantly.

Try only loading the main menu textures when the app launches, and load the game textures when they go to play the game.
Quote this message in a reply
Member
Posts: 61
Joined: 2009.01
Post: #3
Looks like you're absolutely right. I don't know why I didn't realize I was doing that earlier (I still had it loading level 1 at startup!). Thanks a lot for pointing that out.
Quote this message in a reply
Member
Posts: 268
Joined: 2005.04
Post: #4
Your Default.png image doesn't go away until after applicationDidFinishLaunching: is sent to your delegate. That doesn't get sent until after all your init: and awakeFromNib: methods are called. So if you want to load up super-duper-extra fast, or want to display an animated loading screen or whatever, you'll want to init your assets after applicationDidFinishLaunching:.
Quote this message in a reply
Moderator
Posts: 133
Joined: 2008.05
Post: #5
Bachus Wrote:That doesn't get sent until after all your init: and awakeFromNib: methods are called.

I'd be pretty careful about phrasing it this way just in case someone new to development stumbles along this thread. Only objects that archived in to MainWindow.xib (and UIApplication) are allocated and initialized before applicationDidFinishLaunching: is sent to your application delegate.

This is especially important when thinking about view controllers and their views. A view controller can be archived in to a XIB file, but its view is not loaded until that view controller is sent the message view (which might not be a message you send directly).

Back to the question at hand... your resources folder is just data sitting on disk. Images, sounds, videos, text files, property lists, all of those things are not even touched until you load them in the RAM. The iPhone has a very limited amount of RAM, you should load and unload resources as needed. Loading all of your resources at startup has two problems: you get the delay on launch, and you run the risk of running out of memory and getting a low memory warning.
Quote this message in a reply
Member
Posts: 306
Joined: 2009.03
Post: #6
For a point of reference. I have a 2nd gen touch and about 5 1024x1024 png textures and my loadup time is about 3 seconds.
Quote this message in a reply
Member
Posts: 161
Joined: 2005.07
Post: #7
kendric Wrote:For a point of reference. I have a 2nd gen touch and about 5 1024x1024 png textures and my loadup time is about 3 seconds.
Are you loading those 5 textures before your app launches? If so, what image loading library are you using? Five 1024x1024 textures loading in 3 seconds would be 64x faster than the library I'm using (SOIL on a 1st gen iPod touch).
Quote this message in a reply
Member
Posts: 306
Joined: 2009.03
Post: #8
I am just using the built in stuff for this. I don't have the code infront of me, but its related to UIImage. I believe everything is loaded at the start. If you want more details let me know and I can post some code.
Quote this message in a reply
Post Reply