Closed abhinashpati closed 2 years ago
Same issue here - only on pre-version 6.0.0.2. Why is there no code pushed to repository for version 6.0.0.2? Only nuget package available.
Issue ocures also on sample android app if you use nuget package pre-6.0.0.2 from nuget.org.
Well I'm using 5.0.0.8 and i'm getting this crash. So i can confidently say it's an existing issue of the library and not specific to 6.0.02 pre.
Please provide a sample project for debugging, I didn't use Prism.
Here's a sample. I have replicated my project structure in this sample project as well. A Think to note that the issue is not easy to reproduce. It doesn't happens always. It happens out of nowhere. You might have to go through the flow multiple times in order to reproduce it.
https://github.com/abhinashpati/BarcodeSample
@petrdrabek If you have any better and easy way to reproduce this issue, please let @JimmyPun610 know. And as @petrdrabek mentioned that this issue also occurs in the sample, may be you can try to reproduce it with that.
@abhinashpati I'm experiencing diferent issue than you, sorry. It occures only with direct ML Kit using (v6+) I will desribe it with detail explanation and sample app soon.
Here's a sample. I have replicated my project structure in this sample project as well. A Think to note that the issue is not easy to reproduce. It doesn't happens always. It happens out of nowhere. You might have to go through the flow multiple times in order to reproduce it.
https://github.com/abhinashpati/BarcodeSample
@petrdrabek If you have any better and easy way to reproduce this issue, please let @JimmyPun610 know. And as @petrdrabek mentioned that this issue also occurs in the sample, may be you can try to reproduce it with that.
Hi,
I have just tested several times with my Pixel 3 and it looks nothing happen. But for investigating the issue, it should not be related to Prism but Android Camera. The error should be come from GoogleVisionBarCodeScanner.CameraPreview.SetOrientation
public void SetOrientation()
{
Android.Hardware.Camera camera = Methods.GetCamera(_cameraSource);
camera?.StopPreview();
switch (_windowManager.DefaultDisplay.Rotation)
{
case SurfaceOrientation.Rotation0:
camera?.SetDisplayOrientation(90);
break;
case SurfaceOrientation.Rotation90:
camera?.SetDisplayOrientation(0);
break;
case SurfaceOrientation.Rotation180:
camera?.SetDisplayOrientation(270);
break;
case SurfaceOrientation.Rotation270:
camera?.SetDisplayOrientation(180);
break;
}
camera?.StartPreview();
}
I would suggest you move to version 6+ which is switched to CameraX if it is possible. I have also uploaded the version 5.0.9 which added camera.StopPreview() and camera.StartPreview() and hopefully this could be fixed.
Unfortunately, V5.0.9 Doesn't fix it. I'll try to v6 and to see if CameraX fixes this bug.
I'm now getting another crash in V6.1. This is also happening randomly when I'm scanning barcode one after another.
2021-09-21 15:45:05.007 20095-20095/? A/DEBUG: Abort message: '[ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentException: Handle must be valid.
Parameter name: instance
at Java.Interop.JniEnvironment+InstanceMethods.CallVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo method) [0x00009] in <1959115d56f8444789986cf39185638c>:0
at Android.Runtime.JNIEnv.CallVoidMethod (System.IntPtr jobject, System.IntPtr jmethod) [0x0000e] in <cdf69449759145adbc699e96b2eb3764>:0
at AndroidX.Camera.Core.IImageProxyInvoker.Close () [0x00033] in <3513b64a9eca4ee5946ec0af08160ea2>:0
at GoogleVisionBarCodeScanner.Renderer.CameraViewRenderer+BarcodeAnalyzer.Analyze (AndroidX.Camera.Core.IImageProxy proxy) [0x0025b] in <e5a7d9dfaad84930875e6bed57b41ce1>:0
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_1 (System.Object state) [0x00000] in <98fdeeb5cad34f67b78b105df850970d>:0
at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context (System.Object state) [0x00007] in <98fdeeb5cad34f67b78b105df850970d>:0
at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00071] in <98fdeeb5cad34f67b78b105df850970d>:0
at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <98fdeeb5cad34f67b78b105df850970d>:0
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () [0x00021] in <98fdeeb5cad34f67b78b105df850970d>:0
at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00074] in <98fdeeb5cad34f67b78b105df850970d>:0
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () [0x00000] in <98fdeeb5cad34f67b78b105df850970d>:0
FATAL UNHANDLED EXCEPTION: System.ArgumentException: Handle must be valid.
Hi,
If the navigation flow of your app is the same as the sample you provided, which is
I suggest you pop the barcode scanning page (which include the camera view) before pushing the next page, which should be
FATAL UNHANDLED EXCEPTION: System.ArgumentException: Handle must be valid.
@abhinashpati That is exactly the error I was facing too. I already find solution. @JimmyPun610 I will do push request soon.
Hi @petrdrabek
Thank you for helping. Just pull the request and publish the new version 6.1.0.1-pre.
Hi @abhinashpati
Let see if the problem still exist with the 6.1.0.1-pre.
I can confirm the Crash FATAL UNHANDLED EXCEPTION: System.ArgumentException: Handle must be valid
is fixed but not the black screen issue :(
I'm also facing the black screen issue now. The camera turns extremely dark and don't recongnize anything on certain device.
Looks like it always happens on Android 11.
For black screen issue, it may related to RequestFPS paramenter. Do not set it and the device will take default. maybe related to #101
Stack Trace:
I have an app that uses Prism that has a TabbedPage. From the tabpage I'm opening a page with the BarcodeScanner and then from there I'm opening another page and from there I'm accessing MediaPicker.CaptureAsync to open Camera app for capturing a picture. When I'm returning to the page after clicking the picture, I'm getting this crash