Skip to content

25 FPS on iPad 3 #126

Closed
Closed

Description

@Axlle

I'm running the Demo App on an iPad 3 and getting 25 FPS when scrolling up and down (20 FPS without #125). The app becomes CPU-bound once each cell is changing every frame. An iPad 3 does not have the CPU to create 100+ UIImages, assign them to UIImageViews and commit the changes to Core Animation.

screen shot 2016-02-04 at 5 18 59 pm

A workaround I have on this branch is to wrap every image fetch in a NSBlockOperation. The operation guarantees that the app will get 60 FPS because it avoids returning all 100+ images in a single frame. This is most noticeable on an iPad 3, which can only perform ~7 image updates per frame.

I feel that the cache should provide async and cancellable requests, by default, so that every use of the cache does not need to implement its own throttling. Regardless of the speed of the device, and no matter how amazing the cache, there is always a limit on the number of images that can be fetched in a single frame because each request takes a non-zero amount of time.

Thoughts?

I am happy to work on this, given a bit of guidance on the internal threading and the callback structure of the image cache.

Activity

  1. changed the title [-]Demo App getting 25 FPS on iPad 3[/-] [+]25 FPS on iPad 3[/+] on Feb 5, 2016
  2. mallorypaine commented on Feb 5, 2016

    @mallorypaine
    Contributor

    I'll need to investigate what has happened to performance. On device, we should be achieving 60fps without issue.

  3. mallorypaine commented on Feb 5, 2016

    @mallorypaine
    Contributor

    I don't have an iPad 3 at home, but I ran some tests on older iPhones and didn's see anything unusual. I do need to track down this device. What version of iOS is it running?

  4. Axlle commented on Feb 8, 2016

    @Axlle
    Author

    It's running iOS 8.4.

    The image cache isn't slow, UIKit is. I'm testing the performance on an iPad 3 because the iPad 3 historically has the worst graphics performance of any iOS device.

    Replacing the table view cell's call to retrieveImageForEntity:withFormatName:completionBlock: with asynchronouslyRetrieveImageForEntity:withFormatName:completionBlock: solves the frame rate problem, but then it becomes possible to overload the cache.

    2016-02-08 11:09:27.974 FastImageCacheDemo[196:18240] FICImageTable - unable to evict entry from table 'com.path.FastImageCacheDemo.FICDPhotoSquareImage32BitBGRAFormatName' to make room. New index 400, desired max 400
    2016-02-08 11:09:28.137 FastImageCacheDemo[196:18240] FICImageTable - unable to evict entry from table 'com.path.FastImageCacheDemo.FICDPhotoSquareImage32BitBGRAFormatName' to make room. New index 401, desired max 400
    2016-02-08 11:09:28.289 FastImageCacheDemo[196:18240] FICImageTable - unable to evict entry from table 'com.path.FastImageCacheDemo.FICDPhotoSquareImage32BitBGRAFormatName' to make room. New index 402, desired max 400
    2016-02-08 11:09:28.442 FastImageCacheDemo[196:18240] FICImageTable - unable to evict entry from table 'com.path.FastImageCacheDemo.FICDPhotoSquareImage32BitBGRAFormatName' to make room. New index 403, desired max 400
    ...
    

    Note: I did change the demo app to have 5000 unique photos instead of 100, because 100 photos never exercised the cache's 400 image limit.

  5. Axlle commented on Feb 9, 2016

    @Axlle
    Author

    @mallorypaine It looks like I am reproducing #82 with the demo app. The code I am running is here. Should the cache not have a overflow list for the extra images when there are more images requested than can fit in the cache?

  6. mallorypaine commented on Feb 9, 2016

    @mallorypaine
    Contributor

    What are your exact steps to repro #82?

  7. Axlle commented on Feb 9, 2016

    @Axlle
    Author

    I was scrolling down fast enough to get 400+ requests in-flight at the same time. I guess it depends on the device but it was easy with the iPad 3, which can only process a few images a second.

  8. mallorypaine commented on Sep 12, 2016

    @mallorypaine
    Contributor

    I believe your PR addressed this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions