FMPhotoPicker icon indicating copy to clipboard operation
FMPhotoPicker copied to clipboard

Pagination for loading assets?

Open hyouuu opened this issue 6 years ago • 4 comments

When I present the picker, the UI loads up very slowly, and if I tap on the top bar it immediately goes to the very first photo of my photo library, which makes me believe it loaded up the entire library's thumbnails upon opening, and that's probably the major cause of the slowless. Could we make the load paginated and only load more as we scroll up?

hyouuu avatar Jun 30 '19 22:06 hyouuu

In reality, the lib doesn't load any image/video data until it is displayed on the screen. The lib only loads the PHAsset objects from the photo library and load thumbnails only when it needs to display images/videos. It's hard to be a root cause for this situation. I've tried with my own device contains ~300 images and video, the lib load and display the first screen immediately without any problem. So it would better if you can provide more information about the environment that you did the test on, or please provide a demo project for easy to reproduction.

congnd avatar Jul 01 '19 09:07 congnd

Thanks for the quick reply! I think 300 is not a good size to test - e.g. my Photos app contains 22,888 photos, and I think a typical person who has used iPhone for a few years would at least have 5000 photos, so probably test with 9000 photos? Just run the FMPhotoPicker example project on my phone would reproduce the issue - it shows a white screen for 2 seconds before showing the photos, and that's on iPhone XS, so it would be much slower on an older phone.

hyouuu avatar Jul 01 '19 21:07 hyouuu

Did an initial investigation and this line caused the most time: https://github.com/tribalmedia/FMPhotoPicker/blob/b791eca55526cd8c64ee4589b6b45a3e8f8dec86/FMPhotoPicker/FMPhotoPicker/source/Utilities/Helper.swift#L153

I think we should lazily load objects here, and call objects(at indexes: IndexSet) around the currently displayed page. I could try to make an improvement later too.

hyouuu avatar Jul 02 '19 01:07 hyouuu