GitToTheHub commented on code in PR #942:
URL:
https://github.com/apache/cordova-plugin-camera/pull/942#discussion_r2724732095
##########
src/ios/CDVCamera.m:
##########
@@ -394,46 +393,40 @@ - (void)picker:(PHPickerViewController*)picker
didFinishPicking:(NSArray<PHPicke
NSString *assetIdentifier = pickerResult.assetIdentifier;
dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf processPHPickerImage:image
assetIdentifier:assetIdentifier callbackId:callbackId options:pictureOptions];
+
+ // Fetch metadata if asset identifier is available
+ if (assetIdentifier) {
+ PHFetchResult *result = [PHAsset
fetchAssetsWithLocalIdentifiers:@[assetIdentifier] options:nil];
+ PHAsset *asset = result.firstObject;
+
+ if (asset) {
+ PHImageRequestOptions *imageOptions =
[[PHImageRequestOptions alloc] init];
+ imageOptions.synchronous = YES;
+ imageOptions.networkAccessAllowed = YES;
+
+ [[PHImageManager defaultManager]
requestImageDataAndOrientationForAsset:asset
+
options:imageOptions
+
resultHandler:^(NSData *_Nullable imageData, NSString *_Nullable
dataUTI, CGImagePropertyOrientation orientation, NSDictionary *_Nullable info) {
+ NSDictionary *metadata = imageData ? [weakSelf
convertImageMetadata:imageData] : nil;
+ dispatch_async(dispatch_get_main_queue(), ^{
+ [weakSelf finalizePHPickerImage:image
+ metadata:metadata
+ callbackId:callbackId
+
options:pictureOptions];
+ });
+ }];
+ return;
+ }
+ }
Review Comment:
Good catch. Only UI work has to be done on the UI thread. I updated all
occurrences where `dispatch_async(dispatch_get_main_queue(), ..` was used and
use it now only for direct UI work.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]