apache / apache/cordova-plugin-camera
iOS: getPicture returns error(null) when specifying PNG an FILE_URI options
- Dominant language
- Objective-C
- Stars
- 976
- Forks
- 1.6k
- PR merge metrics
- No merged PRs in 30d
Description
# 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`
```ts
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
cordova-plugin-camera@6.0.0
## Checklist
- [x] I searched for existing GitHub issues
- [x] I updated all Cordova tooling to most recent version
- [x] 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?
Contributor guide
Research direction
Inspect src/ios/CDVCamera.m around lines 380-382 and 591-601, then reproduce getPicture on a real iOS device with PNG and FILE_URI options. Confirm that the PNG path returns a valid file URL instead of invoking the error callback with a null message.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- objective-c
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100