ivpusic / react-native-image-crop-picker

iOS/Android image picker with support for camera, video, configurable compression, multiple images and cropping
MIT License
6.11k stars 1.56k forks source link

iOS: Failed to load image data for asset #518

Open Ilario17 opened 6 years ago

Ilario17 commented 6 years ago

Version

Tell us which versions you are using:

Platform

Actual behaviour

When open camera on iOS Device (iOS 10.3.2) and select a photo the app stuck on "Processing assets..." with this log:

Failed to load image data for asset <PHAsset: 0x18155870> F5EA5C74-C9BD-4420-92E5-985357FECEBC/L0/001 mediaType=1/0, sourceType=1, (2448x3264), creationDate=2017-10-05 16:28:49 +0000, location=0, hidden=0, favorite=0 with format 9999

No issue on iOS Simulator

ivpusic commented 6 years ago

do you have some time to debug this? This is specific to image you are selecting and maybe your device.

Ilario17 commented 6 years ago

Mmm I don't think its specific for the image I selected. This happen to all image in my library and also video. Sorry I don't have the time to debug this.. do you have any idea what it may be?

ivpusic commented 6 years ago

hmm, can you try example project?

Ilario17 commented 6 years ago

I can't run the Example project because 'React/RCTBridgeModule.h' file not found.. :|

Ilario17 commented 6 years ago

If I run the app in release mode this issue there isn't.

ahmdx commented 6 years ago

I have faced this issue as well, but I found out it is probably caused by the photo being stored in the cloud instead of on the device itself. Is there a way to re-download the photo before using it?

victranit commented 6 years ago

I have a same issue with another framework. I know why!

When your native Photos library was configured at "Optimize Storage" mode (it mean your photos and videos are being saved in iCloud Server). You must try process downloading photos or videos from iCloud server first, then using them for what you want to do!

kodayashi commented 6 years ago

@trumsuhu - I hit this as well. How are you getting the device to download the image first from iCloud?

@ivpusic - If I select an image on the phone that isn't actually downloaded the "Processing assets..." screen never goes away, essentially causing the app to hang.

This is reproducible as long as you have images (or in my case videos) that aren't cached locally. On my phone, that's any videos more than a few weeks old. Any ideas?

victranit commented 6 years ago

@kodayashi @ivpusic First of all, in react-native, i have no experience, i don't know.

In Swift, you can use this function requestImageData(for:options:resultHandler:) in PHImageManager to Fetching Image Data from iCloud

By the way, in this case, I think, this issue must be fixed from inside framework by framework owner, don't implement outside. Add function to fetch Image Data from iCloud with Completion Handler before return data for user (who using this framework)

(Please explain it for me if my idea is a bad one) Thanks in advance!

Kirow commented 5 years ago

need to set configured options to make it work with iCloud

let options = PHImageRequestOptions()
options.isNetworkAccessAllowed = true //(false by default)
PHImageManager.default().requestImageData(for: asset, options: options
        ) { ... }
HugoAntares commented 5 years ago

@Kirow where do we insert this code in NativeScript ? Or is that plugin's code ?

ninjz commented 1 year ago

Seems to still be failing for me for images stored on iCloud. I'm on version 0.39.0