albumImported smart album returns the panoramas collection instead of imported photos collection

Originator:constantin
Number:rdar://FB9892143 Date Originated:08/02/2022
Status:Open Resolved:
Product:iOS Product Version:15
Classification: Reproducible:Yes
 
Using the `PHAssetCollection.fetchAssetCollections(with:subtype:options)` API to fetch user's smart albums returns a panoramas collection when trying to find the imported photos collection, using the call below:

`PHAssetCollection.fetchAssetCollections(with: .smartAlbum, subtype: .albumImported, options: nil)`

If one would take the resulting collection from the call above, and use the `PHAsset.fetchAssets(in:options)`, they would receive all user's panoramas instead all of the user's imported photos. Here's a more complete example on how to reproduce the issue:

```
func panoramasEqualsImported() {
      let importedCollection = PHAssetCollection.fetchAssetCollections(with: .smartAlbum,
                                                                       subtype: .albumImported,
                                                                       options: nil)

      let panoramasCollection = PHAssetCollection.fetchAssetCollections(with: .smartAlbum,
                                                                        subtype: .smartAlbumPanoramas,
                                                                        options: nil)

      guard let importedCollection = importedCollection.firstObject, let panoramasCollection = panoramasCollection.firstObject else { return }

      let importedResults = PHAsset.fetchAssets(in: importedCollection, options: nil)
      let panoramaResults = PHAsset.fetchAssets(in: panoramasCollection, options: nil)

      let importedAssets = importedResults.objects(at: IndexSet(integersIn: 0..<importedResults.count)).map { $0.localIdentifier }
      let panoramaAssets = panoramaResults.objects(at: IndexSet(integersIn: 0..<panoramaResults.count)).map { $0.localIdentifier }

      let areAlbumsEqual = importedAssets.elementsEqual(panoramaAssets) // true
}
```

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!