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

iOS: getPicture returns error(null) when specifying PNG an FILE_URI options #832

Open
3 tasks done
dmitry-salnikov opened this issue May 4, 2023 · 2 comments
Open
3 tasks done

Comments

@dmitry-salnikov
Copy link

Bug Report

Problem

What is expected to happen?

getPicture should return valid file url.

What does actually happen?

getPicture calls error callback with no error message.

Information

All specified options for getPicture

quality: 100,
allowEdit: false,
targetWidth: 1000,
targetHeight: 1000,
sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
mediaType: Camera.MediaType.PICTURE,
encodingType: Camera.EncodingType.PNG,
destinationType: Camera.DestinationType.FILE_URI,

Command or Code

Just call getPicture with the specified options on iOS device.

Environment, Platform, Device

Use real iOS device.

Version information

iOS 16.3.1
[email protected]

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above

It seems there's a bug in this place:

https://github.com/apache/cordova-plugin-camera/blob/master/src/ios/CDVCamera.m#L591

Here self.data is nil then PNG option is picked. That happens, because self.data is not assigned above:

https://github.com/apache/cordova-plugin-camera/blob/master/src/ios/CDVCamera.m#L380-L382

So, call to [self.data mutableCopy] produces nil, and the next call obviously fails:

https://github.com/apache/cordova-plugin-camera/blob/master/src/ios/CDVCamera.m#L599-L601

It seems that this issue could be easily fixed by assigning self.data = data in the mentioned code:

https://github.com/apache/cordova-plugin-camera/blob/master/src/ios/CDVCamera.m#L380-L382

Could you please take a look?

@tanukki2929
Copy link

tanukki2929 commented May 24, 2023

I too get an error return when I specify PNG on iOS.
The error also occurs on iOS 14.1.
Does anyone have a corrected version of the commit?
encodingType: camera.EncodingType.PNG,.

JPEG is specified, it works fine

@oduverne
Copy link

oduverne commented Jan 6, 2024

The error happens for me with 7.0.0 but not with 6.0.0 tag

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants