-
Notifications
You must be signed in to change notification settings - Fork 556
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Camera plugin on iOS throws error when selected photo is not available locally (iCloud) #1807
Comments
This issue needs more information before it can be addressed. Please see the Contributing Guide for how to create a Sample App. Thanks! |
added reproduction steps in detail |
Hi, did you find a solution? The problem is if you have a photo on iCloud and not locally, the library cannot download it. |
Also experiencing this issue. |
This issue needs more information before it can be addressed. Please see the Contributing Guide for how to create a Sample App. Thanks! |
I tried to upgrade to capacitor 5 with no success, the problem remains.
|
Have been seeing the same issue. Seems to be coming up a lot given a lot of people with new devices (whose photos are almost entirely on iCloud) |
The very very strange thing is that I have other several apps in witch this bug doesn't happen! With the same phone and with the same photos. 🤷♂️ |
Are those apps built over capacitor as well? |
Yes, in Capacitor (4 and 5) as well. |
I am having the same issue. It is 100% reproducible on our end when attempting to select photos from a Shared Album. The album must have been shared by someone else. Shared Albums owned by the user work fine. |
Hi all, we have been experiencing the same issue with iOS 16/17 devices due to the images only being available on iCloud. Has there been an update on any potential fixes/workarounds? |
Hi, we are also experiencing this issue with users across iOS 16.4 onwards, and 17.0.1 onwards. This only seems to occur, from what we can tell, when a user selects a photo that is only stored on iCloud. Although we have had reports of users taking photos then having the same issue. I believe this could be because of the settings for storage. I would assume this is affecting all apps using capacitor with the camera plugin, who have a user base on ios. We tested replacing the camera plugin with the capawesome filepicker plugin which has a pickImages function and the issue exists there too. It looks like the exception is throw by capacitor core |
We also started experiencing this, especially with users who are on iOS 17.0.3. If an image fails to get selected, and then you try again 15-30 seconds later, it will often work the second time. If you're trying to reproduce this issue, you may need to take a fresh photo and then immediately try using it from the Gallery. It seems that attempting to use the photo causes it to get downloaded from iCloud, or some other mechanism that makes it available to Capacitor. In the CameraPlugin.swift code of the Capacitor Camera plugin, I attempted to adjust it to use the Photos framework's PHImageManager instead, but it didn't seem to have any effect (positive or negative). I'm not experienced with Swift so it's likely I didn't do something correctly, but I'll share this in case it helps generate some ideas.
This issue is also being reported on some React Native plugins, such as here. Perhaps something changed on Apple's side? |
Same issue here at my company, a lot of users have been reporting this issue and we reproduce it. Any temporary fixes? |
I think this will only get worse as more people upgrade their ios or device. From what I've seen on the react forums it seems to be something to do with HEIF. Someone had written a work around to convert these to jpeg. We did try implementing bits of it but have no experience with swift. I wonder if collectively we could write a temp fix whilst we wait for an official patch |
Same issue here, any temporary fix? This is a serious bug, it affects a lot of users. |
We are already migrating away from capacitor as a result of continued issues beyond this one since ios 17. Disappointing to see no engagement from the ionic team |
EDITED I just developed a temporary solution, basically it will always search for the images that are hosted on iCloud. In order to use this code, you will have to replace the "picker" function inside the file "node_modules/@capacitor/camera/ios/Plugin/CameraPlugin.swift" I sincerely hope that it can be useful to you.
|
What happens of the image is not on icloud or the user has icloud disabled? |
If the image is not on iCloud or if iCloud is disabled, PhotoKit (the framework you're using for handling images) will look in the local cache on the device for the image. When Therefore, in your code, you should handle these errors in the |
Thanks! I'll try asap. Do you know if the fix you provided, returns also exif? |
Yeah, it returns the same parameters as the original plugin. |
Mate it worked ❤️ I'll proceed with a donation! By the way, I noticed that also Android, has a similar issue with not-local photos. Do you know anything about that? |
Hi how are you? Thank you very much for the donation, I am very happy that it worked for you. Regarding what you mentioned about Android, I have not seen any related reports, but if you continue experiencing this error, create an issue in this repository and I will try to resolve it with pleasure. |
Can we please get an update from the Capacitor team? This is a serious issue affecting every iOS user. This should not be tagged "needs reproduction" as reproduction instructions have been provided. You simply try to pick any iCloud photo not physically present on the device and the plugin fails. |
It's a very serious bug, i posted a temporary solution in the comments #1807 (comment), you can use it if you want, but we need an official one. |
Bug Report
Plugin(s)
@capacitor/camera
version 5.0.7 - I'm pretty sure it's on old versions as wellCapacitor Version
Platform(s)
iOS
Current Behavior
When I use
Camera.pickImages
orCamera.getPhoto
, and I select any image, that is not available locally on my iOS but saved on iCloud Photos andOptimized Storage
turned on, the plugin throws an errorError 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
OR
Other Technical Details
It seems that the
img.itemProvider.canLoadObject
returnsfalse
when the photo is not available locally.Additional Context
The text was updated successfully, but these errors were encountered: