views:

232

answers:

4

Hi all,

I'm new to computer coding and have just finished coding an app and tested it on both 3G and 3GS. On 3GS, it worked as normal as on the simulator. However, when I tried to run it on 3G, the app becomes extremely slow. I'm not sure what's the reason and I hope someone could shed some light on me.

Generally, my app has a couple of view controller classes, with one of them being the title page, one being the main page, one is setting, etc. I used a dissolve to transition from the title page to the main page. But even this simple transition shows un-smooth performance on a 3G! My other part of the app involves zooming in to some images by scaling up the images, switching images by push or dissolve upon receiving touch events, saving photos into photo library and storing and retrieving some photos in a folder and some data in a SQlite database, each showing un-smooth actions.

Compared with some heavy graphic or heavy maths app, I think mine is pretty simple. I totally have no clue why the app would behave so slow and un-smooth that it is barely useful on a 3G. Any help/ direction would be much appreciated. Thanks for helping out.

+6  A: 

You might want to try profiling your application with Shark to find out where the performance bottlenecks are.

David Gelhar
Exactly. The first step in understanding a performance slowdown is profiling, through Shark or Instruments or some other tool.
Brad Larson
Thanks David. I think I'll need some time to learn how to use Shark.
Anthony Chan
+1  A: 

I don't know how relevant it is to your case, but my game (shameless plug) MultiMaze is quite undemanding graphically, and worked beautifully on my 3GS. But when I tried it on a 3G, the frame rate dropped to a glacial 10-20 fps. I ported the whole code base from CoreGraphics to OpenGL ES, and that made a world of difference. It now runs at the limit (60 fps) on my 3GS and very close to it on the 3G.

Marcelo Cantos
How far we've come that 20fps on a mobile phone is slow.
John
Thanks Marcelo. I'll try some more methods before trying OpenGL ES, as I'm totally new to computer programming. Thanks anyway.
Anthony Chan
+1  A: 

Are you using a lot of memory? 3G has 128MB while the 3GS has 256MB RAM.

Are you getting memory warnings? In my debug builds I have an NSLog in didReceiveMemoryWarning so I can see if/when I get warnings.

EDIT: Check the size of your photos, are they resized for the iPhone screen or are they original sized?

progrmr
Hi progrmr, thanks for the advice. In fact, I do get memory warnings in my app, but I don't know why. My whole app is just 3.2MB (including all images and codes), and I only load those images when needed. Is there any clue where the memory goes?
Anthony Chan
You could run with the Leaks tool to check for memory leaks, other than that I don't know how to find out how much space objects take up or your program uses. Photos can be quite large, check there first and don't forget jpg's and png's are uncompressed when loaded into memory, they can be many times bigger than their corresponding disk file.
progrmr
A: 

OK, finally found the problem and got the solution. The problem was that I have about a dozens of transparent images laying on each other to form my main view. So when in any animation, the system needs to redraw on every single layer and calculate their transparent effect and so on. (actually I'm not quite sure, but that's what I think)

The solution I have is to make a temporary composite view containing of them all, and placing the composite as an image in a full screen view before starting any animation. It delays starting the fade a moment, but the fade itself is a lot smoother now.

Anthony Chan