Fetching assets takes too much time on a big album
Originator: | martin | ||
Number: | rdar://7533326 | Date Originated: | 2020-01-13 |
Status: | Open | Resolved: | |
Product: | PhotoKit | Product Version: | |
Classification: | Reproducible: | Always |
Description of the problem: Fetching assets (PHAsset) takes way too much time (more than 3 seconds) when performed on a device with more than 50 000 assets. This latency even occures when setting a fetchLimit of 1 (or any other small number). How to reproduce: - Pick a phone that has at least 50 000 assets. - Get a reference to the “Recent” album: `let collection = PHAssetCollection.fetchAssetCollections(with: .smartAlbum, subtype: .smartAlbumUserLibrary, options: nil).firstObject` - Create a fetch options object and fetch the assets: let fetchOptions = PHFetchOptions() fetchOptions.predicate = NSPredicate(format: "mediaType = %d", PHAssetMediaType.image.rawValue) let fetchResult = PHAsset.fetchAssets(in: collection, options: fetchOptions) Expected result: The assets should be fetched in a reasonable amount of time. Observed result: It takes more than 3 seconds to fetch the assets.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!