Skip to content
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

Image picking fails for live images on newer IOS. #835

Closed
Jamesfleming1 opened this issue Sep 27, 2021 · 18 comments
Closed

Image picking fails for live images on newer IOS. #835

Jamesfleming1 opened this issue Sep 27, 2021 · 18 comments
Assignees
Labels
bug Something isn't working iOS Issue applies to iOS platform

Comments

@Jamesfleming1
Copy link

Describe the bug
The image picker returns an error when trying to pick a live image on iOS .

Platform

  • [] iOS

Platform OS version

iOS 15.0

How are you picking?
Both single image and multi image from gallery fail when trying to pick a live image

Details to reproduce the issue
Try to pick a live image from the gallery.

Additional context
Running on actual iPhones via TestFlight on iOS.

@Jamesfleming1 Jamesfleming1 added the new issue An issue that hasn't yet been seen from the maintainer label Sep 27, 2021
@miguelpruivo
Copy link
Owner

Could you please post the stacktrace?

@miguelpruivo miguelpruivo added triage Further information is requested iOS Issue applies to iOS platform and removed new issue An issue that hasn't yet been seen from the maintainer labels Sep 27, 2021
@Jamesfleming1
Copy link
Author

Okay I will get on that, I guess I need to update my environment to run iOS 15 so that might take me a bit.

@brunoda6
Copy link

Hi,
I'm with the same problem here it is my stacktrace:

`***** Picker:<PHPickerViewController: 0x119516d00> didFinishPicking:(
)

  • -[FilePickerPlugin picker:didFinishPicking:] [Line 377]
    ***** FilePicker canceled
  • -[FilePickerPlugin picker:didFinishPicking:] [Line 382]
    ***** Picker:<PHPickerViewController: 0x104250240> didFinishPicking:(
    "<PHPickerResult: 0x28196bd60>"
    )
  • -[FilePickerPlugin picker:didFinishPicking:] [Line 377]
    [VERBOSE-2:ui_dart_state.cc(209)] Unhandled Exception: NoSuchMethodError: The method 'contains' was called on null.
    Receiver: null
    Tried calling: contains("image")
    #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:63:5)
    WIP clouding support; #1 isImage
    package:galerafm/global/global_functions.dart:156
    adds support for retrieving file paths from gallery and camera due to… #2 _ScreenAdicionarState.pickFiles
    package:galerafm/…/Adicionar/adicionar.dart:103
`

hope it helps ty :)

@miguelpruivo
Copy link
Owner

Thank you I’ll take a look!

@miguelpruivo miguelpruivo added bug Something isn't working and removed triage Further information is requested labels Sep 28, 2021
@miguelpruivo miguelpruivo self-assigned this Sep 28, 2021
@miguelpruivo
Copy link
Owner

Just tried it with a simulator and it works just fine with iOS 15 and live photos. What are the environment you are running on? And how are you picking?

@Jamesfleming1
Copy link
Author

Ios 15, I'm running on an iPhone 7, have reports of it on iPhone 12 mini and iPhone 12 all on iOS 15.

***** Picker:<PHPickerViewController: 0x1049def70> didFinishPicking:(
"<PHPickerResult: 0x2803a5e00>"
)

  • -[FilePickerPlugin picker:didFinishPicking:] [Line 381]

@Jamesfleming1
Copy link
Author

Are you able to try on an actual device?

@miguelpruivo
Copy link
Owner

Yes, just tried it on a device running iOS 15 and it works just fine. Could you please try sharing the picture you are trying to pick on? (you'll have to export it while keeping the original data so it doesn't converts to JPEG).

@Jamesfleming1
Copy link
Author

Jamesfleming1 commented Sep 29, 2021

Here is my call in code

FilePickerResult result = await FilePicker.platform
.pickFiles(
type: FileType.image,
allowMultiple: allowMultiple,
allowCompression: true)
.onError((error, stackTrace) {
print(error);
print(stackTrace);
return Future.error("PickingError");
});

And it gives me this issue
flutter: FileSystemException: Cannot open file, path = '/private/var/mobile/Containers/Data/Application/008FA7A9-1A0E-4930-8E34-D4D0420BC846/tmp/IMG_0020.pvt' (OS Error: Is a directory, errno = 21)

Hopefully that helps. I'm not sure how to actually send a Live Photo without converting it to live image. But it happens on every single live image so I really don't think its an issue with specific image

@shreymahendru
Copy link

shreymahendru commented Sep 29, 2021

Was investigating this today. This happens because .pvt is somewhat of a directory (Private Live Photo Bundle), and it contains 3 files. Check the image. image

The HEIC (the Image), .MOV (the video), and a metadata file.
So when you copy over the file the .pvt "file" is a directory, with 3 files in it.
@miguelpruivo This is where the URL is converted to a directory URL

I am working on a workaround for that, where I covert the HEIC image into a JPEG and return an updated file URL rather than a .pvt. But that might be beyond the scope of this plugin.

Here is a naive solution:
shreymahendru@e2e78e8#diff-b036603fcfe6200abcc45e1c42269d040727e675911d0d8b6c8d8dcc4505aea7

Or For retrieving the HEIC Image (which seems better since you don't lose the metadata):
shreymahendru@8c72eeb

@miguelpruivo
Copy link
Owner

In my testing, the files picked where actually the .pvt which are expected. It's up to the developer to then extract/handle those files. The picker only allows you to pick the files as they are.

The problem is that after picking, you may need to extract, like @shreymahendru. The only two approaches I can see here is leaving as it is, or converting it automatically to JPEG, for example, but then again, some devs may want to the live photo for their applications and this would prevent it.

@miguelpruivo
Copy link
Owner

As a purposed solution whenever the developer has allowCompression set to true I'll extract it to JPEG and if the dev wants the .pvt file, just need to set the allowCompression to false and the file is fetched as it is.

How does that sound to you?

@brunoda6
Copy link

for me it's perfect thanks

@davidfranquet
Copy link

As a purposed solution whenever the developer has allowCompression set to true I'll extract it to JPEG and if the dev wants the .pvt file, just need to set the allowCompression to false and the file is fetched as it is.

How does that sound to you?

looks great to me!

I saw this issue on ios 15. on ios 14 seems to work fine. Got lot of crashes on sentry during this week

Good catch guys!

@miguelpruivo
Copy link
Owner

Fixed and published with 4.1.3. I took advantage of some of the work that @shreymahendru made by converting Live Photos into static JPEG. Thank you! 🎉

@Jamesfleming1
Copy link
Author

Awesome!!! Thanks everyone!

@davidfranquet
Copy link

thanks!!!

@urusai88
Copy link

urusai88 commented Aug 1, 2023

Can you fix it to work without compression?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working iOS Issue applies to iOS platform
Projects
None yet
Development

No branches or pull requests

6 participants