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

Use estimatedAssetCount when updating collections #148

Merged
merged 1 commit into from
Sep 24, 2015

Conversation

kevinwo
Copy link
Contributor

@kevinwo kevinwo commented Sep 17, 2015

I noticed loading the picker becomes extremely slow (a few seconds on an iPhone 6, and as long as 10 - 15 seconds on an iPhone 4S) when you have a few thousand photos in your library. The bottleneck appears to be in calculating the number of items in a given collection – currently it requires fetching full PHAsset objects, and I think using estimatedAssetCount on the PHAssetCollection object would be a more efficient option. After implementing, I noticed the load time on the 4S comes down to 1 - 2 seconds.

screen shot 2015-09-17 at 9 06 04 pm

@1and2papa
Copy link
Owner

@kevinwo Thank you. I indeed thought about using estimatedAssetCount in the very first beginning until I found in the document that it might not match the number in the collection:-

This count may not match the current number of assets in the collection. To get the most recent count, fetch the collection’s assets with the fetchAssetsInAssetCollection:options: method and read the count property of the fetch result.

Given that this picker supports custom assetsFetchOptions, I would also like to add a property for not using estimatedAssetCount. This PR would not be merged directly but I will add the function as said in the coming release.

@kevinwo
Copy link
Contributor Author

kevinwo commented Sep 21, 2015

Thanks @chiunam! Sounds good!

1and2papa added a commit that referenced this pull request Sep 24, 2015
Use estimatedAssetCount when updating collections
@1and2papa 1and2papa merged commit 0dd4f14 into 1and2papa:master Sep 24, 2015
@1and2papa
Copy link
Owner

@kevinwo Just realise that estimatedAssetCount does not return the result instantly so I'll keep using fetchAssetsInAssetCollection:options: for showing the asset count of the albums.

To check whether the album is empty when updating collections, your suggestion of using estimatedAssetCount is good enough indeed so this PR will be merged. Thanks.

@kevinwo
Copy link
Contributor Author

kevinwo commented Sep 24, 2015

@chiunam Cool, thanks!

1and2papa added a commit that referenced this pull request Oct 2, 2015
Use estimatedAssetCount when updating collections
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants