Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why isn't my iPhone 5 showing 60+ fps even on a completely bare UITableView scroll?

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:

Table View

I uploaded a barebones app here.

Can someone confirm I'm not crazy?

Update

Is 60fps the max you can get on an iPhone? Will core animation ever go faster than that?

like image 618
Bob Spryn Avatar asked Feb 14 '13 03:02

Bob Spryn


1 Answers

A couple of thoughts:

  1. I'm hyper sensitive to this, but in my opinion, high 50s is excellent.

  2. 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.

  3. 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.

  4. 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.

like image 181
Rob Avatar answered Oct 01 '22 19:10

Rob