iOS 14 beta critical null bug for PHAssetCollection.localizedTitle that are short foreign album name

PHAssetCollection.localizedTitle returns "nil" for albums that has 1 or 2 characters in Chinese/Korean language (could be happening for other languages, but we have not tested).

Reproduction step:
  1. On iOS 14.0 beta3, create an album with foreign language

(ex. Korean name: "안녕", Simplified Chinese: "照片")
2. NSLog PHAssetCollection.localizedTitle for this album in a test app

Expected: PHAssetCollection.localizedTitle should return correct album name
Actual: PHAssetCollection.localizedTitle returns (null)

This seem to only happen for album names less than 3 characters. It is fine for album names that are 3 characters or longer.

This seems to happen for albums created in iOS 13 and upgraded to iOS14 as well, so the impact will be large.

We have reports from multiple production users about this issue.
Can you give some details how you create the asset collection and how you fetch it?
Are you sure that the app is not in Limited Library mode? Apps in Limited Library mode can not fetch user albums.
1) It is not in "Limited Library Mode". I have re-installed the app to make sure the app has access to "All Photos".
2) I use PHAssetCollection.fetchAssetCollectionsWithType method (pasting code below as a reference). This happens for albums already created in Photos App as well as the one that I create with the app.
=> This same code successfully returns localizedTitle for the albums that iOS14 seem to have issues with.
=> It also successfully returns album names that are greater than certain length

Some additional information that I discovered:
1) It happens only in real device
2) It happens in swift PhotosKit as well as objective-c (using the same fetch method in swift, I verified this).
3) It does NOT happen using deprecated ALAssetsLibrary

I have a consistent repro steps isolating the issue that happens only in iOS14. Please let me know if you can reproduce it yourself -- and if you need anything to get to reproducing this.

Code reference:
Code Block
// Fetch
PHFetchResult<PHAssetCollection *> *result =
[PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeAlbum
subtype:PHAssetCollectionSubtypeAlbumRegular
options:nil];
// Iterate
for (PHAssetCollection *phAssetCollection in result) {
     NSLog(@"Album name: %@", phAssetCollection.localizedTitle); // problematic album shows null here incorrectly.
   }


This will break user experience for apps that deals with albums Internationally.
We also encountered this problem, please fix it, thanks
Encountered the same issue when authorization is set to 'limited'

Code Block
let fetchOptions = PHFetchOptions()
fetchOptions.predicate = NSPredicate(format: "title = %@", albumName)
let fetchResult: PHFetchResult = PHAssetCollection.fetchAssetCollections(with: .album, subtype: .any, options: fetchOptions)
guard let photoAlbum = fetchResult.firstObject else {
    return nil
}

It always returns nil.

Encountered the same issue when authorization is set to 'limited'

This is expected. When in Limited Library mode, user albums cannot be created or fetched.
See also this year's WWDC session Handle the Limited Photos Library in your app at 11:15.
This is happening with full access too. And even if you rename the album after the initial 1 or 2 character long title, the app will keep crashing. I am getting the error either on accessing _title1 or _title2 in the following snippet (whichever should have the short, 1-2 char long, name):

Code Block
NSComparator albumNameComparator = ^(id _title1, id _title2) {
    /* Do literally anything with _title1 and _title2, one of them will report EXC_BAD_ACCESS if either of them is the 1-2 char long title. */
};
NSSortDescriptor *titleSortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"localizedTitle"
    ascending:YES
                                      comparator:albumNameComparator];
NSArray *sortedArray = [assetCollections sortedArrayUsingDescriptors:@[titleSortDescriptor]];


After debugging by using a custom comparator in
+[NSSortdescriptor:sortDescriptorWithkey:ascending:comparator]
I see that the issue is that when you have a short name, your localizedTitle is not of type _PFResultASCIIString (e.g memory address is _title2 _PFResultASCIIString * 0x11b63a878 0x000000011b63a878),
instead it is of type id with an invalid memory address (e.g. _title1 id 0x9fc0bd70f2930dde), so you get an EXC_BAD_ACCESS error.

This is faulty on Apple's side, and a timely fix is much needed. It is 100% reproducible. You delete the album that had initially 2 characters long title, and the issue goes away. You create another one with two characters, the issue is back.
We also encountered this problem
iOS 14 beta critical null bug for PHAssetCollection.localizedTitle that are short foreign album name
 
 
Q