Problem:
While calling PHAsset.fetchAssets() and iterating over its results, if the Photos.app is simultaneously running an import operation (File | Import), the photolibraryd process crashes. I have already flagged this issue to Apple (FB13178379) but wanted to check if anyone else has encountered this behavior.
Steps to Reproduce:
Initiate an import in the Photos.app.
Run the following code snippet in the Playground:
import Photos
PHPhotoLibrary.requestAuthorization(for: .readWrite) { authorizationStatus in
guard authorizationStatus == .authorized else { return }
let fetchResult = PHAsset.fetchAssets(with: nil)
print(fetchResult)
for i in 0..<fetchResult.count {
print(fetchResult[i])
}
}
Upon doing this, I consistently receive the error: Connection to assetsd was interrupted - photolibraryd exited, died, or closed the photo library in the Console, causing my code to hang.
Environment:
macOS Version: 13.5.2 (22G91)
Xcode Version: Version 14.3.1 (14E300c)
Additional Info:
After the crash, a report pops up in the Console, and typically, the Photos.app import operation freezes too. I've noticed that after terminating all processes and/or rebooting, the Photos.app displays "Restoring from iCloud…" and the recovery process lasts overnight.
Seeking Suggestions:
I'm exploring potential workarounds for this issue. I've attempted to use fetchLimit to obtain assets in batches, but the problem persists. Is there a method to detect that the Photos.app is executing an import, allowing my process to wait until completion? Alternatively, can I catch the photolibraryd crash and delay until it's restored?
I'm operating in a batch processing mode for photos, so pausing and retrying later in the event of a Photos.app import isn't an issue.
Any guidance or shared experiences would be greatly appreciated!
Cheers and happy coding!
Post
Replies
Boosts
Views
Activity
I am developing an iOS app that utilizes the timeInDaylight data from HealthKit. This feature is available starting from iOS 17.0+, but it can only be recorded using the Apple Watch SE (2nd generation) and Apple Watch Series 6 or later.
How should I release this app given its dependency on timeInDaylight data? Without this data, the app is useless.
I understand that the App Store does not allow setting specific health data requirements. I am also concerned that including a "device requirements" warning in the App Store description might not pass the review process.
Could you provide any advice on how to approach this situation?
Thank you.