Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pagination for loading assets? #29

Open
hyouuu opened this issue Jun 30, 2019 · 4 comments
Open

Pagination for loading assets? #29

hyouuu opened this issue Jun 30, 2019 · 4 comments
Labels
enhancement New feature or request

Comments

@hyouuu
Copy link

hyouuu commented Jun 30, 2019

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?

@congnd
Copy link
Owner

congnd commented Jul 1, 2019

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.

@hyouuu
Copy link
Author

hyouuu commented Jul 1, 2019

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
Copy link
Author

hyouuu commented Jul 2, 2019

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.

@congnd congnd added the enhancement New feature or request label Apr 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants
@hyouuu @congnd and others