Open meJevin opened 3 years ago
@Redth, can we get some attention on this issue? I will try to investigate and debug myself though.
@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.
Interesting, upon upgrading, ToggleTorch() also stopped working.
@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?
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.
@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.
@Redth, could you share your setup too?
Have you tried latest master now?
@Redth, tried it, no luck..
@Redth, what version of iOS are you running? What device are you using?
@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?
@Redth will try and report shortly.
@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?
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.
@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:
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" />
@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.
Here's a screenshot from my app:
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.
@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:
=================================================================
=================================================================
@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:
=================================================================
=================================================================
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();
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.
@Redth.
What type of device and iOS version is this on? I can't reproduce that here on a couple of devices...
@Redth iPhone 11, iOS 14.3.
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.
@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.
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.
So the app is not entirely crashing? It stays up just no scanning?
@Redth exactly.
@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
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.
@Redth sure, I'll be waiting for your results. Thank you for your help.
@Redth, any luck?
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 ?
@Redth. Yup, just got my mac recently and confirmed what @voidNK said.
@meJevin I have the same problem had a solution?
@RobersonGazolli. Nope. Only building and running my app from an actual Mac machine solved the problem.
@Redth I think we can close this one.
I have the same problem too, are there any updates?
I have the same problem too, from 13.7 versione IOS
@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.
@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:
=================================================================
=================================================================```
@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.
@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
@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.
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
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.
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
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):