dimonovdd / Xamarin.MediaGallery

This plugin is designed to picking and save images and video files from native gallery of Android and iOS devices and capture photos
MIT License
149 stars 18 forks source link

Unable to pick photos from Gallery on iOS simulator #92

Closed joeykang closed 2 years ago

joeykang commented 2 years ago

Description

I'm able to pick photos from Gallery when running on iOS simulator.

Actual Behavior

OpenReadAsync() throws an exception like below.

Error Domain=NSItemProviderErrorDomain Code=-1000 "Cannot load representation of type public.jpeg" UserInfo={NSLocalizedDescription=Cannot load representation of type public.jpeg, NSUnderlyingError=0x600002006a90 {Error Domain=NSCocoaErrorDomain Code=256 "The file “version=1&uuid=B84E8479-475C-4727-A4A4-B77AA9980897&mode=compatible.jpeg” couldn’t be opened." UserInfo={NSURL=file:///Users/joey/Library/Developer/CoreSimulator/Devices/D004FFB9-AEC8-46F5-BDCE-67F4392FF633/data/Containers/Shared/AppGroup/40F09F17-AF44-4239-A0B8-B26FC04C9BD9/File%20Provider%20Storage/photospicker/version=1&uuid=B84E8479-475C-4727-A4A4-B77AA9980897&mode=compatible.jpeg, NSFilePath=/Users/joey/Library/Developer/CoreSimulator/Devices/D004FFB9-AEC8-46F5-BDCE-67F4392FF633/data/Containers/Shared/AppGroup/40F09F17-AF44-4239-A0B8-B26FC04C9BD9/File Provider Storage/photospicker/version=1&uuid=B84E8479-475C-4727-A4A4-B77AA9980897&mode=compatible.jpeg, NSUnderlyingError=0x60000207f8a0 {Error Domain=NSOSStatusErrorDomain Code=-10817 "(null)"}}}}

Expected behavior

Stream should be returned with OpenReadAsync()

Steps to reproduce the behavior

  1. await MediaGallery.PickAsync()
  2. OpenReadAsync()

Screenshots or Videos

Reproduction Link

Configuration

dimonovdd commented 2 years ago

https://github.com/dimonovdd/Xamarin.MediaGallery/discussions/56

joeykang commented 2 years ago

The suggestion in #56 did not work on my end. Even if I pick a photo downloaded with Safari on simulator it returns the same exception. Wonder if this could be a simulator issue running on M1 Mac.

dimonovdd commented 2 years ago

https://stackoverflow.com/questions/67672550/error-domain-nsitemprovidererrordomain-code-1000-cannot-load-representation-of

dimonovdd commented 2 years ago

This issue is on Apple's side. We won't be able to solve it. Try writing to Apple

nicjay commented 2 years ago

I know this is closed, but thought it was worth mentioning the Essentials MediaPicker version of OpenReadAsync() does work without issue on the simulator. I don't know yet how the implementations differ, but I also wasn't able to find any workaround to avoid this crash with MediaGallery, even emptying the gallery and downloading fresh images with Safari. I cannot use a real device to test, so the Essentials verson works for now.

dimonovdd commented 2 years ago

@nicjay hi. Sorry, I haven't seen your messages MediaGallery uses new PHPicker, Essentials uses outdated UIImagePicker.

Do you get the same error as in the description?

nicjay commented 2 years ago

@dimonovdd Yes, identical error.

dimonovdd commented 2 years ago

You can check in google: this error is really on apple's side

eddieyanez commented 1 year ago

I have the same problem on the latest version of Xcode and the iOS simulator. Has anyone found a workaround since then by any chance?

dimonovdd commented 1 year ago

@eddieyanez Hi. Apparently apple still hasn't fixed it

https://developer.apple.com/forums/thread/658135

eddieyanez commented 1 year ago

@eddieyanez Hi. Apparently apple still hasn't fixed it

https://developer.apple.com/forums/thread/658135

That really sucks! Do you happen to know if the outdated UIImagePicker allows multiple image selection?

dimonovdd commented 1 year ago

UIImagePicker allows multiple image selection?

No

dimonovdd commented 1 year ago

There is a workaround:

You can save any image from Safari on simulator. The Picker will work good with such images

eddieyanez commented 1 year ago

I've actually tried it and it didn't work for me. I still introduced the nugget into the codebase, but couldn't get past it on Android, therefore I removed the code in the end. Happy to give it another go and have a look if you find it would be useful?