Save 48MP ProRaw to PhotoLibrary may fail

After took 48MP ProRaw photo,

captureOutput:(AVCapturePhotoOutput *)output didFinishProcessingPhoto

write to photo library use

[PHPhotoLibrary sharedPhotoLibrary] performChangesAndWait:

or

[PHPhotoLibrary sharedPhotoLibrary] performChanges

There is a high probability of failure

No matter use fileURL or [photo fileDataRepresentation]

failure info below

2022-09-28 10:43:57.353815+0800 LUTCamera[2031:218103] [GatekeeperXPC] Error received from proxy factory <PLAssetsdServiceProxyFactory: 0x28190b300> in sendChangesRequest:usingProxyFactory:error:: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.photos.service was interrupted, but the message was sent over an additional proxy and therefore this proxy has become invalid." UserInfo={NSDebugDescription=The connection to service named com.apple.photos.service was interrupted, but the message was sent over an additional proxy and therefore this proxy has become invalid.}
2022-09-28 10:43:57.354114+0800 LUTCamera[2031:218103] [PhotoKit] PhotoKit XPC proxy is invalid. Dropping request on the floor and returning an error: Error Domain=PHPhotosErrorDomain Code=3301 "(null)" (underlying error Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.photos.service was interrupted, but the message was sent over an additional proxy and therefore this proxy has become invalid." UserInfo={NSDebugDescription=The connection to service named com.apple.photos.service was interrupted, but the message was sent over an additional proxy and therefore this proxy has become invalid.})
2022-09-28 10:43:57.359493+0800 LUTCamera[2031:218100] [error] error: XPC: synchronousRemoteObjectProxyWithErrorHandler encountered error: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service created from an endpoint was invalidated: failed to check-in, peer may have been unloaded: mach_error=10000003." UserInfo={NSDebugDescription=The connection to service created from an endpoint was invalidated: failed to check-in, peer may have been unloaded: mach_error=10000003.}
2022-09-28 10:43:57.359508+0800 LUTCamera[2031:218257] CoreData: XPC: XPC connection was invalidated
CoreData: error: XPC: synchronousRemoteObjectProxyWithErrorHandler encountered error: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service created from an endpoint was invalidated: failed to check-in, peer may have been unloaded: mach_error=10000003." UserInfo={NSDebugDescription=The connection to service created from an endpoint was invalidated: failed to check-in, peer may have been unloaded: mach_error=10000003.}
2022-09-28 10:43:57.473207+0800 LUTCamera[2031:218100] CoreData: XPC: sendMessage: failed #0
Answered by Frameworks Engineer in 730465022

This should be addressed in the iOS 16.1 beta: https://developer.apple.com/news/releases/?id=09142022e

Also, to improve the overall performance and user experience for RAW captures that are added to the photo library we recommend that you include a thumbnail/preview in the RAW (like the system Camera app does). There is some discussion of this in the WWDC2021 Capture and Process ProRAW images session: https://developer.apple.com/videos/play/wwdc2021/10160/

Specifically this recommendation: "If your intent is to save a ProRAW file to the photo library, you should use the capture settings to embed a full-size JPEG preview in the file"

Accepted Answer

This should be addressed in the iOS 16.1 beta: https://developer.apple.com/news/releases/?id=09142022e

Also, to improve the overall performance and user experience for RAW captures that are added to the photo library we recommend that you include a thumbnail/preview in the RAW (like the system Camera app does). There is some discussion of this in the WWDC2021 Capture and Process ProRAW images session: https://developer.apple.com/videos/play/wwdc2021/10160/

Specifically this recommendation: "If your intent is to save a ProRAW file to the photo library, you should use the capture settings to embed a full-size JPEG preview in the file"

Save 48MP ProRaw to PhotoLibrary may fail
 
 
Q