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

Scanner not working sometimes #99

Open
VictorKochetkov opened this issue Dec 30, 2021 · 6 comments
Open

Scanner not working sometimes #99

VictorKochetkov opened this issue Dec 30, 2021 · 6 comments
Labels
bug Something isn't working

Comments

@VictorKochetkov
Copy link
Contributor

VictorKochetkov commented Dec 30, 2021

I've faced with some strange scanner behavior on Android.

On some devices scanner not working (not scanning) at first page opening. I have to close page and open it again. After that scanner works correctly.

May be some "internal" things not ready on first try?
For example there https://github.com/JimmyPun610/BarcodeScanner.XF/blob/dd8c0d099b4c155a9aefd2accb92afe28affcf51/GoogleVisionBarCodeScanner/Android/Renderer/CameraViewRenderer.cs#L84

@vladPanasiuk
Copy link

I have the same problem. In Debug mode, this is rare, but in Release it occurs every time

@JimmyPun610 JimmyPun610 added the bug Something isn't working label Jun 9, 2022
@JimmyPun610
Copy link
Owner

maybe related to #105

@istanko
Copy link

istanko commented Jul 5, 2022

Hi,

In my case this is happening when proxy?.Close(); in SafeCloseImageProxy method in Android CameraViewRenderer.cs line 410 raise the ArgumentException.

private void SafeCloseImageProxy(IImageProxy proxy)
{
	try
	{
		proxy?.Close();
   	}
   	catch (ObjectDisposedException) { }
   	catch (ArgumentException)
   	{
      	//Ignore argument exception, it will be thrown if BarcodeAnalyzer get disposed during 		processing
    	}
}

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 /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/Java.Interop/JniEnvironment.g.cs:11853
at Android.Runtime.JNIEnv.CallVoidMethod (System.IntPtr jobject, System.IntPtr jmethod) [0x00000] in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNIEnv.g.cs:258
at AndroidX.Camera.Core.IImageProxyInvoker.Close () [0x0002d] in D:\a\1\s\generated\androidx.camera.camera-core\obj\Release\monoandroid9.0\generated\src\AndroidX.Camera.Core.IImageProxy.cs:467
at BarcodeScanner.Mobile.XamarinForms.Renderer.CameraViewRenderer+BarcodeAnalyzer.SafeCloseImageProxy (AndroidX.Camera.Core.IImageProxy proxy, BarcodeScanner.Mobile.XamarinForms.Renderer.CameraViewRenderer _renderer) [0x00002]

After this exception scanning stops.

I've managed to add quick and dirty workaround with calling:

try
{
    proxy?.Close();
}
catch (ObjectDisposedException) { }
catch (ArgumentException)
{
    //Ignore argument exception, it will be thrown if BarcodeAnalyzer get disposed during processing
    Device.BeginInvokeOnMainThread(() =>
    {
        _renderer.CameraCallback();
    });
}

@mantasdaskev
Copy link

Hi, wanted to now if there is any progress made with this issue?

@MridulMalviya
Copy link

I am also facing same issue for Android Kyocera dual force pro device.
Sometimes it is working if we move application from background state to foreground state.

@Serverator
Copy link

Serverator commented May 25, 2023

I have the same issue, using 6.3.0.29 in MAUI
In debug it works all the time, but when I switch to release there is like 1/5 chance that scanner won't send any OnDetected events when opened.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants