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

RuntimeException on getPreviewFpsRange #75

Closed
503e2 opened this issue Mar 1, 2014 · 1 comment
Closed

RuntimeException on getPreviewFpsRange #75

503e2 opened this issue Mar 1, 2014 · 1 comment

Comments

@503e2
Copy link

503e2 commented Mar 1, 2014

Hi,

on my android phone (Motorola Milestone 2 with CM10.2) I was getting crashes shortly after the barcode scanner started with the latest version from the Google Play.
I debugged the code a little bit and found the following:
getPreviewFpsRange in android/src/com/google/zxing/client/android/camera/CameraConfigurationManager.java (line 253) throws a RuntimeException because the camera parameters have preview-fps-range=10000, 30000 and so parseInt(" 30000") fails.
I don't know where this bug comes from (CM, Android, the guy who ported CM to the MS2) but I found out that the ROM I'm using is not the only ROM for the MS2 with this bug.
Although that exception is catched later on, the app force closes because of an IndexOutOfBoundsException in core/src/com/google/zxing/PlanarYUVLuminanceSource.java (line 73, offset > yuvData.length).
Long story short - the following patch fixes my problem:

--- CameraConfigurationManager1.java    2014-03-01 16:28:36.483774358 +0100
+++ CameraConfigurationManager2.java    2014-03-01 16:08:14.543834888 +0100
@@ -250,7 +250,11 @@
         Log.i(TAG, "No suitable FPS range?");
       } else {
         int[] currentFpsRange = new int[2];
-        parameters.getPreviewFpsRange(currentFpsRange);
+        try {
+           parameters.getPreviewFpsRange(currentFpsRange);
+        } catch (RuntimeException e) {
+           Log.i(TAG, "Error getting current PreviewFpsRange");
+        }
         if (!Arrays.equals(currentFpsRange, minimumSuitableFpsRange)) {
           Log.i(TAG, "Setting FPS range to " + Arrays.toString(minimumSuitableFpsRange));
           parameters.setPreviewFpsRange(minimumSuitableFpsRange[Camera.Parameters.PREVIEW_FPS_MIN_INDEX],

I don't know if other devices are affected but I would really appreciate it if this patch could be incorporated in your releases so I don't have to build my own :)

@srowen
Copy link
Contributor

srowen commented Mar 1, 2014

There is no parseInt here -- the Android API returns int[] so I assume this is a bug in CM and/or the config, yes. You can definitely patch and build it as you say, and I think that's best. This isn't necessary it seems for a mainstream Android device without this bug.

@srowen srowen closed this as completed Mar 1, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants