You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cordova.apache.org by "Phil Snell (JIRA)" <ji...@apache.org> on 2012/08/08 20:35:20 UTC
[jira] [Created] (CB-1212) When camera is started, and then
cancelled with no photo, attempt to read exif data results in fatal error
Phil Snell created CB-1212:
------------------------------
Summary: When camera is started, and then cancelled with no photo, attempt to read exif data results in fatal error
Key: CB-1212
URL: https://issues.apache.org/jira/browse/CB-1212
Project: Apache Cordova
Issue Type: Bug
Components: Android
Affects Versions: 2.0.0
Environment: Dell Streak device using SDK version 7
Reporter: Phil Snell
Assignee: Joe Bowser
If you start the camera, it loads normally, and then when you click cancel right after that, it causes a fatal error. This is because it's trying to initialize the exif data, but no image exists. What ends up happening is an error when parseInt is called on null. Selected error messages:
E/AndroidRuntime(3206): Caused by: java.lang.NumberFormatException: unable to parse 'null' as integer
E/AndroidRuntime(3206): at org.apache.cordova.ExifHelper.getOrientation(ExifHelper.java:167)
E/AndroidRuntime(3206): at org.apache.cordova.CameraLauncher.onActivityResult(CameraLauncher.java:282)
I found a fix that works for me by editing CameraLauncher.onActivityResult. I moved the code that deals with exif to inside the conditional:
if (resultCode == Activity.RESULT_OK) {
because this is when you know there is an image available. Diff:
diff --git a/framework/src/org/apache/cordova/CameraLauncher.java b/framework/src/org/apache/cordova/CameraLauncher.java
index 6d05c64..48c5676 100755
--- a/framework/src/org/apache/cordova/CameraLauncher.java
+++ b/framework/src/org/apache/cordova/CameraLauncher.java
@@ -273,19 +273,22 @@ public class CameraLauncher extends Plugin implements MediaScannerConnectionClie
// If CAMERA
if (srcType == CAMERA) {
- // Create an ExifHelper to save the exif data that is lost during compression
- ExifHelper exif = new ExifHelper();
- try {
- if (this.encodingType == JPEG) {
- exif.createInFile(DirectoryManager.getTempDirectoryPath(this.cordova.getActivity()) + "/.Pic.jpg");
- exif.readExifData();
- rotate = exif.getOrientation();
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
+
// If image available
if (resultCode == Activity.RESULT_OK) {
+
+ // Create an ExifHelper to save the exif data that is lost during compression
+ ExifHelper exif = new ExifHelper();
+ try {
+ if (this.encodingType == JPEG) {
+ exif.createInFile(DirectoryManager.getTempDirectoryPath(this.cordova.getActivity()) + "/.Pic.jpg");
+ exif.readExifData();
+ rotate = exif.getOrientation();
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
try {
Bitmap bitmap = null;
Uri uri = null;
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Resolved] (CB-1212) When camera is started, and then
cancelled with no photo, attempt to read exif data results in fatal error
Posted by "Simon MacDonald (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CB-1212?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Simon MacDonald resolved CB-1212.
---------------------------------
Resolution: Fixed
Fix Version/s: 2.1.0
I could not reproduce this issue on my devices. It fails at the line before where the image file is not found which is handled correctly by the catch block. Although your suggestion to move the code into RESULT_OK makes good sense so I've gone ahead and made the change.
> When camera is started, and then cancelled with no photo, attempt to read exif data results in fatal error
> ----------------------------------------------------------------------------------------------------------
>
> Key: CB-1212
> URL: https://issues.apache.org/jira/browse/CB-1212
> Project: Apache Cordova
> Issue Type: Bug
> Components: Android
> Affects Versions: 2.0.0
> Environment: Dell Streak device using SDK version 7
> Reporter: Phil Snell
> Assignee: Simon MacDonald
> Fix For: 2.1.0
>
>
> If you start the camera, it loads normally, and then when you click cancel right after that, it causes a fatal error. This is because it's trying to initialize the exif data, but no image exists. What ends up happening is an error when parseInt is called on null. Selected error messages:
> E/AndroidRuntime(3206): Caused by: java.lang.NumberFormatException: unable to parse 'null' as integer
> E/AndroidRuntime(3206): at org.apache.cordova.ExifHelper.getOrientation(ExifHelper.java:167)
> E/AndroidRuntime(3206): at org.apache.cordova.CameraLauncher.onActivityResult(CameraLauncher.java:282)
> I found a fix that works for me by editing CameraLauncher.onActivityResult. I moved the code that deals with exif to inside the conditional:
> if (resultCode == Activity.RESULT_OK) {
> because this is when you know there is an image available. Diff:
> diff --git a/framework/src/org/apache/cordova/CameraLauncher.java b/framework/src/org/apache/cordova/CameraLauncher.java
> index 6d05c64..48c5676 100755
> --- a/framework/src/org/apache/cordova/CameraLauncher.java
> +++ b/framework/src/org/apache/cordova/CameraLauncher.java
> @@ -273,19 +273,22 @@ public class CameraLauncher extends Plugin implements MediaScannerConnectionClie
>
> // If CAMERA
> if (srcType == CAMERA) {
> - // Create an ExifHelper to save the exif data that is lost during compression
> - ExifHelper exif = new ExifHelper();
> - try {
> - if (this.encodingType == JPEG) {
> - exif.createInFile(DirectoryManager.getTempDirectoryPath(this.cordova.getActivity()) + "/.Pic.jpg");
> - exif.readExifData();
> - rotate = exif.getOrientation();
> - }
> - } catch (IOException e) {
> - e.printStackTrace();
> - }
> +
> // If image available
> if (resultCode == Activity.RESULT_OK) {
> +
> + // Create an ExifHelper to save the exif data that is lost during compression
> + ExifHelper exif = new ExifHelper();
> + try {
> + if (this.encodingType == JPEG) {
> + exif.createInFile(DirectoryManager.getTempDirectoryPath(this.cordova.getActivity()) + "/.Pic.jpg");
> + exif.readExifData();
> + rotate = exif.getOrientation();
> + }
> + } catch (IOException e) {
> + e.printStackTrace();
> + }
> +
> try {
> Bitmap bitmap = null;
> Uri uri = null;
>
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Assigned] (CB-1212) When camera is started, and then
cancelled with no photo, attempt to read exif data results in fatal error
Posted by "Simon MacDonald (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CB-1212?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Simon MacDonald reassigned CB-1212:
-----------------------------------
Assignee: Simon MacDonald (was: Joe Bowser)
> When camera is started, and then cancelled with no photo, attempt to read exif data results in fatal error
> ----------------------------------------------------------------------------------------------------------
>
> Key: CB-1212
> URL: https://issues.apache.org/jira/browse/CB-1212
> Project: Apache Cordova
> Issue Type: Bug
> Components: Android
> Affects Versions: 2.0.0
> Environment: Dell Streak device using SDK version 7
> Reporter: Phil Snell
> Assignee: Simon MacDonald
>
> If you start the camera, it loads normally, and then when you click cancel right after that, it causes a fatal error. This is because it's trying to initialize the exif data, but no image exists. What ends up happening is an error when parseInt is called on null. Selected error messages:
> E/AndroidRuntime(3206): Caused by: java.lang.NumberFormatException: unable to parse 'null' as integer
> E/AndroidRuntime(3206): at org.apache.cordova.ExifHelper.getOrientation(ExifHelper.java:167)
> E/AndroidRuntime(3206): at org.apache.cordova.CameraLauncher.onActivityResult(CameraLauncher.java:282)
> I found a fix that works for me by editing CameraLauncher.onActivityResult. I moved the code that deals with exif to inside the conditional:
> if (resultCode == Activity.RESULT_OK) {
> because this is when you know there is an image available. Diff:
> diff --git a/framework/src/org/apache/cordova/CameraLauncher.java b/framework/src/org/apache/cordova/CameraLauncher.java
> index 6d05c64..48c5676 100755
> --- a/framework/src/org/apache/cordova/CameraLauncher.java
> +++ b/framework/src/org/apache/cordova/CameraLauncher.java
> @@ -273,19 +273,22 @@ public class CameraLauncher extends Plugin implements MediaScannerConnectionClie
>
> // If CAMERA
> if (srcType == CAMERA) {
> - // Create an ExifHelper to save the exif data that is lost during compression
> - ExifHelper exif = new ExifHelper();
> - try {
> - if (this.encodingType == JPEG) {
> - exif.createInFile(DirectoryManager.getTempDirectoryPath(this.cordova.getActivity()) + "/.Pic.jpg");
> - exif.readExifData();
> - rotate = exif.getOrientation();
> - }
> - } catch (IOException e) {
> - e.printStackTrace();
> - }
> +
> // If image available
> if (resultCode == Activity.RESULT_OK) {
> +
> + // Create an ExifHelper to save the exif data that is lost during compression
> + ExifHelper exif = new ExifHelper();
> + try {
> + if (this.encodingType == JPEG) {
> + exif.createInFile(DirectoryManager.getTempDirectoryPath(this.cordova.getActivity()) + "/.Pic.jpg");
> + exif.readExifData();
> + rotate = exif.getOrientation();
> + }
> + } catch (IOException e) {
> + e.printStackTrace();
> + }
> +
> try {
> Bitmap bitmap = null;
> Uri uri = null;
>
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira