Reputation: 17812
In my application, I've been working to get my fps above 60 in the core animation tool while scrolling my table views on an iPhone 5. My GPU isn't tapping out, and I couldn't really identify anything that sped it up (by commenting things out or deleting views in a nib).
After hours, I finally got curious and started a fresh junk application with nothing but a UITableViewController that just spits out the same cell over and over. I profiled this with 1000 rows while scrolling, and STILL only got in the high 50's.
What am I missing here? There's no way that's correct. It doesn't get any simpler than this straight up table displaying:
I uploaded a barebones app here.
Can someone confirm I'm not crazy?
Is 60fps the max you can get on an iPhone? Will core animation ever go faster than that?
Upvotes: 6
Views: 2433
Reputation: 438287
A couple of thoughts:
I'm hyper sensitive to this, but in my opinion, high 50s is excellent.
When I benchmarked this using code (which is more accurate than Instruments), a plain text tableview on an iPhone 5 was locked in a 60.0 fps, so I'm skeptical of your "high 50s" number. Your performance could have been degraded if:
If you measured it via Instruments;
Did your test with a debug build; or
Launched the app from Xcode rather than launching it from the device itself.
To get a bit of a qualitative sense of UX for different frame rates, I slowly degraded performance by doing image loading in the background on my table view, and then further degraded by doing this computationally expensive process in the foreground. I'll spare you the gory details, but bottom line, in my opinion, frame rates in the mid 50s and above were all silky smooth, I started to notice (but it wasn't horrible) the frame rate as it declined to 30-40 fps, and as the frame rates declined to 5-15 fps the UX became completely unacceptable. You should experiment, yourself, but with good designs, should be able to stay in the high 50s, but as low as mid 50s is probably fine.
Instruments might not give you the most accurate measurement. I might measure it in code. I put a fpsLabel
on a spare spot on my screen, which updates once per second with a CADisplayLink
(or if you have custom draw routines, you can do your own fps calculations there):
@interface ViewController () <UITableViewDataSource>
@property (nonatomic) CFTimeInterval previousTimestamp;
@property (nonatomic) NSInteger frameCount;
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.previousTimestamp = CFAbsoluteTimeGetCurrent();
CADisplayLink *displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(handleDisplayLink:)];
[displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes];
}
- (void)handleDisplayLink:(CADisplayLink *)displayLink;
{
CFTimeInterval now = CFAbsoluteTimeGetCurrent();
CFTimeInterval elapsed = now - self.previousTimestamp;
self.frameCount++;
if (elapsed > 1.0)
{
CGFloat fps = self.frameCount / elapsed;
dispatch_async(dispatch_get_main_queue(), ^{
self.fpsLabel.text = [NSString stringWithFormat:@"%.1f fps", fps];
});
self.previousTimestamp = now;
self.frameCount = 0;
}
}
Bottom line, a combination of a more accurate measurement (via code) in release build conditions (i.e. not linked to the computer, running non-debug build), I think you'll find that the table view performance on iPhone 5 is excellent, locked in at 60 fps. But even if your UI dips to mid 50s fps, I personally think that's still fine.
Upvotes: 8
Reputation: 17812
So I think the answer here is that my expectations were incorrect.
Everything I read seemed to say you want to get your app to 60 fps. I didn't realize that that was in fact the maximum fps, and that you are basically never going to get solid 60fps.
After profiling a bunch of other apps in instruments (which I didn't realize I could do on other people's apps from the app store), it seems that most apps (most well built apps) table views hover in the low to high 50's while scrolling. Path was the one exception I found so far that pretty much locks in at either 59 or 60, which is incredible with everything they are rendering.
So it seems I should actually be pretty satisfied with 50+ fps.
Upvotes: 0
Reputation: 16310
Animating above 60Hz would just be a waste of battery. The screen doesn't refresh any faster than that and your eyes can't differentiate motion above 60Hz.
Upvotes: 0