views:

147

answers:

1

I have an iphone app that basically uses the camera, an opengl layer, and UIViews (some drawing with Quartz). It runs ok on 3GS, but on the 3G it is unusable. Particularly, when I press a UIButton, it literally takes sometimes 10 seconds to register the press. Shark doesn't do me much good because it crashes when I try to profile even a tiny portion, and I've tried turning off some of the layers to see if they might be obvious contributors to the lag. I've noticed that turning off the camera really helps.

I'm wondering if anyone has any familiarity with this and might suggest some likely causes. I had issues with extreme slowdown from running my app in landscape mode and using transforms, so considered that might be a cause, but I'm wondering if hoping for a 3G to run something with all of the above elements is just not really possible considering the camera seems to really cost a lot.

The fact that the buttons are horribly delayed in their response makes me think there is something fundamental that I might be missing.

A: 

If it takes 10 seconds to respond at all, that means events on your main thread are being queued faster than they can be processed. That is a very bad thing. There are a number of ways to combat this depending on how you've designed your application

rpetrich
Mentioning the ways to combat it would be nice.
Xorlev
Push IO operations to background threads. Use CADisplayLink or NSTimer so that the iPhone will automatically reduce framerate when there's congestion. Optimize your OpenGL code so that while commands are being sent to the GPU, the next frame is being prepared. Avoid blocking functions. Don't mix Quartz with OpenGL. Lastly: do less work. Not all of these optimizations will apply to everyone; profile at each step.
rpetrich