Redth / ZXing.Net.Mobile

Barcode Scanner for Xamarin.iOS, Xamarin.Android, UWP and Tizen
MIT License
1.07k stars 700 forks source link

iOS scanning not working (OnScanResult never fired) #967

Open meJevin opened 3 years ago

meJevin commented 3 years ago

Duplicate of #949 to bump.

Setup: Xamarin.Forms 4.8.0 Zxing.Mobile: 2.4.1 Zxing.Mobile.Forms: 2.4.1 iOS: 14.3

Upon running sample Xamarin.Forms projects for iOS this happens: the camera is enabled, the video stream is good, but not able to scan and interpret barcodes. Sample image from my device (iPhone 11): image

meJevin commented 3 years ago

@Redth, can we get some attention on this issue? I will try to investigate and debug myself though.

meJevin commented 3 years ago

@Redth, ZXingScannerView is not able to recognize barcodes (trying QR code) in version 3.0.0-beta5 too. Also, I've updated Xamarin.Forms to 5.0.0.1874 and Xamarin.Essentials to 1.6.0. No luck. Will investigate with source code later.

meJevin commented 3 years ago

Interesting, upon upgrading, ToggleTorch() also stopped working.

meJevin commented 3 years ago

@Redth, while debugging, I've never been able to hit a breakpoint at DidOutputSampleBuffer function in OutputRecorder in ZXing.ScannerView.ios.cs. Nor have I been able to hit DidDropSampleBuffer. Although, as I said earlier, the control actually shows video stream from back camera. Any ideas?

Redth commented 3 years ago

So I'm not entirely sure what was up, but i've just updated the dependencies and brought in a couple PR's that shouldn't be related and things seem to be working fine locally for me. Will publish a preview shortly.

meJevin commented 3 years ago

@Redth thank you so much. I've not been able to get it to work on iOS still. On android it works like a charm.

meJevin commented 3 years ago

@Redth, could you share your setup too?

Redth commented 3 years ago

Have you tried latest master now?

meJevin commented 3 years ago

@Redth, tried it, no luck..

meJevin commented 3 years ago

@Redth, what version of iOS are you running? What device are you using?

Redth commented 3 years ago

@meJevin i have verified it working well with both an iOS 12.5.1 iPhone 6 and an iOS 14.4 beta iPhone 11 Pro.

Have you tried the latest nuget packages from CI?

meJevin commented 3 years ago

@Redth will try and report shortly.

meJevin commented 3 years ago

@Redth while we're at it.. may I ask you about the thermal situation on your phone? Does it also get really hot in the processor area while scanning and analyzing?

Redth commented 3 years ago

Sure it does, it's doing a lot of processing ;)

You might try setting the options to use the native AVScanner on iOS to see if that's better if you have a need for the scanner running long periods of time.

meJevin commented 3 years ago

@Redth, I apologize for my late response. I've tried the latests nuget packages from CI and it still doesn't work. Here's information about my setup:

Show/Hide Visual Studio info Microsoft Visual Studio Community 2019 Version 16.8.4 VisualStudio.16.Release/16.8.4+30907.101 Microsoft .NET Framework Version 4.8.03752 Installed Version: Community Visual C++ 2019 00435-60000-00000-AA742 Microsoft Visual C++ 2019 ADL Tools Service Provider 1.0 This package contains services used by Data Lake tools ASA Service Provider 1.0 ASP.NET and Web Tools 2019 16.8.557.25636 ASP.NET and Web Tools 2019 ASP.NET Core Razor Language Services 16.1.0.2052803+84e121f1403378489b842e1797df2f3f5a49ac3c Provides languages services for ASP.NET Core Razor. ASP.NET Web Frameworks and Tools 2012 16.8.557.25636 For additional information, visit https://www.asp.net/ ASP.NET Web Frameworks and Tools 2019 16.8.557.25636 For additional information, visit https://www.asp.net/ Azure App Service Tools v3.0.0 16.8.557.25636 Azure App Service Tools v3.0.0 Azure Data Lake Node 1.0 This package contains the Data Lake integration nodes for Server Explorer. Azure Data Lake Tools for Visual Studio 2.6.1000.0 Microsoft Azure Data Lake Tools for Visual Studio Azure Functions and Web Jobs Tools 16.8.557.25636 Azure Functions and Web Jobs Tools Azure Stream Analytics Tools for Visual Studio 2.6.1000.0 Microsoft Azure Stream Analytics Tools for Visual Studio C# Tools 3.8.0-5.20604.10+9ed4b774d20940880de8df1ca8b07508aa01c8cd C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used. Common Azure Tools 1.10 Provides common services for use by Azure Mobile Services and Microsoft Azure Tools. Cookiecutter 16.8.20241.2 Provides tools for finding, instantiating and customizing templates in cookiecutter format. Extensibility Message Bus 1.2.6 (master@34d6af2) Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration. Fabric.DiagnosticEvents 1.0 Fabric Diagnostic Events GitHub.VisualStudio 2.11.102.28613 A Visual Studio Extension that brings the GitHub Flow into Visual Studio. IntelliCode Extension 1.0 IntelliCode Visual Studio Extension Detailed Info Microsoft Azure HDInsight Azure Node 2.6.1000.0 HDInsight Node under Azure Node Microsoft Azure Hive Query Language Service 2.6.1000.0 Language service for Hive query Microsoft Azure Service Fabric Tools for Visual Studio 16.0 Microsoft Azure Service Fabric Tools for Visual Studio Microsoft Azure Stream Analytics Language Service 2.6.1000.0 Language service for Azure Stream Analytics Microsoft Azure Stream Analytics Node 1.0 Azure Stream Analytics Node under Azure Node Microsoft Azure Tools 2.9 Microsoft Azure Tools for Microsoft Visual Studio 2019 - v2.9.30924.1 Microsoft Continuous Delivery Tools for Visual Studio 0.4 Simplifying the configuration of Azure DevOps pipelines from within the Visual Studio IDE. Microsoft JVM Debugger 1.0 Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines Microsoft Library Manager 2.1.113+g422d40002e.RR Install client-side libraries easily to any web project Microsoft MI-Based Debugger 1.0 Provides support for connecting Visual Studio to MI compatible debuggers Microsoft Visual C++ Wizards 1.0 Microsoft Visual C++ Wizards Microsoft Visual Studio Tools for Containers 1.1 Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container. Microsoft Visual Studio VC Package 1.0 Microsoft Visual Studio VC Package Mono Debugging for Visual Studio 16.8.43 (00471f8) Support for debugging Mono processes with Visual Studio. Node.js Tools 1.5.20902.1 Commit Hash:b474efcb6f92db52a8f8e2e6a8cb9648476885cc Adds support for developing and debugging Node.js apps in Visual Studio NuGet Package Manager 5.8.1 NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/ Open Command Line 2.4.233 2.4.233 ProjectServicesPackage Extension 1.0 ProjectServicesPackage Visual Studio Extension Detailed Info Python 16.8.20241.2 Provides IntelliSense, projects, templates, debugging, interactive windows, and other support for Python developers. Python - Conda support 16.8.20241.2 Conda support for Python projects. Python - Django support 16.8.20241.2 Provides templates and integration for the Django web framework. Python - IronPython support 16.8.20241.2 Provides templates and integration for IronPython-based projects. Python - Profiling support 16.8.20241.2 Profiling support for Python projects. Qt Visual Studio Tools 2.6.0.7 The Qt Visual Studio Tools allow developers to use the standard development environment without having to worry about any Qt-related build steps or tools. SQL Server Data Tools 16.0.62012.31170 Microsoft SQL Server Data Tools Test Adapter for Boost.Test 1.0 Enables Visual Studio's testing tools with unit tests written for Boost.Test. The use terms and Third Party Notices are available in the extension installation directory. Test Adapter for Google Test 1.0 Enables Visual Studio's testing tools with unit tests written for Google Test. The use terms and Third Party Notices are available in the extension installation directory. ToolWindowHostedEditor 1.0 Hosting json editor into a tool window TypeScript Tools 16.0.21016.2001 TypeScript Tools for Microsoft Visual Studio Visual Basic Tools 3.8.0-5.20604.10+9ed4b774d20940880de8df1ca8b07508aa01c8cd Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used. Visual F# Tools 16.8.0-beta.20507.4+da6be68280c89131cdba2045525b80890401defd Microsoft Visual F# Tools Visual Studio Code Debug Adapter Host Package 1.0 Interop layer for hosting Visual Studio Code debug adapters in Visual Studio Visual Studio Container Tools Extensions 1.0 View, manage, and diagnose containers within Visual Studio. Visual Studio Tools for CMake 1.0 Visual Studio Tools for CMake Visual Studio Tools for Containers 1.0 Visual Studio Tools for Containers Visual Studio Tools for Kubernetes 1.0 Visual Studio Tools for Kubernetes VisualStudio.DeviceLog 1.0 Information about my package VisualStudio.Foo 1.0 Information about my package VisualStudio.Mac 1.0 Mac Extension for Visual Studio Xamarin 16.8.000.261 (d16-8@bb99248) Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android. Xamarin Designer 16.8.0.507 (remotes/origin/d16-8@e87b24884) Visual Studio extension to enable Xamarin Designer tools in Visual Studio. Xamarin Templates 16.8.112 (86385a3) Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms. Xamarin.Android SDK 11.1.0.26 (d16-8/a36ce73) Xamarin.Android Reference Assemblies and MSBuild support. Mono: 5e9cb6d Java.Interop: xamarin/java.interop/d16-8@79d9533 ProGuard: Guardsquare/proguard/proguard6.2.2@ebe9000 SQLite: xamarin/sqlite/3.32.1@1a3276b Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-8@2fb1cbc Xamarin.iOS and Xamarin.Mac SDK 14.8.0.3 (c51fabee8) Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.
meJevin commented 3 years ago

Packages:

<PackageReference Include="IdentityModel.OidcClient" Version="3.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.11" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.11" />
<PackageReference Include="Refractored.MvvmHelpers" Version="1.6.2" />
<PackageReference Include="Xamarin.CommunityToolkit" Version="1.0.2" />
<PackageReference Include="Xamarin.Forms" Version="5.0.0.1905" />  
<PackageReference Include="Xamarin.Essentials" Version="1.6.0" />  
<PackageReference Include="ZXing.Net.Mobile" Version="3.1.0-beta2" />  
<PackageReference Include="ZXing.Net.Mobile.Forms" Version="3.1.0-beta2" />
meJevin commented 3 years ago

@Redth, could it be because I'm not connected to a Mac from my development computer running Windows 10? I don't have a Mac machine at my disposal unfortunately.

meJevin commented 3 years ago

Here's a screenshot from my app:

image

meJevin commented 3 years ago

I use a ZXingScannerView. This is how I use it in my app;

public partial class ScanPage : ContentView
{
    ZXingScannerView ScannerView;

    public ScanPage()
    {
        InitializeComponent();

        ScannerView = new ZXingScannerView()
        {
            Options = new MobileBarcodeScanningOptions()
            {
                TryHarder = true,
                AutoRotate = true,
                PossibleFormats = new List<BarcodeFormat> { BarcodeFormat.QR_CODE, BarcodeFormat.All_1D },
                CameraResolutionSelector = (res) =>
                {
                    return res.Last();
                },

            },
            HorizontalOptions = LayoutOptions.FillAndExpand,
            VerticalOptions = LayoutOptions.FillAndExpand,
            AutomationId = "zxingScannerView",
        };

        ScannerView.OnScanResult += ScannerView_OnScanResult;

        MainContainer.Children.Add(ScannerView);
    }

    public async Task Initialize()
    {
        ScannerView.IsScanning = true;
        ScannerView.IsAnalyzing = true;
    }

    public async Task Uninitialize()
    {
        ScannerView.IsScanning = false;
        ScannerView.IsAnalyzing = false;
    }

    private void ScannerView_OnScanResult(Result result)
    {
        // Stop analysis until we navigate away so we don't keep reading barcodes
        ScannerView.IsAnalyzing = false;

        // Show an alert
        Console.WriteLine($"\n\nSCANNED: {result.Text} {Enum.GetName(typeof(BarcodeFormat), result.BarcodeFormat)}");

        ScannerView.IsAnalyzing = true;
    }
}

Of course, before showing this ContentView I invoke Initialize() with an await.

meJevin commented 3 years ago

@Redth, just noticed in the console, I get the following message when settings IsScanning to true for the first time in my app;

=================================================================
    Native Crash Reporting
=================================================================
Got a segv while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

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

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

    0x1042d4120 - /private/var/containers/Bundle/Application/E3124E61-DC10-493C-9BF3-46CF4BA9BCE3/PVScan.Mobile.iOS.app/Xamarin.PreBuilt.iOS : mono_dump_native_crash_info

    0x1044669e4 - /private/var/containers/Bundle/Application/E3124E61-DC10-493C-9BF3-46CF4BA9BCE3/PVScan.Mobile.iOS.app/Xamarin.PreBuilt.iOS : xamarin_collapse_struct_name

    0x1042cacbc - /private/var/containers/Bundle/Application/E3124E61-DC10-493C-9BF3-46CF4BA9BCE3/PVScan.Mobile.iOS.app/Xamarin.PreBuilt.iOS : mono_handle_native_crash

    0x104472198 - /private/var/containers/Bundle/Application/E3124E61-DC10-493C-9BF3-46CF4BA9BCE3/PVScan.Mobile.iOS.app/Xamarin.PreBuilt.iOS : _ZL15param_iter_next14IteratorActionPvPKcmS0_Pj

    0x1042d7a60 - /private/var/containers/Bundle/Application/E3124E61-DC10-493C-9BF3-46CF4BA9BCE3/PVScan.Mobile.iOS.app/Xamarin.PreBuilt.iOS : mono_sigsegv_signal_handler_debug
    0x1e1f0d290 - /usr/lib/system/libsystem_platform.dylib : <redacted>

    0x10446bf84 - /private/var/containers/Bundle/Application/E3124E61-DC10-493C-9BF3-46CF4BA9BCE3/PVScan.Mobile.iOS.app/Xamarin.PreBuilt.iOS : xamarin_invoke_trampoline
    0x104472074 - /private/var/containers/Bundle/Application/E3124E61-DC10-493C-9BF3-46CF4BA9BCE3/PVScan.Mobile.iOS.app/Xamarin.PreBuilt.iOS : xamarin_arch_trampoline

    0x1b0cc1338 - /System/Library/PrivateFrameworks/CMCapture.framework/CMCapture : <redacted>
    0x196335db0 - /usr/lib/system/libdispatch.dylib : <redacted>
    0x19633912c - /usr/lib/system/libdispatch.dylib : <redacted>
    0x19634ac08 - /usr/lib/system/libdispatch.dylib : <redacted>
    0x19633cfd8 - /usr/lib/system/libdispatch.dylib : <redacted>
    0x19633dc5c - /usr/lib/system/libdispatch.dylib : <redacted>
    0x196347d78 - /usr/lib/system/libdispatch.dylib : <redacted>
    0x1e1f13804 - /usr/lib/system/libsystem_pthread.dylib : _pthread_wqthread

    0x104472c18 - /private/var/containers/Bundle/Application/E3124E61-DC10-493C-9BF3-46CF4BA9BCE3/PVScan.Mobile.iOS.app/Xamarin.PreBuilt.iOS : xamarin_arm64_common_trampoline
    0x1b097df20 - /System/Library/PrivateFrameworks/AVFCapture.framework/AVFCapture : <redacted>
    0x1b097dc4c - /System/Library/PrivateFrameworks/AVFCapture.framework/AVFCapture : <redacted>
    0x1b0a47844 - /System/Library/PrivateFrameworks/CMCapture.framework/CMCapture : <redacted>

    0x1e1f1a75c - /usr/lib/system/libsystem_pthread.dylib : start_wqthread

=================================================================
    Basic Fault Address Reporting
=================================================================
Memory around native instruction pointer (0x1044668c4):0x1044668b4  a8 83 5e f8 09 00 80 52 09 
01 00 39 a8 03 5f f8  ..^....R...9.._.
0x1044668c4  09 01 40 39 69 0f 00 34 a8 03 5f f8 09 01 c0 39  ..@9i..4
.._....9
0x1044668d4  29 8d 00 71 e8 03 09 aa 08 7d 40 d3 1f 69 01 f1  )..q.....}@..i..
0x1044668e4  e8 13 00 f9 68 0b 00 
54 08 00 00 90 08 61 2c 91  ....h..T.....a,.

=================================================================
    Managed Stacktrace:
=================================================================
=================================================================
meJevin commented 3 years ago

@Redth, upon running Sample.Forms.iOS project from latest master code in this repo, I get the following error when choosing 'Scan continuously' for the first time;

2021-01-21 20:13:31.836 Xamarin.PreBuilt.iOS[10649:3606276] ZXingScannerView.Setup() took 0,003 ms.
2021-01-21 20:13:31.836 Xamarin.PreBuilt.iOS[10649:3606276] StartScanning

[0:] Alloc AVCaptureVideoPreviewLayer took 5.623 ms.
[0:] PERF: Setting up layers took 5.4387 ms
[0:] PERF: session.StartRunning() took 267.3865 ms
Resolved pending breakpoint at 'ZXingScannerView.ios.cs:428,1' to void ZXing.Mobile.ZXingScannerView.OutputRecorder.DidOutputSampleBuffer (AVFoundation.AVCaptureOutput captureOutput, CoreMedia.CMSampleBuffer sampleBuffer, AVFoundation.AVCaptureConnection connection) [0x00001].
Resolved pending breakpoint at 'ZXingScannerView.ios.cs:420,1' to void ZXing.Mobile.ZXingScannerView.OutputRecorder.DidDropSampleBuffer (AVFoundation.AVCaptureOutput captureOutput, CoreMedia.CMSampleBuffer sampleBuffer, AVFoundation.AVCaptureConnection connection) [0x00000].
[0:] PERF: SetupCamera Finished.  Took 73.189 ms.
Thread started:  #16
[0:] PERF: Setup Focus in 1.9375 ms.
[0:] PERF: StartScanning() Took 630.5997 ms.
Thread started:  #17

=================================================================
    Native Crash Reporting
=================================================================
Got a segv while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

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

    0x100750120 - /private/var/containers/Bundle/Application/FBB16F3F-9B55-40EF-A656-A715AB32FFBD/Sample.Forms.iOS.app/Xamarin.PreBuilt.iOS : mono_dump_native_crash_info

    0x100746cbc - /private/var/containers/Bundle/Application/FBB16F3F-9B55-40EF-A656-A715AB32FFBD/Sample.Forms.iOS.app/Xamarin.PreBuilt.iOS : mono_handle_native_crash

    0x100753a60 - /private/var/containers/Bundle/Application/FBB16F3F-9B55-40EF-A656-A715AB32FFBD/Sample.Forms.iOS.app/Xamarin.PreBuilt.iOS : mono_sigsegv_signal_handler_debug
    0x1e1f0d290 - /usr/lib/system/libsystem_platform.dylib : <redacted>

    0x1008e29e4 - /private/var/containers/Bundle/Application/FBB16F3F-9B55-40EF-A656-A715AB32FFBD/Sample.Forms.iOS.app/Xamarin.PreBuilt.iOS : xamarin_collapse_struct_name

    0x1008ee198 - /private/var/containers/Bundle/Application/FBB16F3F-9B55-40EF-A656-A715AB32FFBD/Sample.Forms.iOS.app/Xamarin.PreBuilt.iOS : _ZL15param_iter_next14IteratorActionPvPKcmS0_Pj

    0x1008e7f84 - /private/var/containers/Bundle/Application/FBB16F3F-9B55-40EF-A656-A715AB32FFBD/Sample.Forms.iOS.app/Xamarin.PreBuilt.iOS : xamarin_invoke_trampoline
    0x1008ee074 - /private/var/containers/Bundle/Application/FBB16F3F-9B55-40EF-A656-A715AB32FFBD/Sample.Forms.iOS.app/Xamarin.PreBuilt.iOS : xamarin_arch_trampoline

    0x1008eec18 - /private/var/containers/Bundle/Application/FBB16F3F-9B55-40EF-A656-A715AB32FFBD/Sample.Forms.iOS.app/Xamarin.PreBuilt.iOS : xamarin_arm64_common_trampoline
    0x1b097df20 - /System/Library/PrivateFrameworks/AVFCapture.framework/AVFCapture : <redacted>
    0x1b097dc4c - /System/Library/PrivateFrameworks/AVFCapture.framework/AVFCapture : <redacted>
    0x1b0a47844 - /System/Library/PrivateFrameworks/CMCapture.framework/CMCapture : <redacted>
    0x1b0cc1338 - /System/Library/PrivateFrameworks/CMCapture.framework/CMCapture : <redacted>
    0x196335db0 - /usr/lib/system/libdispatch.dylib : <redacted>
    0x19633912c - /usr/lib/system/libdispatch.dylib : <redacted>
    0x19634ac08 - /usr/lib/system/libdispatch.dylib : <redacted>
    0x19633cfd8 - /usr/lib/system/libdispatch.dylib : <redacted>
    0x19633dc5c - /usr/lib/system/libdispatch.dylib : <redacted>
    0x196347d78 - /usr/lib/system/libdispatch.dylib : <redacted>
    0x1e1f13804 - /usr/lib/system/libsystem_pthread.dylib : _pthread_wqthread
    0x1e1f1a75c - /usr/lib/system/lib
system_pthread.dylib : start_wqthread

=================================================================
    Basic Fault Address Reporting
=================================================================
Memory around native instruction pointer (0x1008e28c4):0x1008e28b4  a8 83 5e f8 09 00 80 52 09 01 00 39 a8 03 5f f8  ..^....R...9.._.
0x1008e28c4  09 01 40 39 69 0f 00 34 a8 03 5f f8 09 01 c0 39  ..@9i..4.
._....9
0x1008e28d4  29 8d 00 71 e8 03 09 aa 08 7d 40 d3 1f 69 01 f1  )..q.....}@..i..
0x1008e28e4  
e8 13 00 f9 68 0b 00 54 08 00 00 90 08 61 2c 91  ....h..T.....a,.

=================================================================
    Managed Stacktrace:
=================================================================
=================================================================
meJevin commented 3 years ago

Debugging code from master at the moment. SEGV native crash message appears after line 215 is executed in ZXingScannerView.ios.cs.

Line is: session.StartRunning();

https://github.com/Redth/ZXing.Net.Mobile/blob/b67c6687160fb3acca9578a2bb9107aae724762d/ZXing.Net.Mobile/iOS/ZXingScannerView.ios.cs#L215

meJevin commented 3 years ago

I guess my other issue #969 about native resources not being released and the phone continuing to heat up can be closed if this SEGV issue is causing it.

meJevin commented 3 years ago

@Redth.

Redth commented 3 years ago

What type of device and iOS version is this on? I can't reproduce that here on a couple of devices...

meJevin commented 3 years ago

@Redth iPhone 11, iOS 14.3.

Redth commented 3 years ago

This happens immediately after scanning continuously? or after awhile? Debug settings? Are you linking? Just trying to figure out what might be different from how I'm testing.

meJevin commented 3 years ago

@Redth this happens when running Xamrin.Forms iOS sample from this repo. Happens when IsScanning is set to true. When IsScanning is set to true, while debugging the source code, I get to this line https://github.com/Redth/ZXing.Net.Mobile/blob/b67c6687160fb3acca9578a2bb9107aae724762d/ZXing.Net.Mobile/iOS/ZXingScannerView.ios.cs#L215 After which the crash message appears in the console. All the settings can be viewd in Xamarin.Forms iOS samples in this repo.

meJevin commented 3 years ago

It's really interesting because although I get that crash message the video stream is present. And when setting IsScanning to false video stream ends (a little green dot in the top right is also appearing and disappearing). So the crash message appears on the very first time. Despite that, I am never able to get ScanResut to fire.

Redth commented 3 years ago

So the app is not entirely crashing? It stays up just no scanning?

meJevin commented 3 years ago

@Redth exactly.

meJevin commented 3 years ago

@Redth I'm not experienced with Xamarin but, as I said, maybe it's because I'm not connected to a Mac machine and I'm doing all of this solely on my Windows PC. Unfortunately I don't have a Mac right now, it will arrive in about a month or two. So I can't confirm that

Redth commented 3 years ago

Yeah I just tried it from my Mac and I do not observe the same crash as you. I'm honestly not sure why that happens for you. I'll see if I can try from windows tomorrow. I attempted to look about 10 different times today and quickly got pulled away each time.

meJevin commented 3 years ago

@Redth sure, I'll be waiting for your results. Thank you for your help.

meJevin commented 3 years ago

@Redth, any luck?

voidNK commented 3 years ago

I got the same error. If i deploy with windows (vs2019, iphone connected to windows) the app crashed (IsScanning==true). Otherwise if i deploy with vs2019 (paired to a mac), the iphone is connected to the mac, the same codebase ist running fine, without a crash. I checked a lot of linker/compiler settings, older version of ZXing, without luck. Does anyone has another hint or solution for me/us ?

meJevin commented 3 years ago

@Redth. Yup, just got my mac recently and confirmed what @voidNK said.

RobersonGazolli commented 3 years ago

@meJevin I have the same problem had a solution?

meJevin commented 3 years ago

@RobersonGazolli. Nope. Only building and running my app from an actual Mac machine solved the problem.

meJevin commented 3 years ago

@Redth I think we can close this one.

mrobertsontvc commented 3 years ago

I have the same problem too, are there any updates?

zerocode-jack commented 3 years ago

I have the same problem too, from 13.7 versione IOS

meJevin commented 3 years ago

@mrobertsontvc, @zerocode-jack, have you guys tried running sample application on a Mac? We've established that there's an unknown error when running from a Windows machine on an iOS device. Unfortunately, we still don't know what's causing it. But when running from a Mac machine from VS Mac on a real iOS device everything seems to be working fine.

bakerhillpins commented 3 years ago

@meJevin @Redth

I see in the comments that you've been trying this on the Xamarin.Forms sample project. I'm unsure of how that could work as the AppDelegate.cs file appears to only have a single revision and doesn't include the specified startup code?

However, I've added the startup code and don't get any scan results either. iOS 14.4.2 iPhone7 Here's the crash report from the output window in VS2019



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

Got a segv while executing native code. This usually indicates

a fatal error in the mono runtime or one of the native libraries 

used by your application.
=================================================================

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

    Native stacktrace:

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

    0x10274c120 - /private/var/containers/Bundle/Application/DAABC2F6-8973-482D-83D2-458E1E39492D/Sample.Forms.iOS.app/Xamarin.PreBuilt.iOS : mono_dump_native_crash_info

    0x102742cbc - /private/var/containers/Bundle/Application/DAABC2F6-8973-482D-83D2-458E1E39492D/Sample.Forms.iOS.app/Xamarin.PreBuilt.iOS : mono_handle_native_crash

    0x10274fa60 - /private/var/containers/Bundle/Application/DAABC2F6-8973-482D-83D2-458E1E39492D/Sample.Forms.iOS.app/Xamarin.PreBuilt.iOS : mono_sigsegv_signal_handler_debug

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

    0x1028dea14 - /private/var/containers/Bundle/Application/DAABC2F6-8973-482D-83D2-458E1E39492D/Sample.Forms.iOS.app/Xamarin.PreBuilt.iOS : xamarin_collapse_struct_name

    0x1028ea1f0 - /private/var/containers/Bundle/Application/DAABC2F6-8973-482D-83D2-458E1E39492D/Sample.Forms.iOS.app/Xamarin.PreBuilt.iOS : _ZL15param_iter_next14IteratorActionPvPKcmS0_Pj

    0x1028eac70 - /private/var/containers/Bundle/Application/DAABC2F6-8973-482D-83D2-458E1E39492D/Sample.Forms.iOS.app/Xamarin.PreBuilt.iOS : xamarin_arm64_common_trampoline
    0x199875414 - /System/Library/PrivateFrameworks/AVFCapture.framework/AVFCapture : <redacted>
    0x199875174 - /System/Library/PrivateFrameworks/AVFCapture.framework/AVFCapture : <redacted>

    0x1999365e4 - /System/Library/PrivateFrameworks/CMCapture.framework/CMCapture : <redacted>
    0x199b98304 - /System/Library/PrivateFrameworks/CMCapture.framework/CMCapture : <redacted>

    0x1028e3fb4 - /private/var/containers/Bundle/Application/DAABC2F6-8973-482D-83D2-458E1E39492D/Sample.Forms.iOS.app/Xamarin.PreBuilt.iOS : xamarin_invoke_trampoline
    0x1028ea0cc - /private/var/containers/Bundle/Application/DAABC2F6-8973-482D-83D2-458E1E39492D/Sample.Forms.iOS.app/Xamarin.PreBuilt.iOS : xamarin_arch_trampoline

    0x1802ea280 - /usr/lib/system/libdispatch.dylib : <redacted>
    0x18028f390 - /usr/lib/system/libdispatch.dylib : <redacted>
    0x1802a00ac - /usr/lib/system/libdispatch.dylib : <redacted>
    0x180292c94 - /usr/lib/system/libdispatch.dylib : <redacted>
    0x1802938a8 - /usr/lib/system/libdispatch.dylib : <redacted>
    0x18029d338 - /usr/lib/system/libdispatch.dylib : <redacted>

    0x1c8ed55a4 - /usr/lib/system/libsystem_pthread.dylib : _pthread_wqthread
    0x1c8ed8874 - /usr/lib/system/libsystem_pthread.dylib : start_wqthread

=================================================================
    Basic Fault Address Reporting
=================================================================
Memory around native instruction pointer (0x1028de8f4):0x1028de8e4  a8 83 5e f8 09 00 80 52 09 01 00 39 
a8 03 
5f f8  .
.^....R...9.._.
0x1028de8f4  09 01 40 39 69 0f 00 34 a8 03 5f f8 09 01 c0 39  ..@9i..4.._....9
0x1028de904  29 8d 00 71 e8 03 09 aa 08 7d 40 d3 1f 69 01 f1  )..q.....}@..i..
0x1028de914  e8 13 00 f9 68 0b 00 54 08 00 00 90 08 21 2d 91  ....h..T...
..!-.

=================================================================
    Managed Stacktrace:
=================================================================
=================================================================```
bakerhillpins commented 3 years ago

@Redth @meJevin

FYI: I was able to resolve the crash above by updating the NuGet packages for the solution for Xamarin.Forms and Xamarin.Essentials to the following versions.

<PackageReference Include="Xamarin.Forms" Version="5.0.0.2012" />
<PackageReference Include="Xamarin.Essentials" Version="1.6.1" />

I still can't get it to work on iOS (after adding the init code) however, so I'll spend a few more minutes looking around. I did note that while SetupCaptureSession() returns true, we never seem to end up in the OutputRecorder delegate that's set.

meJevin commented 3 years ago

@bakerhillpins. I've written above that the only way to get around the iOS crash is to build and run the application on an actual Mac machine in Visual Studio for Mac. As for your question to why AppDelegate.cs doesn't have the initialization code: I guess it's because that function doesn't do much on iOS. https://github.com/Redth/ZXing.Net.Mobile/blob/f8abca8d7e4d0e1e76b6ba6b9418545aa2085036/ZXing.Net.Mobile.Forms/ZXingScannerViewRenderer.ios.cs#L18 https://github.com/Redth/ZXing.Net.Mobile/blob/f8abca8d7e4d0e1e76b6ba6b9418545aa2085036/ZXing.Net.Mobile.Forms/ZXingBarcodeImageViewRenderer.ios.cs#L19

bakerhillpins commented 3 years ago

@meJevin

I've written above that the only way to get around the iOS crash is to build and run the application on an actual Mac machine in Visual Studio for Mac.

Ok... just relating my experience. I upgraded Forms/Essentials and I no longer see the crash. So if it's technically still there than that would suggest to me that it's timing related and a concurrency issue. YMMV however.

StephaniesHusband commented 2 years ago

Any updates on the "not scanning" issue (not the crash issue)? Still seeing "not scanning" issue: Xamarin.Forms 5.0.0.2337 Xamarin.Essentials 1.7.1 ZXing.Net.Mobile 2.4.1 ZXing.Net.Mobile.Forms 2.4.1 Real iPhone 11 running iOS 15.3.1

StephaniesHusband commented 2 years ago

Any updates on the "not scanning" issue (not the crash issue)? Still seeing "not scanning" issue: Xamarin.Forms 5.0.0.2337 Xamarin.Essentials 1.7.1 ZXing.Net.Mobile 2.4.1 ZXing.Net.Mobile.Forms 2.4.1 Real iPhone 11 running iOS 15.3.1

Just tried ZXing 3.1.0-beta2 and still doesn't work with iOS. Sees image, but doesn't ever read the qrcode/fire event. Android works fine.

Toprakete commented 2 years ago

Same here, OnScanResult event not called. IPad Air with iOS 12.5.5 Iphone 5s with iOS 12.5.5 Xamarin.Forms 5.0.0.2012 Xamarin.Essentials 1.6.1 ZXing.Net.Mobile 2.4.1 ZXing.Net.Mobile.Forms 2.4.1