Giter Club home page Giter Club logo

barcodescanning.native.maui's People

Contributors

afriscic avatar opterjohan-hallberg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

barcodescanning.native.maui's Issues

Command Binding gives Warning in Log

Hi

I have the following binding to my ViewModel for OnDetectionFinishedCommand:

<scanner:CameraView
    x:Name="MyCameraView"
    OnDetectionFinishedCommand="{Binding DetectionFinishedCommand}"
    AimMode="True"
    CaptureQuality="Highest" />

In the log I get the following warning

Microsoft.Maui.Controls.Xaml.Diagnostics.BindingDiagnostics: Warning: 'DetectionFinishedCommand' property not found on 'HML.Guide.App.Core.ViewModels.ScannerViewModel', target property: 'BarcodeScanning.CameraView.OnDetectionFinishedCommand'

Not an issue - I Apologize

I'm sorry, this is not an issue, but I can't find another place to contact the developer. One issue with the BarcodeScanner.Mobile.MAUI is that it seemed to have a dependency somewhere in the tree on bitcode. So apple rejects it and I had to do a lengthy workaround to remove the bitcode.
Also, the Android Simulator on an arm64 architecture on my Mac doesn't appear to work with some Google Vision ML kit stuff.

Are both of these issue addresses/gone in your version?

Thank you!!

Support for net8.x

First of all, thank you for a very nice plugin - the best QR scanner I have tried on Maui.

Would it possible to add "support" for .net8.0? It would be very handy when you have unit-test projects referencing your Maui project?

Code39: incomplete codes are being scanned

It seems that OnDetectionFinished is being fired prematurely (at least) for Code39 barcodes. I would have expected that start and stop markers would be considered and OnDetectionFinished would only fire if both have been detected, but this doesn't seem to be the case.

As an easy repro, just cover part of a Code39 code and scan it.

'APK already contains the item libbarhopper' warnings

After adding the library I get these warnings when building

0>libbarhopper_v3.so: Warning XA4301 : APK already contains the item lib/armeabi-v7a/libbarhopper_v3.so; ignoring.
0>libbarhopper_v3.so: Warning XA4301 : APK already contains the item lib/x86/libbarhopper_v3.so; ignoring.
0>libbarhopper_v3.so: Warning XA4301 : APK already contains the item lib/arm64-v8a/libbarhopper_v3.so; ignoring.
0>libbarhopper_v3.so: Warning XA4301 : APK already contains the item lib/x86_64/libbarhopper_v3.so; ignoring.

If there is a way to remove them other than <NoWarn>$(NoWarn);XA4301</NoWarn>?

IOS Camera View Response

On IOS, since version 1.4.0 the scan page with the camera preview stopped responding to the Torch, Pause, Camera and remaining buttons. The camera can scan a barcode or QR Code but it doesn't respond to any button or when navigating back, this can be simulated in your sample project.

The latest version that this worked was version 1.3.1

Use a red bar instead of the dot

It would be cool if we could use a red bar instead of the dot. A thin bar, which could be even better than the dot, filling the entire reading area, to help identify the beginning and end of the barcode reading

Problem with iPhone 7

After I updated BarcodeScanning.Native.Maui from 1.1.1 to 1.4.0, the scanner no longer works on an old iPhone 7 with iOS 15.8.2.
The camera itself still works, but the UI is frozen and no barcodes are recognized. None of the buttons work anymore. An iPhone 14 Pro and an iPad do work.
There have of course also been other updates to .Net Maui and Visual Studio. The cause may also lie there.
What could be the cause of this?
Thanks in advance.

Memory Leak in CameraView (on iOS)

Hi afriscic

Many thanks for your work on this project lately.

Unfortunately, since version 1.4.0 the CameraView started to leak again.
I.e. the page containing a CameraView never gets garbage collected anymore.

        <scanner:CameraView
            x:Name="MyCameraView"
            OnDetectionFinished="MyCameraView_OnOnDetectionFinished"
            AimMode="True"
            CaptureQuality="Highest" />

I have a sample project that demonstrates that problem:
https://github.com/marco-skizza/BarcodeScanningNativeMauiLeak

Steps to Reproduce:

  • Disable Hot Reload in Visual Studio
  • Run the project
  • Click Button and go back again multiple times
  • Observe that ~ScannerLeakPage() called never gets logged

This seems to be a problem with iOS as well as Android.

Missing Features

Hi,

i've tried to use your plugin with MVVM and think there are some improvements out there.

  • Timeout between Detections to prevent duplicate results. This would be useful if you use the result and parse it down in the Navigation. 500 ms ought to be enough as a default but a bindable property would be even better.
  • Tap to Focus doesn't work on a local iOS device
  • MVVM Bindings seem to be a bit broken. CameraFacing is ignored when bound and it's not easy to bind the command and still get the barcode. Perhaps it would be nicer to make the detection command bindable and return the detected barcodes as a separate property
  • Is there a way to donate to you? This plugin has been the best to scan so far!

MVVM Example:
RelayCommand to toggle CameraProperty

	public CameraPageViewModel1()
	{
		CameraFacing = CameraFacing.Front;
	}

        [ObservableProperty] private CameraFacing _cameraFacing;

	[RelayCommand]
	private void ToggleCamera()
	{
		CameraFacing = CameraFacing == CameraFacing.Front ? CameraFacing.Back : CameraFacing.Front;
	}

XAML:

	<AbsoluteLayout>
		<scanner:CameraView
			AbsoluteLayout.LayoutFlags="All"
			AbsoluteLayout.LayoutBounds="0,0,1,1"
			CaptureQuality="Highest"
			ForceInverted="False"
			TapToFocusEnabled="True"
			OnDetectionFinished="CameraView_OnDetectionFinished"
			CameraFacing="{Binding CameraFacing}"
			VibrationOnDetected="{Binding VibrateOnDetection}"
			BarcodeSymbologies="All"
			x:Name="Barcode"/>

		<GraphicsView
			AbsoluteLayout.LayoutFlags="All"
			AbsoluteLayout.LayoutBounds="0,0,1,1"
			x:Name="Graphics"
			InputTransparent="True"/>

		<Grid ColumnDefinitions="*, *" AbsoluteLayout.LayoutFlags="All" AbsoluteLayout.LayoutBounds="0,0,1,0.1">
			<Picker x:Name="Quality" Title="Quality" Grid.Column="2" BackgroundColor="Transparent"  WidthRequest="45" HeightRequest="45" SelectedIndexChanged="Quality_SelectedIndexChanged"/>

			<Button Text="C" Grid.Column="0" WidthRequest="50" HeightRequest="50" CornerRadius="25" Command="{Binding ToggleCameraCommand}"/>
			<Button Text="T" Grid.Column="1" WidthRequest="50" HeightRequest="50" CornerRadius="25" Clicked="TorchButton_Clicked"/>
		</Grid>
	</AbsoluteLayout>

The Constructor Camera facing front is being ignored.

What is expected inside a byte[] array for iOS Methods.ScanFromImage?

Hi.
Thanks a lot for your library, it looks like the best thing that can be used for scanning barcodes in MAUI among Open-Source projects.

To make it possible to quickly debug the code that is used after scanning within the emulator, I noticed the Methods.ScanFromImage method and tried to use it. I tried passing PNG and Jpeg bytes, but it wasn't recognized.
I came across this and it looks like a similar problem: https://stackoverflow.com/questions/58270939/how-to-create-image-programmatically-from-byte-array-in-ios

Perhaps it's worth adding explicit xml documentation for this or switching to CGImage.FromPNG? https://learn.microsoft.com/en-us/dotnet/api/coregraphics.cgimage.frompng?view=xamarin-ios-sdk-12

Shell crash regression after 1.0.2

There's a crash that's only happening after later changes. It happens when we have the component in a Shell tab, navigate away from that tab to another tab (in this instance containing a MapView, but same thing whichever one), navigate back to the original, then away again.

Thanks for the awesome lib btw!

System.NotSupportedException: Unable to activate instance of type BarcodeScanning.Platforms.Android.BarcodeView from native handle 0x73babd0045 (key_handle 0xeb0df9a).
 ---> System.MissingMethodException: No constructor found for BarcodeScanning.Platforms.Android.BarcodeView::.ctor(System.IntPtr, Android.Runtime.JniHandleOwnership)
 ---> Java.Interop.JavaLocationException: Exception of type 'Java.Interop.JavaLocationException' was thrown.
Java.Lang.Error: Exception of type 'Java.Lang.Error' was thrown.

  --- End of managed Java.Lang.Error stack trace ---
java.lang.Error: Java callstack:
	at crc6471f056c3c23d95e9.MainActivity.n_dispatchTouchEvent(Native Method)
	at crc6471f056c3c23d95e9.MainActivity.dispatchTouchEvent(MainActivity.java:106)
	at androidx.appcompat.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:70)
	at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:448)
	at android.view.View.dispatchPointerEvent(View.java:15919)
	at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:7021)
	at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:6815)
	at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:6229)
	at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:6286)
	at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:6252)
	at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:6417)
	at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:6260)
	at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:6474)
	at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:6233)
	at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:6286)
	at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:6252)
	at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:6260)
	at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:6233)
	at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:9211)
	at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:9162)
	at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:9131)
	at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:9337)
	at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:267)
	at android.os.MessageQueue.nativePollOnce(Native Method)
	at android.os.MessageQueue.next(MessageQueue.java:335)
	at android.os.Looper.loopOnce(Looper.java:162)
	at android.os.Looper.loop(Looper.java:294)
	at android.app.ActivityThread.main(ActivityThread.java:8177)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)

  --- End of managed Java.Lang.Error stack trace ---
java.lang.Error: Java callstack:
	at crc6471f056c3c23d95e9.MainActivity.n_dispatchTouchEvent(Native Method)
	at crc6471f056c3c23d95e9.MainActivity.dispatchTouchEvent(MainActivity.java:106)
	at androidx.appcompat.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:70)
	at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:448)
	at android.view.View.dispatchPointerEvent(View.java:15919)
	at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:7021)
	at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:6815)
	at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:6229)
	at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:6286)
	at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:6252)
	at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:6417)
	at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:6260)
	at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:6474)
	at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:6233)
	at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:6286)
	at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:6252)
	at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:6260)
	at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:6233)
	at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:9211)
	at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:9162)
	at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:9131)
	at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:9337)
	at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:267)
	at android.os.MessageQueue.nativePollOnce(Native Method)
	at android.os.MessageQueue.next(MessageQueue.java:335)
	at android.os.Looper.loopOnce(Looper.java:162)
	at android.os.Looper.loop(Looper.java:294)
	at android.app.ActivityThread.main(ActivityThread.java:8177)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)

   --- End of inner exception stack trace ---
   at Java.Interop.TypeManager.CreateProxy(Type type, IntPtr handle, JniHandleOwnership transfer) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Java.Interop/TypeManager.cs:line 349
   at Java.Interop.TypeManager.CreateInstance(IntPtr handle, JniHandleOwnership transfer, Type targetType) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Java.Interop/TypeManager.cs:line 311
   --- End of inner exception stack trace ---
   at Java.Interop.TypeManager.CreateInstance(IntPtr handle, JniHandleOwnership transfer, Type targetType) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Java.Interop/TypeManager.cs:line 318
   at Java.Lang.Object.GetObject(IntPtr handle, JniHandleOwnership transfer, Type type) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Java.Lang/Object.cs:line 303
   at Java.Lang.Object._GetObject[View](IntPtr handle, JniHandleOwnership transfer) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Java.Lang/Object.cs:line 289
   at Java.Lang.Object.GetObject[View](IntPtr handle, JniHandleOwnership transfer) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Java.Lang/Object.cs:line 281
   at Android.Views.ViewGroup.GetChildAt(Int32 index) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/net8.0/android-34/mcw/Android.Views.ViewGroup.cs:line 3135
   at Microsoft.Maui.Platform.ViewGroupExtensions.<GetChildrenOfType>d__0`1[[Android.Gms.Maps.MapView, Xamarin.GooglePlayServices.Maps, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext() in D:\a\_work\1\s\src\Core\src\Platform\Android\ViewGroupExtensions.cs:line 15
   at Microsoft.Maui.Platform.ViewGroupExtensions.<GetChildrenOfType>d__0`1[[Android.Gms.Maps.MapView, Xamarin.GooglePlayServices.Maps, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext() in D:\a\_work\1\s\src\Core\src\Platform\Android\ViewGroupExtensions.cs:line 24
   at Microsoft.Maui.Platform.ViewGroupExtensions.<GetChildrenOfType>d__0`1[[Android.Gms.Maps.MapView, Xamarin.GooglePlayServices.Maps, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext() in D:\a\_work\1\s\src\Core\src\Platform\Android\ViewGroupExtensions.cs:line 24
   at Microsoft.Maui.Platform.ViewGroupExtensions.<GetChildrenOfType>d__0`1[[Android.Gms.Maps.MapView, Xamarin.GooglePlayServices.Maps, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext() in D:\a\_work\1\s\src\Core\src\Platform\Android\ViewGroupExtensions.cs:line 24
   at Microsoft.Maui.Platform.ViewGroupExtensions.<GetChildrenOfType>d__0`1[[Android.Gms.Maps.MapView, Xamarin.GooglePlayServices.Maps, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext() in D:\a\_work\1\s\src\Core\src\Platform\Android\ViewGroupExtensions.cs:line 24
   at Microsoft.Maui.Platform.ViewGroupExtensions.<GetChildrenOfType>d__0`1[[Android.Gms.Maps.MapView, Xamarin.GooglePlayServices.Maps, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext() in D:\a\_work\1\s\src\Core\src\Platform\Android\ViewGroupExtensions.cs:line 24
   at Microsoft.Maui.Platform.ViewGroupExtensions.<GetChildrenOfType>d__0`1[[Android.Gms.Maps.MapView, Xamarin.GooglePlayServices.Maps, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext() in D:\a\_work\1\s\src\Core\src\Platform\Android\ViewGroupExtensions.cs:line 24
   at Microsoft.Maui.Platform.ViewGroupExtensions.<GetChildrenOfType>d__0`1[[Android.Gms.Maps.MapView, Xamarin.GooglePlayServices.Maps, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext() in D:\a\_work\1\s\src\Core\src\Platform\Android\ViewGroupExtensions.cs:line 24
   at Microsoft.Maui.Platform.ViewGroupExtensions.<GetChildrenOfType>d__0`1[[Android.Gms.Maps.MapView, Xamarin.GooglePlayServices.Maps, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext() in D:\a\_work\1\s\src\Core\src\Platform\Android\ViewGroupExtensions.cs:line 24
   at Microsoft.Maui.Platform.ViewGroupExtensions.<GetChildrenOfType>d__0`1[[Android.Gms.Maps.MapView, Xamarin.GooglePlayServices.Maps, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext() in D:\a\_work\1\s\src\Core\src\Platform\Android\ViewGroupExtensions.cs:line 24
   at Microsoft.Maui.Platform.ViewGroupExtensions.<GetChildrenOfType>d__0`1[[Android.Gms.Maps.MapView, Xamarin.GooglePlayServices.Maps, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext() in D:\a\_work\1\s\src\Core\src\Platform\Android\ViewGroupExtensions.cs:line 24
   at Microsoft.Maui.Platform.ViewGroupExtensions.<GetChildrenOfType>d__0`1[[Android.Gms.Maps.MapView, Xamarin.GooglePlayServices.Maps, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext() in D:\a\_work\1\s\src\Core\src\Platform\Android\ViewGroupExtensions.cs:line 24
   at Microsoft.Maui.Platform.ViewGroupExtensions.<GetChildrenOfType>d__0`1[[Android.Gms.Maps.MapView, Xamarin.GooglePlayServices.Maps, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext() in D:\a\_work\1\s\src\Core\src\Platform\Android\ViewGroupExtensions.cs:line 24
   at Microsoft.Maui.Platform.ViewGroupExtensions.<GetChildrenOfType>d__0`1[[Android.Gms.Maps.MapView, Xamarin.GooglePlayServices.Maps, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext() in D:\a\_work\1\s\src\Core\src\Platform\Android\ViewGroupExtensions.cs:line 24
   at Microsoft.Maui.Platform.ViewGroupExtensions.<GetChildrenOfType>d__0`1[[Android.Gms.Maps.MapView, Xamarin.GooglePlayServices.Maps, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext() in D:\a\_work\1\s\src\Core\src\Platform\Android\ViewGroupExtensions.cs:line 24
   at Microsoft.Maui.Platform.ViewGroupExtensions.<GetChildrenOfType>d__0`1[[Android.Gms.Maps.MapView, Xamarin.GooglePlayServices.Maps, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext() in D:\a\_work\1\s\src\Core\src\Platform\Android\ViewGroupExtensions.cs:line 24
   at Microsoft.Maui.Platform.ViewGroupExtensions.<GetChildrenOfType>d__0`1[[Android.Gms.Maps.MapView, Xamarin.GooglePlayServices.Maps, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext() in D:\a\_work\1\s\src\Core\src\Platform\Android\ViewGroupExtensions.cs:line 24
   at Microsoft.Maui.Platform.ViewGroupExtensions.<GetChildrenOfType>d__0`1[[Android.Gms.Maps.MapView, Xamarin.GooglePlayServices.Maps, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext() in D:\a\_work\1\s\src\Core\src\Platform\Android\ViewGroupExtensions.cs:line 24
   at Microsoft.Maui.Platform.ViewGroupExtensions.<GetChildrenOfType>d__0`1[[Android.Gms.Maps.MapView, Xamarin.GooglePlayServices.Maps, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext() in D:\a\_work\1\s\src\Core\src\Platform\Android\ViewGroupExtensions.cs:line 24
   at Microsoft.Maui.Platform.ViewGroupExtensions.<GetChildrenOfType>d__0`1[[Android.Gms.Maps.MapView, Xamarin.GooglePlayServices.Maps, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext() in D:\a\_work\1\s\src\Core\src\Platform\Android\ViewGroupExtensions.cs:line 24
   at Opter.Main.Mobile.Driver.Droid.MainActivity.DispatchTouchEvent(MotionEvent e) in /Users/tol/CODE2/OPTER/Main/Mobile/Driver/Opter.Main.Mobile.Driver/Platforms/Android/MainActivity.cs:line 310
   at Android.App.Activity.n_DispatchTouchEvent_Landroid_view_MotionEvent_(IntPtr jnienv, IntPtr native__this, IntPtr native_ev) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/net8.0/android-34/mcw/Android.App.Activity.cs:line 2049
   at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPL_Z(_JniMarshal_PPL_Z callback, IntPtr jnienv, IntPtr klazz, IntPtr p0) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:line 136

Scan Distance and Polling Interval

Hey Afriscic,

Happy new year!

We were able to use your package for a demo application. Wanted to ask about polling intervals and scan distance.

How can we increase the effective scan distance from the barcodes? While the scanning works remarkably at stand still and relatively well in motion(my last issue), we have to be really close to the barcodes to get a pickup. Wanted to ask you if there is a way to configure the effective distance, and if there is some parameter we could tweak(aside from resolution quality, we have that set to "Highest") so that it may read at further distances?

Also we often find that after a while the camera will stop scanning. In our particular use-case, we want to stop scanning after a number of scans rather than a time interval. The current workaround is a button to manually reset the camera, but I wanted to ask the chef himself if there is a configuration for the camera to work as a function of scans rather than time and how the polling interval plays a role in all this. Could we set it to always scan and manually turn off the scanning?

Looking forward to your response, and again great work on the package.

Exception when returning from parent page

If the control is placed in a secondary page, when you return to the main page an exception is thrown.

Step to reproduce:
Create a page with your control.
register it in di (optional)
builder.Services.AddSingleton();

From main page:
await Shell.Current.GoToAsync($"{nameof(YourPage}");

From your page
await Shell.Current.GoToAsync($"..");

Exception:
System.ObjectDisposedException: 'Cannot access a disposed object.
Object name: 'AndroidX.Camera.View.PreviewView'.'

MVVM: obtaining a result

Hello again,

how do I retrieve a scanned code from within OnDetectionFinishedCommand? There isn't any bindable BarcodeResult property.

Am I missing something?

Cheers,
Olaf

The application sometimes quits unexpectedly

The application sometimes quits unexpectedly without messages when scanning multiple EAN8 codes, if barcodes are scanned at an angle or are partially obscured by thin objects such as wires.

Last messages from output:

[me.scanmauitest] Explicit concurrent mark compact GC freed 23594(1205KB) AllocSpace objects, 0(0B) LOS objects, 49% free, 6627KB/12MB, paused 124us,1.180ms total 21.234ms
[OplusStatistics--] IllegalArgumentException:java.lang.IllegalArgumentException: Unknown URL content://com.oplus.statistics.provider/track_event
[native] F0000 00:00:1711725226.632530 28971 oned_decoder_client.cc:630] Check failed: recognition_options.HasBarcodeFormat(CODE_39)
[native] terminating.
[native] F0000 00:00:1711725226.632530 28971 oned_decoder_client.cc:630] Check failed: recognition_options.HasBarcodeFormat(CODE_39)
[native] terminating.
[libc] Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 28971 (pool-4-thread-3), pid 20585 (me.scanmauitest)

My device:
Realme GT Neo 5 RMX3709
Android 14

        <scanner:CameraView
                            OnDetectionFinished="CameraView_OnDetectionFinished"
                            CaptureQuality="High"
                            ForceInverted="False"
                            TapToFocusEnabled="True"
                            AimMode="False"
                            ViewfinderMode="True"
                            BarcodeSymbologies="Ean8"
                            x:Name="Barcode" />

.net 8

Hi,
Great work !
Did you plan to build nuget package for .net 8 ?
Thanks

Question: Running App on Windows with This Package

My app is going to be for iOS, Android, and Windows. It has many facets, not just the barcode scanner. How would I make it to where I can run the app in Windows with just this barcode feature disabled since it is not compatible?

After some time, the camera stops scanning.

After starting the camera, (10 - 60 seconds) it stops firing the DetectionFinished event until the page is closed and opened again. I have been unable to find a workaround.
No messages in output, but logcat shows this.

01-10 10:26:25.550 948 2095 E CamX : [ERROR][STATS_AWB] camxcawbmain.cpp:1852: AddDebugData Invalid debugData, return

01-10 10:26:25.563 948 2098 E CamX : [ERROR][STATS_AWB] camxcawbmain.cpp:1329: AWBGetParameter GetParam depth vendor Tag Start

01-10 10:26:25.563 948 2098 E CamX : [ERROR][STATS_AWB] camxcawbmain.cpp:1391: AWBGetParameter GetParam depth vendor Tag End, Tag Count : 0

01-10 10:26:25.591 1214 2732 I EDMNativeHelperService: isCameraEnabled

01-10 10:26:25.593 1214 2732 D EDMNativeHelper: isCameraEnabled

01-10 10:26:25.594 1214 2732 D EDMNativeHelper: checking for camera in EnterpriseDeviceManagerService

01-10 10:26:25.594 1214 2732 D EnterpriseDeviceManagerService: isCameraEnabledNative

01-10 10:26:25.594 1214 2732 D EnterpriseDeviceManagerService: checking for camera in restriction policy

01-10 10:26:25.594 1214 2732 D RestrictionPolicy: isCameraEnabled ret(true) userId(0) cxtInfo.mCallerUid(10761) cxtInfo.mContainerId(0)

01-10 10:26:25.609 948 2097 E CamX : [ERROR][STATS_AWB] camxcawbmain.cpp:1852: AddDebugData Invalid debugData, return

01-10 10:26:25.633 948 2096 E CamX : [ERROR][STATS_AWB] camxcawbmain.cpp:1329: AWBGetParameter GetParam depth vendor Tag Start

01-10 10:26:25.634 948 2096 E CamX : [ERROR][STATS_AWB] camxcawbmain.cpp:1391: AWBGetParameter GetParam depth vendor Tag End, Tag Count : 0

OnDetectionFinished Event Gets called immediately in ContentView

I have this in my xaml view

    <!-- CameraView centered in the middle of the screen -->
    <Frame Grid.Row="0" IsClippedToBounds="true" Padding="0" HorizontalOptions="Fill" VerticalOptions="Fill">
        <barcode:CameraView
            HorizontalOptions="Fill"
            VerticalOptions="Fill"
            x:Name="Barcode"
            CaptureQuality="High"
            ForceInverted="False"
            TapToFocusEnabled="True"
            BarcodeSymbologies="All"
            OnDetectionFinished="BarcodeDetected" />
        <!-- CaptureQuality="Highest" doesnt work in dotnet 8 android -->
    </Frame>

in the code behind, I put a breakpoint on my BarcodeDetected method, and it's called immediately when the content view is shown.
In fact, every time I continue, it gets called again immediately.

I am using the component in a ContentVIew that is getting swapped with another view via a shared, injected service.

Has anyone ran into the "OnDetectionFinished" getting called rapidly and immediately?
I got this to work as a workaround, but it's not ideal:

private void BarcodeDetected(object sender, OnDetectionFinishedEventArg e)
{
    if (e.BarcodeResults?.Any() ?? false)
    {
        Device.BeginInvokeOnMainThread(() =>
        {
            BarcodeScannedEvent?.Invoke(e.BarcodeResults.FirstOrDefault());
        });
    }
}

Scanner orientation on iOS with only Portrait orientation allowed

Hi afriscic

Thanks for this library. It looks very promising to me!

On iOS I have set the following in my Info.plist:

	<key>UISupportedInterfaceOrientations</key>
	<array>
		<string>UIInterfaceOrientationPortrait</string>
	</array>
	<key>UISupportedInterfaceOrientations~ipad</key>
	<array>
		<string>UIInterfaceOrientationPortrait</string>
	</array>

When I start the scanner with the device in landscape position, the orientation of the scanner is rotated.

CameraView is not currently being Garbage Collected (on iOS)

Hi

I have the following Xaml on my page:

        <scanner:CameraView
            x:Name="MyCameraView"
            OnDetectionFinished="MyCameraView_OnOnDetectionFinished"
            AimMode="True"
            CaptureQuality="Highest" />

The code behind code looks like this:

public partial class ScannerPage : ContentPage
{
    public ScannerPage()
    {
        InitializeComponent();
    }

    private void MyCameraView_OnOnDetectionFinished(object? sender, OnDetectionFinishedEventArg e)
    {
        var debug = 0;
    }

    protected override void OnAppearing()
    {
        base.OnAppearing();

        MyCameraView.CameraEnabled = true;
    }

    protected override void OnDisappearing()
    {
        base.OnDisappearing();

        MyCameraView.CameraEnabled = false;
    }

    protected override void OnHandlerChanging(HandlerChangingEventArgs args)
    {
        base.OnHandlerChanging(args);

        if (args.NewHandler != null)
        {
            return;
        }

        MyCameraView.Handler?.DisconnectHandler();
    }

    ~ScannerPage()
    {
        Debug.WriteLine("~ScannerPage() called");
    }
}

I put the control on a page I can navigate to.
When I navigate back, the Deconstructor ~ScannerPage() should be called eventually - but this is not the case.

P.S.: You can force the garbage collector on the page you're navigating from with:

            GC.Collect();
            GC.WaitForPendingFinalizers();

P.P.S.: I'm on MAUI .NET 8.

Thanks!

Android System.InvalidOperationException crash in CameraViewHandler.UpdateAnalyzer for 106 users (172 reports)

Thank you for creating this library! We recently switched to it with our transition to MAUI and it has met our needs very well!

However, since using it we have seen 172 reports of the following crash in CameraViewHandler.UpdateAnalyzer from 106 users:

System.InvalidOperationException: VirtualView cannot be null here
Microsoft.Maui.Handlers.ViewHandler`2[[BarcodeScanning.CameraView, BarcodeScanning.Native.Maui, Version=1.2.4.0, Culture=neutral, PublicKeyToken=null],[BarcodeScanning.BarcodeView, BarcodeScanning.Native.Maui, Version=1.2.4.0, Culture=neutral, PublicKeyToken=null]].get_VirtualView()
BarcodeScanning.CameraViewHandler.UpdateAnalyzer()
BarcodeScanning.CameraViewHandler.Start()
Java.Lang.Thread.RunnableImplementor.Run()
Java.Lang.IRunnableInvoker.n_Run(IntPtr jnienv, IntPtr native__this)
Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PP_V(_JniMarshal_PP_V callback, IntPtr jnienv, IntPtr klazz)

There is a check in CameraViewHandler.UpdateAnalyzer for whether VirtualView is null (&& VirtualView is not null) here:

if (_cameraController is not null && _cameraExecutor is not null && VirtualView is not null && _previewView is not null)

However, the ViewHandler<TVirtualView, TPlatformView>.VirtualView property throws InvalidOperationException if it is null:
https://github.com/dotnet/maui/blob/df5061e531656564942691ae70fbb157b6d791d3/src/Core/src/Handlers/View/ViewHandlerOfT.cs#L42

Luckily, there is also an implementation of IViewHandler.VirtualView in the class without that check that can be called instead:
https://github.com/afriscic/BarcodeScanning.Native.Maui/pull/39/files

Please let me know if you have any question or concerns about the pull request I have provided to address this crash!

Is .NET 7 supported?

Hello and thanks a lot for your library.
I want to ask if there is a chance to use it with .NET 7?

Thanks in advance!

iOS 12.5.7 - Requesting Camera permission crashes app

Running the scanner with .net8 and the latest dll the app is unable to request the camera permissions and throws this error:[AVCaptureSession startRunning] startRunning may not be called between calls to beginConfiguration and commitConfiguration.

It then crashes the app. Restarting and trying to access the camera again results in another error:
+[AVCaptureDevice defaultDeviceWithDeviceType:mediaType:position:] The deviceType cannot be nil

Details

Thread started: #14 **ObjCRuntime.ObjCException:** 'Objective-C exception thrown. Name: NSGenericException Reason: *** -[AVCaptureSession startRunning] startRunning may not be called between calls to beginConfiguration and commitConfiguration Native stack trace: 0 CoreFoundation 0x00000001ac72e198 + 252 1 libobjc.A.dylib 0x00000001ab9069f8 objc_exception_throw + 56 2 AVFoundation 0x00000001b2770e54 + 212 3 W3AppMaui 0x0000000100082044 xamarin_get_original_working_directory_path + 8604 4 W3AppMaui 0x00000001003ae20c AppleCryptoNative_X509ImportCollection + 2885204 5 W3AppMaui 0x00000001003acba8 AppleCryptoNative_X509ImportCollection + 2879472 6 W3AppMaui 0x00000001003a15b4 AppleCryptoNative_X509ImportCollection + 2832892 7 W3AppMaui 0x000000010039f180 AppleCryptoNative_X509ImportCollection + 2823624 8 W3AppMaui 0x000000010036de0c AppleCryptoNative_X509ImportCollection + 2622036 9 W3AppMaui 0x00000001003155d8 AppleCryptoNative_X509ImportCollection + 2259488 10 W3AppMaui 0x000000010031935c AppleCryptoNative_X509ImportCollection + 2275236 11 W3AppMaui 0x00000001003df944 AppleCryptoNative_X509ImportCollection + 3087756 12 W3AppMaui 0x000000010043a82c AppleCryptoNative_X509ImportCollection + 3460212 13 Foundation 0x00000001ad1b5690 + 336 14 CoreFoundation 0x00000001ac6bff1c + 24 15 CoreFoundation 0x00000001ac6bfe9c + 88 16 CoreFoundation 0x00000001ac6bf784 + 176 17 CoreFoundation 0x00000001ac6ba6c0 + 1004 18 CoreFoundation 0x00000001ac6b9fb4 CFRunLoopRunSpecific + 436 19 GraphicsServices 0x00000001ae8bc79c GSEventRunModal + 104 20 UIKitCore 0x00000001d8b82c38 UIApplicationMain + 212 21 W3AppMaui 0x00000001000545f4 xamarin_UIApplicationMain + 60 22 W3AppMaui 0x00000001003ae2a8 AppleCryptoNative_X509ImportCollection + 2885360 23 W3AppMaui 0x00000001003acba8 AppleCryptoNative_X509ImportCollection + 2879472 24 W3AppMaui 0x00000001003a15b4 AppleCryptoNative_X509ImportCollection + 2832892 25 W3AppMaui 0x000000010039f180 AppleCryptoNative_X509ImportCollection + 2823624 26 W3AppMaui 0x000000010036de0c AppleCryptoNative_X509ImportCollection + 2622036 27 W3AppMaui 0x00000001003155d8 AppleCryptoNative_X509ImportCollection + 2259488 28 W3AppMaui 0x000000010031b8d4 AppleCryptoNative_X509ImportCollection + 2284828 29 W3AppMaui 0x0000000100373404 AppleCryptoNative_X509ImportCollection + 2644044 30 W3AppMaui 0x0000000100080fb8 xamarin_get_original_working_directory_path + 4368 31 W3AppMaui 0x00000001003db970 AppleCryptoNative_X509ImportCollection + 3071416 32 libdyld.dylib 0x00000001ac17d8e0 + 4 '

Der Thread 0x8 hat mit Code 0 (0x0) geendet.
Der Thread 0x6 hat mit Code 0 (0x0) geendet.
Der Thread 0xd hat mit Code 0 (0x0) geendet.
Thread finished: #8
Thread finished: #6
Thread finished: #13
Thread started: #15
0x00000001ac6b9fb4 CFRunLoopRunSpecific + 436
19 GraphicsServices 0x00000001ae8bc79c GSEventRunModal + 104
20 UIKitCore 0x00000001d8b82c38 UIApplicationMain + 212
21 W3AppMaui 0x00000001000545f4 xamarin_UIApplicationMain + 60
22 W3AppMaui 0x00000001003ae2a8 AppleCryptoNative_X509ImportCollection + 2885360
23 W3AppMaui 0x00000001003acba8 AppleCryptoNative_X509ImportCollection + 2879472
24 W3AppMaui 0x00000001003a15b4 AppleCryptoNative_X509ImportCollection + 2832892
25 W3AppMaui 0x000000010039f180 AppleCryptoNative_X509ImportCollection + 2823624
26 W3AppMaui 0x000000010036de0c AppleCryptoNative_X509ImportCollection + 2622036
27 W3AppMaui 0x00000001003155d8 AppleCryptoNative_X509ImportCollection + 2259488
28 W3AppMaui 0x000000010
031b8d4 AppleCryptoNative_X509ImportCollection + 2284828
29 W3AppMaui 0x0000000100373404 AppleCryptoNative_X509ImportCollection + 2644044
30 W3AppMaui 0x0000000100080fb8 xamarin_get_original_working_directory_path + 4368
31 W3AppMaui 0x00000001003db970 AppleCryptoNative_X509ImportCollection + 3071416
32 libdyld.dylib 0x00000001ac17d8e0 + 4

at AVFoundation.AVCaptureSession.StartRunning() in /Users/builder/azdo/_work/1/s/xamarin-macios/src/build/dotnet/ios/generated-sources/AVFoundation/AVCaptureSession.g.cs:line 270
at BarcodeScanning.CameraViewHandler.Start()
at BarcodeScanning.CameraViewHandler.HandleCameraEnabled()
at BarcodeScanning.CameraViewHandler.<>c.<.cctor>b__27_4(CameraViewHandler handler, CameraView virtualView)
at Microsoft.Maui.PropertyMapper`2.<>c__DisplayClass5_0[[BarcodeScanning.CameraView, BarcodeScanning.Native.Maui, Version=1.2.3.0, Culture=neutral, PublicKe
1ac72e198 + 252
1 libobjc.A.dylib 0x00000001ab9069f8 objc_exception_throw + 56
2 AVFoundation 0x00000001b2770e54 + 212
3 W3AppMaui 0x0000000100082044 xamarin_get_original_working_directory_path + 8604
4 W3AppMaui 0x00000001003ae20c AppleCryptoNative_X509ImportCollection + 2885204
5 W3AppMaui 0x00000001003acba8 AppleCryptoNative_X509ImportCollection + 2879472
6 W3AppMaui 0x00000001003a15b4 AppleCryptoNative_X509ImportCollection + 2832892
7 W3AppMaui 0x000000010039f180 AppleCryptoNative_X509ImportCollection + 2823624
8 W3AppMaui 0x000000010036de0c AppleCryptoNative_X509ImportCollection + 2622036
9 W3AppMaui 0x00000001003155d8 AppleCryptoNative_X509ImportCollection + 2259488
10 W3AppMaui 0x000000010031935c AppleCryp
toNative_X509ImportCollection + 2275236
11 W3AppMaui 0x00000001003df944 AppleCryptoNative_X509ImportCollection + 3087756
12 W3AppMaui 0x000000010043a82c AppleCryptoNative_X509ImportCollection + 3460212
13 Foundation 0x00000001ad1b5690 + 336
14 CoreFoundation 0x00000001ac6bff1c + 24
15 CoreFoundation 0x00000001ac6bfe9c + 88
16 CoreFoundation 0x00000001ac6bf784 + 176
17 CoreFoundation 0x00000001ac6ba6c0 + 1004
18 CoreFoundation 0x00000001ac6b9fb4 CFRunLoopRunSpecific + 436
19 GraphicsServices 0x00000001ae8bc79c GSEventRunModal + 104
20 UIKitCore 0x00000001d8b82c38 UIApplicationMain + 212
21 W3AppMaui 0x00000001000545f4 xamarin_UIApplicationMain + 60
22 W3AppMaui
2024-01-22 13:22:27.880 W3AppMaui[320:13416]
Unhandled Exception:
ObjCRuntime.ObjCException: Objective-C exception thrown. Name: NSGenericException Reason: *** -[AVCaptureSession startRunning] startRunning may not be called between calls to beginConfiguration and commitConfiguration
Native stack trace:
0 CoreFoundation 0x00000001ac72e198 + 252
1 libobjc.A.dylib 0x00000001ab9069f8 objc_exception_throw + 56
2 AVFoundation 0x00000001b2770e54 + 212
3 W3AppMaui 0x0000000100082044 xamarin_get_original_working_directory_path + 8604
4 W3AppMaui 0x00000001003ae20c AppleCryptoNative_X509ImportCollection + 2885204
5 W3AppMaui 0x00000001003acba8 AppleCryptoNative_X509ImportCollection + 2879472
6 W3AppMaui 0x00000001003a15b4 AppleCryptoNative_X509ImportCollection + 2832892
7 W3AppMaui
0x000000010039f180 AppleCryptoNative_X509ImportCollection + 2823624
8 W3AppMaui 0x000000010036de0c AppleCryptoNative_X509ImportCollection + 2622036
9 W3AppMaui 0x00000001003155d8 AppleCryptoNative_X509ImportCollection + 2259488
10 W3AppMaui 0x000000010031935c AppleCryptoNative_X509ImportCollection + 2275236
11 W3AppMaui 0x00000001003df944 AppleCryptoNative_X509ImportCollection + 3087756
12 W3AppMaui 0x000000010043a82c AppleCryptoNative_X509ImportCollection + 3460212
13 Foundation 0x00000001ad1b5690 + 336
14 CoreFoundation 0x00000001ac6bff1c + 24
15 CoreFoundation 0x00000001ac6bfe9c + 88
16 CoreFoundation 0x00000001ac6bf784 + 176
17 CoreFoundation 0x00000001ac6ba6c0 + 1004
18 CoreFoundation
indableObject.SetValue(BindableProperty property, Object value)
at BarcodeScanning.CameraView.set_CameraEnabled(Boolean value)
at W3AppMaui.Views.BarcodeScanner.OnAppearing() in E:\sources\W3App\W3AppMaui\Views\BarCodeScanner.xaml.cs:line 29
at System.Threading.Tasks.Task.<>c.b__128_0(Object state)
at Foundation.NSAsyncSynchronizationContextDispatcher.Apply() in /Users/builder/azdo/_work/1/s/xamarin-macios/src/Foundation/NSAction.cs:line 176
at UIKit.UIApplication.UIApplicationMain(Int32 argc, String[] argv, IntPtr principalClassName, IntPtr delegateClassName) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 58
at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 94
at W3AppMaui.Program.Main(String[] args) in E:\sources\W3App\W3AppMaui\Platforms\iOS\Program.cs:line 13
Native stack trace:
0 CoreFoundation 0x0000000
yToken=null],[BarcodeScanning.CameraViewHandler, BarcodeScanning.Native.Maui, Version=1.2.3.0, Culture=neutral, PublicKeyToken=null]].b__0(IElementHandler h, IElement v)
at Microsoft.Maui.PropertyMapper.UpdatePropertyCore(String key, IElementHandler viewHandler, IElement virtualView)
at Microsoft.Maui.PropertyMapper.UpdateProperty(IElementHandler viewHandler, IElement virtualView, String property)
at Microsoft.Maui.Handlers.ElementHandler.UpdateValue(String property)
at Microsoft.Maui.Controls.Element.OnPropertyChanged(String propertyName)
at Microsoft.Maui.Controls.BindableObject.SetValueActual(BindableProperty property, BindablePropertyContext context, Object value, Boolean currentlyApplying, SetValueFlags attributes, SetterSpecificity specificity, Boolean silent)
at Microsoft.Maui.Controls.BindableObject.SetValueCore(BindableProperty property, Object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes, SetterSpecificity specificity)
at Microsoft.Maui.Controls.B
ntrols.BindableObject.SetValue(BindableProperty property, Object value)
at BarcodeScanning.CameraView.set_CameraEnabled(Boolean value)
at W3AppMaui.Views.BarcodeScanner.OnAppearing() in E:\sources\W3App\W3AppMaui\Views\BarCodeScanner.xaml.cs:line 29
at System.Threading.Tasks.Task.<>c.b__128_0(Object state)
at Foundation.NSAsyncSynchronizationContextDispatcher.Apply() in /Users/builder/azdo/_work/1/s/xamarin-macios/src/Foundation/NSAction.cs:line 176
at UIKit.UIApplication.UIApplicationMain(Int32 argc, String[] argv, IntPtr principalClassName, IntPtr delegateClassName) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 58
at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 94
at W3AppMaui.Program.Main(String[] args) in E:\sources\W3App\W3AppMaui\Platforms\iOS\Program.cs:line 13

0x1ac222ea8 - /usr/lib/system/libsystem_c.dylib : abort

7b c1 a8 c0
ff
fd
Managed Stacktrace:

..

=================================================================

.{....
.......T
7b bf a9 fd 03 00 91
d4 c3 00 00 54 fd
01 10 00
)..
0x1ac2ca0fc
Die App wurde beendet.

=================================================================

...
._..
.....{
90 29
80 d2
5f d6
7b c1 a8 c0
91
03
03 00
..
0x1ac2ca0ec bf
...
.U.
..
..
.{
T
.
97
55 d6
......
0x1ac2ca0dc c3 00 00 54 fd 7b bf a9 fd
03 00 91

..
._..
)
.{.
10 00 d4
01
d2
d6 10 29 80
03 5f
0x10006e2c8 - /var/containers/Bundle/Application/D9D0FE60-19F1-48FB-9E21-BB3BF4BEC68B/W3AppMaui.app/W3AppMaui : xamarin_find_protocol_wrapper_type
0x1002d35f4 - /var/containers/Bundle/Application/D9D0FE60-19F1-48FB-9E21-BB3BF4BEC68B/W3AppMaui.app/W3AppMaui : AppleCryptoNative_X509ImportCollection
0x10037342c - /var/containers/Bundle/Application/D9D0FE60-19F1-48FB-9E21-BB3BF4BEC68B/W3AppMaui.app/W3AppMaui : AppleCryptoNative_X509ImportCollection
0x100080fb8 - /var/containers/Bundle/Application/D9D0FE60-19F1-48FB-9E21-BB3BF4BEC68B/W3AppMaui.app/W3AppMaui : xamarin_get_original_working_directory_path
0x1003db970 - /var/containers/Bundle/Application/D9D0FE60-19F1-48FB-9E21-BB3BF4BEC68B/W3AppMaui.app/W3AppMaui : AppleCryptoNative_X509ImportCollection
0x1ac17d8e0 - /usr/lib/system/libdyld.dylib :

=================================================================

Basic Fault Address Reporting

=================================================================
Memory around native instruction pointer (0x1ac2ca0dc):0x1ac2ca0cc fd
0x1ac343094 - /usr/lib/system/libsystem_pthread.dylib :

0x1ac33d9fc - /usr/lib/system/libsystem_platform.dylib : <redacted>

0x1004f3a74 - /var/containers/Bundle/Application/D9D0FE60-19F1-48FB-9E21-BB3BF4BEC68B/W3AppMaui.app/W3AppMaui : AppleCryptoNative_X509ImportCollection

0x10039d210 - /var/containers/Bundle/Application/D9D0FE60-19F1-48FB-9E21-BB3BF4BEC68B/W3AppMaui.app/W3AppMaui : AppleCryptoNative_X509ImportCollection

=================================================================
0x10039da20 - /var/containers/Bundle/Application/D9D0FE60-19F1-48FB-9E21-BB3BF4BEC68B/W3AppMaui.app/W3AppMaui : AppleCryptoNative_X509ImportCollection
0x10038890c - /var/containers/Bundle/Application/D9D0FE60-19F1-48FB-9E21-BB3BF4BEC68B/W3AppMaui.app/W3AppMaui : AppleCryptoNative_X509ImportCollection

00001ac6b9fb4 CFRunLoopRunSpecific + 436
19 GraphicsServices 0x00000001ae8bc79c GSEventRunModal + 104
20 UIKitCore 0x00000001d8b82c38 UIApplicationMain + 212
21 W3AppMaui 0x00000001000545f4 xamarin_UIApplicationMain + 60
22 W3AppMaui 0x00000001003ae2a8 AppleCryptoNative_X509ImportCollection + 2885360
23 W3AppMaui 0x00000001003acba8 AppleCryptoNative_X509ImportCollection + 2879472
24 W3AppMaui 0x00000001003a15b4 AppleCryptoNative_X509ImportCollection + 2832892
25 W3AppMaui 0x000000010039f180 AppleCryptoNative_X509ImportCollection + 2823624
26 W3AppMaui 0x000000010036de0c AppleCryptoNative_X509ImportCollection + 2622036
27 W3AppMaui 0x00000001003155d8 AppleCryptoNative_X509ImportCollection + 2259488
28 W3AppMaui 0x000000010031b8d4 AppleCryptoN
a fatal error in the mono runtime or one of the native libraries
used by your application.

=================================================================
Native stacktrace:

=================================================================
Native Crash Reporting

Got a SIGABRT while executing native code. This usually indicates

PublicKeyToken=null],[BarcodeScanning.CameraViewHandler, BarcodeScanning.Native.Maui, Version=1.2.3.0, Culture=neutral, PublicKeyToken=null]].b__0(IElementHandler h, IElement v)
at Microsoft.Maui.PropertyMapper.UpdatePropertyCore(String key, IElementHandler viewHandler, IElement virtualView)
at Microsoft.Maui.PropertyMapper.UpdateProperty(IElementHandler viewHandler, IElement virtualView, String property)
at Microsoft.Maui.Handlers.ElementHandler.UpdateValue(String property)
at Microsoft.Maui.Controls.Element.OnPropertyChanged(String propertyName)
at Microsoft.Maui.Controls.BindableObject.SetValueActual(BindableProperty property, BindablePropertyContext context, Object value, Boolean currentlyApplying, SetValueFlags attributes, SetterSpecificity specificity, Boolean silent)
at Microsoft.Maui.Controls.BindableObject.SetValueCore(BindableProperty property, Object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes, SetterSpecificity specificity)
at Microsoft.Maui.Co
AppleCryptoNative_X509ImportCollection + 2823624
8 W3AppMaui 0x000000010036de0c AppleCryptoNative_X509ImportCollection + 2622036
9 W3AppMaui 0x00000001003155d8 AppleCryptoNative_X509ImportCollection + 2259488
10 W3AppMaui 0x000000010031935c AppleCryptoNative_X509ImportCollection + 2275236
11 W3AppMaui 0x00000001003df944 AppleCryptoNative_X509ImportCollection + 3087756
12 W3AppMaui 0x000000010043a82c AppleCryptoNative_X509ImportCollection + 3460212
13 Foundation 0x00000001ad1b5690 + 336
14 CoreFoundation 0x00000001ac6bff1c + 24
15 CoreFoundation 0x00000001ac6bfe9c + 88
16 CoreFoundation 0x00000001ac6bf784 + 176
17 CoreFoundation 0x00000001ac6ba6c0 + 1004
18 CoreFoundation 0x000
2024-01-22 13:22:27.898 W3AppMaui[320:13416] Unhandled managed exception: Objective-C exception thrown. Name: NSGenericException Reason: *** -[AVCaptureSession startRunning] startRunning may not be called between calls to beginConfiguration and commitConfiguration
Native stack trace:
0 CoreFoundation 0x00000001ac72e198 + 252
1 libobjc.A.dylib 0x00000001ab9069f8 objc_exception_throw + 56
2 AVFoundation 0x00000001b2770e54 + 212
3 W3AppMaui 0x0000000100082044 xamarin_get_original_working_directory_path + 8604
4 W3AppMaui 0x00000001003ae20c AppleCryptoNative_X509ImportCollection + 2885204
5 W3AppMaui 0x00000001003acba8 AppleCryptoNative_X509ImportCollection + 2879472
6 W3AppMaui 0x00000001003a15b4 AppleCryptoNative_X509ImportCollection + 2832892
7 W3AppMaui 0x000000010039f180
509ImportCollection + 3071416
32 libdyld.dylib 0x00000001ac17d8e0 + 4

ative_X509ImportCollection + 2284828
29 W3AppMaui 0x0000000100373404 AppleCryptoNative_X509ImportCollection + 2644044
30 W3AppMaui 0x0000000100080fb8 xamarin_get_original_working_directory_path + 4368
31 W3AppMaui 0x00000001003db970 AppleCryptoNative_X509ImportCollection + 3071416
32 libdyld.dylib 0x00000001ac17d8e0 + 4
(ObjCRuntime.ObjCException)
at AVFoundation.AVCaptureSession.StartRunning() in /Users/builder/azdo/_work/1/s/xamarin-macios/src/build/dotnet/ios/generated-sources/AVFoundation/AVCaptureSession.g.cs:line 270
at BarcodeScanning.CameraViewHandler.Start()
at BarcodeScanning.CameraViewHandler.HandleCameraEnabled()
at BarcodeScanning.CameraViewHandler.<>c.<.cctor>b__27_4(CameraViewHandler handler, CameraView virtualView)
at Microsoft.Maui.PropertyMapper`2.<>c__DisplayClass5_0[[BarcodeScanning.CameraView, BarcodeScanning.Native.Maui, Version=1.2.3.0, Culture=neutral,
0x00000001003ae2a8 AppleCryptoNative_X509ImportCollection + 2885360
23 W3AppMaui 0x00000001003acba8 AppleCryptoNative_X509ImportCollection + 2879472
24 W3AppMaui 0x00000001003a15b4 AppleCryptoNative_X509ImportCollection + 2832892
25 W3AppMaui 0x000000010039f180 AppleCryptoNative_X509ImportCollection + 2823624
26 W3AppMaui 0x000000010036de0c AppleCryptoNative_X509ImportCollection + 2622036
27 W3AppMaui 0x00000001003155d8 AppleCryptoNative_X509ImportCollection + 2259488
28 W3AppMaui 0x000000010031b8d4 AppleCryptoNative_X509ImportCollection + 2284828
29 W3AppMaui 0x0000000100373404 AppleCryptoNative_X509ImportCollection + 2644044
30 W3AppMaui 0x0000000100080fb8 xamarin_get_original_working_directory_path + 4368
31 W3AppMaui 0x00000001003db970 AppleCryptoNative_X

Scanning with 3 lens iPhones isn't possible

Since the iOS CameraViewHandler always uses the BuiltInWideAngleCamera which doesn’t support close range focus for devices with 3 lenses and therefore scanning with 3 lens iPhones (e. g. iPhone 13 Pro & iPhone 15 Pro Max) isn’t possible. Based on https://github.com/JimmyPun610/BarcodeScanner.Mobile/issues/202#issuecomment-1834844897 I was able to adapt the CameraViewHandler as follows so sthat scanning is also possible with iPhones with 3 lenses.

Inside UpdateCamera() I replaced following code:

_captureDevice = AVCaptureDevice.GetDefaultDevice(
    AVCaptureDeviceType.BuiltInWideAngleCamera,
    AVMediaTypes.Video,
    VirtualView?.CameraFacing == CameraFacing.Front ? AVCaptureDevicePosition.Front : AVCaptureDevicePosition.Back);
_captureDevice ??= AVCaptureDevice.GetDefaultDevice(AVMediaTypes.Video);

with following code:

var position = VirtualView.CameraFacing == CameraFacing.Front ? AVCaptureDevicePosition.Front : AVCaptureDevicePosition.Back;
_captureDevice = GetCaptureDevice(position);

and the implementation of GetCaptureDevice() looks as follows:

private static AVCaptureDevice GetCaptureDevice(AVCaptureDevicePosition position)
 {
     AVCaptureDevice captureDevice = AVCaptureDevice.GetDefaultDevice(AVCaptureDeviceType.BuiltInTripleCamera, AVMediaTypes.Video, position);
     captureDevice ??= AVCaptureDevice.GetDefaultDevice(AVCaptureDeviceType.BuiltInDualCamera, AVMediaTypes.Video, position);
     captureDevice ??= AVCaptureDevice.DevicesWithMediaType(AVMediaTypes.Video.GetConstant()).FirstOrDefault( d => d.Position == position);

     return captureDevice;
 }

Would it be bossible to add support for 3 lens iPhone scanning based on the CameraViewHandler modifications described in this issue?

Scanning in Motion

Hello,

I'm using your package and demo for a POC. Works great relative to other solutions we have tried to use. I wanted to ask about scanning in motion. While scanning, at a very slow conveyer speed, it can pick up the codes (QR in our case). But when the speed is increased we lose the ability to recognize the barcodes. Are there fields you would recommend to adjust in order to increase the likelihood of a successful in-motion scan?

Change the barcode format at runtime

Hi,

How can I change the barcode format at runtime?
It tried this: barcodeReader.BarcodeSymbologies.Equals("Ean13");
but this is not working, it still reads all the barcodes.
Thanks in advance.

A humble request.

Hello, would it be possible to modify the project to compile for the windows platform? It would be enough if Windows showed a blank page. Our application targets Android and Windows platforms (10.0.19041.0). The Android implementation is perfect, a colleague is developing for Windows and we are now unable to continue the project. I spent time editing your source code, but unfortunately I'm not at a good enough level to handle it now, I have to get my application live and I don't have time to spare now.
You have our great admiration.

Enhancement Request: Customizable AimMode Overlay for Scanner

Hello,

I recently came across your project while transitioning to MAUI from Xamarin.Forms and found the scanner component quite promising. I particularly appreciate the AimMode feature, as it adds significant value to my applications.

However, as I delve deeper into integrating it into my projects, I've found a minor but impactful issue. While the automatic inclusion of the red dot in AimMode is a neat touch, it doesn't quite align with the design preferences I have for my scanner implementation.

I believe introducing a customization option for the AimMode overlay would greatly enhance the flexibility of your scanner component. Specifically, by providing a property such as AimModeOverlay, developers like myself would have the freedom to tailor the scanner's appearance to better fit our application's design language.

I understand that implementing this feature may require some development effort, but I believe it's a relatively straightforward addition that would greatly benefit your user base. Simply allowing developers to display a customizable overlay, such as a red circle in the center of the screen, outside of the scanner itself, would address this concern without complicating the existing functionality.

Thank you for considering this enhancement request. I'm eager to see how your project evolves and am confident that this addition would be well-received by the community.

Best regards,
Erbil

Torch not turning on - iOS

Hi

First of all, thank you for a nice plugin.

I tried using the torch function on Android and iOS

TorchOn="True"

It seems to work fine on Android but nothing happens on iOS. Can you confirm that it works on iOS?

No image detail when exporting the image using CaptureAsync()

I'm trying to export the image after the barcodes are detected so I can save the image for logging.

I am running the following code to get the Byte[] of the image.

MemoryStream mStream = new();
IScreenshotResult rawImage = await this.BarcodeView.CaptureAsync();
await rawImage.CopyToAsync(mStream, ScreenshotFormat.Jpeg, 100);
Byte[] SourceImage = mStream.ToArray();

However, when the Byte[] array is saved to the device the image is a black jpg with no detail.
The image resolution is correct, just no image data.
Inspecting the returned byte[] shows that most of the bytes are showing the value of 0.

Nuget Version: 1.4.1
OS: Android 14
Testing Device: Samsung Galaxy S21

Thank you in advance,
Pete

iOS Focus problem

Hello!
On iOS I noticed that some devices struggle to scan a code, because they can't focus (even with TapToFocusEnabled set to True).
This happens on devices with more than one camera, noting that they use the first one at the top, while for example an iPhone 7 (which has one camera) works perfectly.
Is there any possible solution?

Thanks!

Restrict barcode detection to CameraView

Hi,

Let me start to say that I really like your library!!!

  • My issue is that it seems like the image captured from the camera and used to detect barcodes do not match what is displayed in the CameraView. If you make a smaller CameraView, I still get detection from barcodes not visible in the view.
  • e.g. In the example below I get detection from both the barcode in view and the second barcode above, outside of view.
  • I tried to analyze the code to see if I could help and make a PR, but I am unsure what to do.
  • This is discovered on Android. (have not tested on iOS yet)
  • Any Ideas?

/Regards Johan

image

I have a question. Please help me..

Hello.
I am writing to you because I have a question.

The project is implementing a camera barcode scan,
I've tried to test the barcode scanning function, but no matter how many cameras I put on the barcode, the value is 0 or null in 'CameraView_OnDetectionFinished'.
What's the reason?

`<barcode:CameraView AbsoluteLayout.LayoutFlags="All"
AbsoluteLayout.LayoutBounds="0,0,1,1"
OnDetectionFinished="CameraView_OnDetectionFinished"
CaptureQuality="High"
ForceInverted="False"
TapToFocusEnabled="True"
BarcodeSymbologies="All"
CameraEnabled="True"

                        x:Name="Barcode"/>

private void CameraView_OnDetectionFinished(object sender, OnDetectionFinishedEventArg e)
{

if (e.BarcodeResults.Count > 0)
{
    //
}


var barcodeResults = e.BarcodeResults;
if (barcodeResults.Count > 0)
{

}
foreach (var result in e.BarcodeResults)
{

}
_drawable.barcodeResults = e.BarcodeResults;
Graphics.Invalidate();

}

Is the modal method the problem?
Above is the part that I call in my Main Page.

`
var barcodeScan = new BarcodeScan();
barcodeScan.OnValueScanned += (sender, value) =>
{
if (value != null && value != "")
{
string valueFromPopup = value;

}

};
await Navigation.PushModalAsync(barcodeScan);
`

Video is frozen when attempt to call page a second time

Step to reproduce:
Create a page with your control.
register it in di
builder.Services.AddSingleton();

Navigate to your page. All is ok.
Navigate back and navigate to your page a second time.
Video is frozen.

Workaround found:
Inject page with transient scope
builder.Services.AddTransient();

First time user question!

Hello. I just installed barcodescanning for the first time and I really like it so far. I do have a few questions that I couldn't figure out from the documentation. If you could help guide me how to use this, that would be super helpful! Here is my xaml code
<scanner:CameraView x:Name="BarcodeView" HorizontalOptions="Fill" VerticalOptions="Fill" OnDetectionFinished="BarcodeView_OnDetectionFinished" BarcodeSymbologies="Upca" TapToFocusEnabled="True" VibrationOnDetected="True" />

  1. Give the above code, I was expecting the BarcodeView_OnDetectionFinished event to get fired only when a barcode was scanned. It is being fired non stop with nothing in the e.BarcodeResults. Is this normal behavior?
  2. I specify BarcodeSymbologies="Upca", but the e.BarcodeResults is reading 2D barcodes on my iphone as well in the BarcodeView_OnDetectionFinished event. How do I filter out just the Upca symbology?
  3. I searched on the internet and couldn't figure out what "PoolingInterval" was. What does that functionality do?

Thanks again and sorry for so many questions!

Transparent cameraview

On android maui latest version the cameraview is transparent and i get the following error
[CoordinateTransform] The source viewport (640x406) does not match the target viewport (640x374). Please make sure they are associated with the same Viewport.

<scanner:CameraView x:Name="BarcodeView" CameraEnabled="True" VibrationOnDetected="True" OnDetectionFinished="BarcodeView_OnDetectionFinished"
                                                            CaptureQuality="Low"
                                HorizontalOptions="FillAndExpand"
                           VerticalOptions="FillAndExpand"
                            ForceInverted="True"
                            TapToFocusEnabled="True"
                            BarcodeSymbologies="All"
                            AimMode="True"
                                />

I've tried a few things now, and copied from the examples but no luck...

ObjectDisposedException when popping modal page

I've read #4 and I'm having a similar issue in 1.3.1:

System.ObjectDisposedException: Cannot access a disposed object. Object name: 'AndroidX.Camera.View.LifecycleCameraController'.
Java.Interop.JniPeerMembers.AssertSelf (/home/user/workspace/app/.meteor/sources/xamarin/java.interop/bec0326a925ff888d96cb433f5049000a6d32a33/src/Java.Interop/Java.Interop/JniPeerMembers.cs:153)
Java.Interop.JniPeerMembers.JniInstanceMethods.InvokeVirtualObjectMethod (/home/user/workspace/app/.meteor/sources/xamarin/java.interop/bec0326a925ff888d96cb433f5049000a6d32a33/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods_Invoke.cs:858)
AndroidX.Camera.View.CameraController.EnableTorch (AndroidX.Camera.View.CameraController.cs:1654)
BarcodeScanning.CameraViewHandler.Stop (:-1)
Java.Lang.Thread.RunnableImplementor.Run (/home/user/workspace/app/.meteor/sources/xamarin/xamarin-android/f68622cf6b97fa23cc3d3105a52ef5b2e31d52a1/src/Mono.Android/Java.Lang/Thread.cs:36)
Java.Lang.IRunnableInvoker.n_Run (/home/user/workspace/app/.meteor/sources/xamarin/xamarin-android/f68622cf6b97fa23cc3d3105a52ef5b2e31d52a1/src/Mono.Android/obj/Release/net8.0/android-34/mcw/Java.Lang.IRunnable.cs:84)
Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PP_V (/home/user/workspace/app/.meteor/sources/xamarin/xamarin-android/f68622cf6b97fa23cc3d3105a52ef5b2e31d52a1/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:26)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.