Post

Replies

Boosts

Views

Activity

Potential bug with PHAsset Creation Request with photoProxy resource type.
I have noticed a problem when a PHAsset creation request is made with the resource type PHAssetResourceType.photoProxy. let creationRequest = PHAssetCreationRequest.forAsset() creationRequest.addResource(with: .photoProxy, data: photoData, options: nil) creationRequest.location = location creationRequest.isFavorite = true After successfully saving the resulting asset through PHPhotoLibrary.shared().performChanges, I could verify it in the Photos app. I noticed that the created photo was initially marked as Favorite and that the location was added to the info as expected. The title of the image changes from "Today" to "" too. Next, the photo was refreshed, and location data was purged. However, the title remains unchanged and displays the . This refresh was also observed in the code. PHPhotoLibraryChangeObserver protocols func photoLibraryDidChange(_ changeInstance: PHChange) receives a change notification. The same asset has been changed, and there is no location information anymore. isFavorite information persists correctly. After debugging for a few hours, I discovered that changing the resource type to .photo fixes this issue. Location data is not removed in the Photos app, and no refresh callback is seen in func photoLibraryDidChange(_ changeInstance: PHChange). I initially used .photoProxy because in the AVCapturePhotoCaptureDelegate implementation class, I always get the call in func photoOutput(_ output: AVCapturePhotoOutput, didFinishCapturingDeferredPhotoProxy deferredPhotoProxy: AVCaptureDeferredPhotoProxy?, error: Error?). So here is where I am capturing the photo data as photoData = deferredPhotoProxy?.fileDataRepresentation().
2
0
191
Oct ’24