Ios PhotoKit:来自PHChangeRequestHelper中assetsd的响应无效

Ios PhotoKit:来自PHChangeRequestHelper中assetsd的响应无效,ios,profiling,photokit,phphotolibrary,Ios,Profiling,Photokit,Phphotolibrary,在我的应用程序中,我正在创建一个视频并将其保存到多媒体资料中。 有时(例如20次中有一次)代码无法保存视频 使用AVAssetWriter创建视频,并将其保存在应用程序临时目录中,直到客户端要求将其保存到库中: - (void)saveVideoToGallery:(void(^)(NSError* error))completionHandler { NSString* videoPath = [self tmpVideoFullPath]; __block PHOb

在我的应用程序中,我正在创建一个视频并将其保存到多媒体资料中。 有时(例如20次中有一次)代码无法保存视频

使用
AVAssetWriter
创建视频,并将其保存在应用程序临时目录中,直到客户端要求将其保存到库中:

- (void)saveVideoToGallery:(void(^)(NSError* error))completionHandler
{
    NSString* videoPath = [self tmpVideoFullPath];
    
    __block PHObjectPlaceholder *_placeholder = nil;
    
    [[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
        
        PHAssetChangeRequest* createAssetRequest = [PHAssetChangeRequest creationRequestForAssetFromVideoAtFileURL:[NSURL fileURLWithPath:videoPath]];
        _placeholder = [createAssetRequest placeholderForCreatedAsset];
        
    } completionHandler:^(BOOL success, NSError * _Nullable error) {
        NSLog(@"TADAM Save video to album... %s", success? "✅":"❌");
        completionHandler(error);
    }];
}
saveVideoToGallery
在后台线程中调用

在我的应用程序中,还有一个模块在后台调用
PhotoKit
,但它只读取,不写入(fetchRequests)

PhotoKit
故障日志如下所示:

2020-09-10 13:22:02.315442+0300 MyApp[5448:1561813] [GatekeeperXPC] Error getting remote object proxy for -[PLAssetsdPhotoKitClient requestUUIDWithCustomUUID:reply:]_block_invoke: Error Domain=com.apple.photos.error Code=41002 "Unable to obtain assetsd XPC proxy for getPhotoKitServiceWithReply:. assetsd could have crashed" UserInfo={NSLocalizedDescription=Unable to obtain assetsd XPC proxy for getPhotoKitServiceWithReply:. assetsd could have crashed, NSUnderlyingError=0x28399ef40 {Error Domain=NSCocoaErrorDomain Code=4097 "connection to service on pid 0 named com.apple.photos.service" UserInfo={NSDebugDescription=connection to service on pid 0 named com.apple.photos.service}}}
2020-09-10 13:22:02.315519+0300 MyApp[5448:1561813] [PhotoKit] Failed: Invalid response from assetsd in -[PHChangeRequestHelper _generateUUIDIfNecessary:]_block_invoke Error Domain=com.apple.photos.error Code=41002 "Unable to obtain assetsd XPC proxy for getPhotoKitServiceWithReply:. assetsd could have crashed" UserInfo={NSLocalizedDescription=Unable to obtain assetsd XPC proxy for getPhotoKitServiceWithReply:. assetsd could have crashed, NSUnderlyingError=0x28399ef40 {Error Domain=NSCocoaErrorDomain Code=4097 "connection to service on pid 0 named com.apple.photos.service" UserInfo={NSDebugDescription=connection to service on pid 0 named com.apple.photos.service}}}
所以问题是

  • 如果PhotoKit出现问题,这可能是一个bug,还是我应该以某种方式分析我的代码
  • 您是否知道在发生故障之前获取PhotoKit日志的一些环境变量