Bug 16137 - Camera.Parameters.SupportedPreviewFpsRange problem
Summary: Camera.Parameters.SupportedPreviewFpsRange problem
Status: VERIFIED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: BCL Class Libraries ()
Version: 4.8.x
Hardware: PC Mac OS
: Normal normal
Target Milestone: 4.12.0 (KitKat)
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2013-11-12 03:41 UTC by Alex
Modified: 2014-02-21 10:10 UTC (History)
5 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Test case for the SupportedPreviewFpsRange problem (12.39 KB, application/zip)
2013-11-13 02:58 UTC, Alex
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
VERIFIED FIXED

Description Alex 2013-11-12 03:41:41 UTC
Hi all,

this property should return an IList<int[]>. Consider the following simplified code:

// mycamera is supposed to be an open camera object.
…
var params = mycamera.GetParameters(); // Get parameters, runs ok.
var test = params.SupportedPreviewFpsRange; // Runs ok, the Count property is 2 in my case.
var item = test[0]; // Generates InvalidCastException!!!
…

What is going on here? How can the third line generate an InvalidCastException? I think there must be a bug…

Thanks for you help.

Alex
Comment 1 Jonathan Pryor 2013-11-12 10:20:59 UTC
Can you provide the full logcat output (full stack trace), and/or a sample program which exhibits the exception? Camera.Parameters.SupportedPreviewFpsRange already is an IList<int[]>:

http://androidapi.xamarin.com/?link=P%3aAndroid.Hardware.Camera%2bParameters.SupportedPreviewFpsRange
Comment 2 Alex 2013-11-13 02:57:05 UTC
Hi Jonathan,

yes, I know it is an IList<int[]>. The problem is that the property value can't be accessed because of some cast exception. I have created a small program to exhibit the problem, I modified the Hello World app, so please click on the Click Me button :).

NOTE that you have to run it on a *real* device with a back-facing camera or modify the code to use a front-facing one.

Thanks for looking into this.

Alex
Comment 3 Alex 2013-11-13 02:58:26 UTC
Created attachment 5414 [details]
Test case for the SupportedPreviewFpsRange problem
Comment 4 Alex 2013-11-20 08:07:44 UTC
Ok, this should be a piece of cake to reproduce, so can you confirm the bug? We would like to access the propery but there does not seem to be a way...

Thanks

Alex
Comment 5 Jonathan Pryor 2013-11-20 09:13:56 UTC
Yes, I'm able to repro, and even have a test case. Now to just actually fix the damn thing...

Regardless, an untested workaround came to mind. The error doesn't come from accessing the SupportedPreviewFpsRange property; the error comes from using the _indexer_ on the value returned.

Thus, the (untested) workaround: don't use the indexer.

    var _ranges = cameraparams.SupportedPreviewFpsRange;
    var ranges = _ranges.JavaCast<Java.Util.IList>();
    Java.Lang.Object first = ranges.Get (0);
    int[] values = (int[]) first;
Comment 6 Mohit Kheterpal 2013-11-20 10:58:46 UTC
Today we have checked this issue and able to reproduce this issue with following builds :


XS 4.2.1(build 1)
X.Android 4.10.01068

Hence we marking this issue as confirmed.
Comment 7 Jonathan Pryor 2013-11-20 16:06:02 UTC
Fixed in monodroid/40676db
Comment 8 Alex 2013-11-21 03:05:06 UTC
Thanks :)
Alex
Comment 9 narayanp 2013-12-16 01:08:24 UTC
I have checked this issue with following builds:

All Mac
X.S 4.2.2(build 2)
Mono 3.2.6
X.Android 4.11.0.208

Samsung S4 version 4.3

Using the attached sample we have clicked on 'Hello World Click Me' button, getting no exception.
Comment 10 Lucian POPESCU 2014-02-19 18:37:05 UTC
@Jonathan Pryor: 

var ranges = cameraparams.SupportedPreviewFpsRange;
Since "ranges" is an IList<int[]>, there is no JavaCast extension on it, so there is no way to bypass the indexer.
I have tried everything: foreach, for (i), ranges[index], nothing works.

I still have this issue, in the latest stable release, so I'm now upgrading to the latest beta, to see how that works out.

Device: HTC One running under Android 4.3 
Environment:

Microsoft Visual Studio Ultimate 2012
Version 11.0.61030.00 Update 4
Microsoft .NET Framework
Version 4.5.51641

Version installée : Ultimate

Xamarin.Android   4.10.02014 (4b53fbd0)
Visual Studio plugin to enable development for Xamarin.Android.

Xamarin.iOS   1.10.39 (e0334707)
Visual Studio extension to enable development for Xamarin.iOS
Comment 11 Jonathan Pryor 2014-02-21 10:10:00 UTC
> Since "ranges" is an IList<int[]>, there is no JavaCast extension on it,

Cast to IJavaObject:

    var _ranges = cameraparams.SupportedPreviewFpsRange;
    var ranges  = ((IJavaObject) _ranges).JavaCast<Java.Util.IList>();

In actuality, it should be an Android.Runtime.JavaList<T>.