capacitor-plugins
capacitor-plugins copied to clipboard
Camera plugin on iOS throws error when selected photo is not available locally (iCloud)
Bug Report
Plugin(s)
-
@capacitor/camera
version 5.0.7 - I'm pretty sure it's on old versions as well
Capacitor Version
💊 Capacitor Doctor 💊
Latest Dependencies:
@capacitor/cli: 5.4.1
@capacitor/core: 5.4.1
@capacitor/android: 5.4.1
@capacitor/ios: 5.4.1
Installed Dependencies:
@capacitor/cli: 5.4.0
@capacitor/core: 5.4.0
@capacitor/android: 5.4.0
@capacitor/ios: 5.4.0
[success] iOS looking great! 👌
[success] Android looking great! 👌
Platform(s)
iOS
Current Behavior
When I use Camera.pickImages
or Camera.getPhoto
, and I select any image, that is not available locally on my iOS but saved on iCloud Photos and Optimized Storage
turned on, the plugin throws an error Error loading image
.
Expected Behavior
I expect that regardless the file is available locally or not, it should be loaded fine.
Similar behaviour can be witnessed on iOS when you use <input type="file" accept="image/*" />
on Safari/Chrome to pick an image, it loads the image, showing spinner, if it's not available on the iPhone locally. The same does not happen when using Capacitor.
Code Reproduction
- Make sure you have iCloud on the profile
- Make sure you have Optimize Storage feature on for Photos
- From the code below, when the native PHPicker opens up, select a photo which is not available locally on device
Camera.pickImages({ quality: 90 })
OR
Camera.getPhoto({
allowEditing: false,
source: CameraSource.Photos,
resultType: CameraResultType.Uri,
})
Other Technical Details
It seems that the img.itemProvider.canLoadObject
returns false
when the photo is not available locally.