Kenny Wyland
Kenny Wyland

Reputation: 21870

Reducing iPhone App Start Up Time

I'm trying to investigate a very long start up time for my app and could use some help. It takes about 6-7 seconds to start up and that's just FAR too long. I'm not loading any data sets or anything, but the app is a calculator so my xib does have lots of buttons and button images.

I'd like to use Instruments (or something else) to analyze where all of the time is being spent so that I can optimize, but the documentation for Instruments isn't really giving me much on specifics of how to use it for this specific problem and/or how to interpret the results.

Do you have any suggestions for how to test this? A pointer to a tutorial on how to use Instruments for this? An iTunes U video or something else?

Any suggestions are welcome!

Kenny

Upvotes: 3

Views: 2400

Answers (4)

Kenny Wyland
Kenny Wyland

Reputation: 21870

Palimondo asked how I eventually solved my problem... it was a bunch of small changes and I'm not truly sure where the savings came in to play and I'll explain why below.

My app is a calculator, so it has a ton of buttons. I thought at first it must be the button loading causing the problem, but as I explained in the comments above to Paul, even if I loaded 0 buttons, that only shaved 1 second off of the start up time. After changing many small things, I was able to save 3 seconds off of start up time which was good enough.

I had a background image that was a nice textured-gradient-ish image. I reduced the file size on it (changed the texture, exported it with different options).

I went from loading 100 buttons up front (it's a calculator) to loading about 15, but attempted to do it in a secret fashion so the user wouldn't notice. About 50 of the buttons aren't visible to start anyway because you have to tap a Shift button to see them, so they were easy to lazy-load. The others are visible, but I figured that the user isn't going to tap most of those right at start-up because they need to hit some numbers first. So I left all of the number pad buttons and the Clear button in the xib so they are loaded on start up but removed everything else from the xib.

That left me with a big blank area on the screen and you could actually see the buttons filling in the blank area as I lazy loaded them (filling very quickly, but you could see the blank area and then all the buttons appear). So I updated the background gradient graphic to include images of the buttons. The buttons appear to be there, but they aren't, so unless the user taps a fake button within 2 seconds they never notice a problem... and usually they just try to tap that button again anyway and by then it usually has been lazy-loaded and therefore works.

Upvotes: 2

hotpaw2
hotpaw2

Reputation: 70673

I would measure the startup time of an empty dummy app (maybe the XCode Window-based app template) on your actual device (debugger disconnected). Then start adding your initialization code, views and objects from your app into this dummy app until you find what's slowing the startup time the most.

Upvotes: 0

David Liu
David Liu

Reputation: 9601

Before doing any of the above suggestions:

Is this 6-7 seconds while running from XCode? Or from starting directly by tapping it on the iPhone?

Debuggers and instruments won't help you much here, since they just add to the overhead, and won't help as much in profiling because it poisons the data you'll see.

Edit:

In terms of profiling tools, you may want to look into using Shark: http://www.switchonthecode.com/tutorials/using-shark-to-performance-tune-your-iphone-app

It's pretty simple to use in general. It's sorta self-explanatory.

Upvotes: 1

Paul Ardeleanu
Paul Ardeleanu

Reputation: 6700

Here are couple of suggestions:

  • do you need all those buttons loading up at once?
  • do you (over)use transparencies in your images?
  • are the images the exact size required? Stretching (resizing) takes time to compute
  • do you perform any operation that is blocking the main thread?

Upvotes: 1

Related Questions