My iOS app allows users to edit and save videos. The edited videos are saved with a call to
PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL:
within a PHPhotoLibrary
's performChanges
block.These calls frequently fail with the error code
41002
(Domain: com.apple.photos.error
). Its localizedDescription
is:Unable to obtain assetsd XPC proxy for getPhotoKitServiceWithReply:. assetsd could have crashed
What does the error mean? I tried to search for the error code, the domain and the keywords from the description, but couldn't find anything. Is there an official reference for the errors in this domain? What error message should I show to the user?
An Apple engineer has provided me the following explanation:
The app could not communicate with a helper application (i.e. the photo library). The most common reason that
assetsd
might crash is because the foreground app is using a lot of memory (or allocating memory very quickly), and the system decides to terminate assetsd
to alleviate some of that memory pressure.To prevent these errors, you should make sure that your app is not triggering a high memory pressure situation.
This should only be a temporary issue. In other words, if you tried to submit the same request later, it may work (assuming that any high memory pressure situation has been resolved). So, I recommend that you queue up requests that fail and try to submit them later, and inform your user of this in some way, so that they know the save has not gone through yet.
This same issue can also create an error with the code
4099
, domain NSCocoaErrorDomain
and the description:Couldn’t communicate with a helper application.