Zebra EMDK: barcode scanning crashes in debug with Xamarin 4.9.0.749

DouglasHenkeDouglasHenke USUniversity ✭✭
edited March 2018 in Xamarin.Android

I have a barcode scanning application built in Xamarin.Android using the Zebra EMDK. Under Xamarin 4.9.0.749, it crashes 100% reproducibly at or near a call to scanner.Read():

03-09 13:27:43.043 F/        (21460): * Assertion at /Users/builder/jenkins/workspace/xamarin-android-d15-6/xamarin-android/external/mono/mono/metadata/threads.c:3016, condition `internal' not met
03-09 13:27:43.043 F/libc    (21460): Fatal signal 6 (SIGABRT), code -6 in tid 21532 (Thread-1255)

This only happens when running in the debugger; release builds work fine. I see the same problem on various platforms including TC70X, TC75X and WT6000.

This is a regression; the same code worked fine (in both release and debug modes) with prior Xamarin versions.

I am using Microsoft Visual Studio Professional 2015, Version 14.0.25431.01 Update 3, with Xamarin.Android SDK 8.2.0.15.

The problem can be easily re-created using the Zebra sample application.

Steps to recreate:
1. Open solution.
2. Change build mode from "Release" to "Debug".
3. Clean solution.
4. Build solution.
5. Connect target device via USB cable. Ensure USB debugging is enabled and that your target device model appears next to the "Run" in the toolbar.
6. Launch application in debugger.
7. When UI appears, check "continuous" box, then press "Start" button.
8. Press and release scan trigger a few times. (Two is usually enough. Ten always is.)

Additional information:

The same crash happens regardless of the specific version of Symbol.XamarinEMDK I link against. I've tried it with the default that comes with the sample app (2.4.0.87) as well as the latest pre-release EMDK in a NuGet package (2.7.0.76), plus some 2.5.x and 2.6.x intermediate versions.

It also doesn't seem to matter what target framework I use. The sample app default (Android 4.4 KitKat) exhibits the problem, as does Android 8.1 Oreo.

Best Answer

Answers

  • PeterBaPeterBa Member

    Same error.

  • FrancescosafFrancescosaf USMember ✭✭
    edited March 2018

    Same error ..
    report bug 61261

  • DouglasHenkeDouglasHenke USUniversity ✭✭

    @Francescosaf said:
    Same error ..
    report bug 61261

    Thanks. That does indeed look like the same issue. Here is a link to Bug #61261 for anyone reading.

    I have also opened a case (ID 04000930) with Zebra support, as my ability to trigger this bug seems to be tied to using their EMDK. (This is probably a Xamarin problem and not an EMDK bug, but it seemed like a good idea to get it on their radar sooner rather than later.)

  • FrancescosafFrancescosaf USMember ✭✭
    edited March 2018

    I agree it is not related to Zebra SDK but to Xamarin (also because I'm working with google maps and not Zebra SDK :( )
    It is a big trouble could not debug

  • PatrickKirschPatrickKirsch DEMember

    Are there some news to this Bug? After Upgrading again to the newest Version of VS2017 (15.6.3) this problem isn't gone and I can't find a solution to it via google or my self. For me the only solution i see is to downgrade again to 15.4.5 and hope for the best on the next release!?

  • DouglasHenkeDouglasHenke USUniversity ✭✭

    @PatrickKirsch said:
    Are there some news to this Bug? After Upgrading again to the newest Version of VS2017 (15.6.3) this problem isn't gone and I can't find a solution to it via google or my self. For me the only solution i see is to downgrade again to 15.4.5 and hope for the best on the next release!?

    Patrick,

    I am experiencing this bug with both VS2017 (15.6.3) and VS2015. Another user is reporting it with VS2017 (15.6.2) in the Xamarin Bugzilla linked above.

    Based on this, I do not believe that downgrading Visual Studio will help. I suspect (but have not yet tested myself) that downgrading Xamarin itself to some version earlier than 4.9.0.749 would be required to avoid this bug.

    Speculation: The bug is in Xamarin or Mono, not Visual Studio.

  • PatrickKirschPatrickKirsch DEMember

    Hi,
    and thanks for your quick response. Even if it is an bug in Xamarin, in VS2017 Xamarin is integrated into the VS2017 Installer as component. so the only way i can downgrade Xamarin is to downgrade the hole VS2017, or do i miss something?
    I also tested this method one week ago or so, is was upgrading to 15.6.2 and facing this Issue the first Time, after half a day of researching and trying to fix it, i gave up and downgraded VS2017 to 15.4.5 that was the Last Installer i was able to find.
    But this is quite a process because you first have to uninstall VS2017 and the reinstall it with the old version, this took the other half of my day, now i tried it again with the new 15.6.3, hoped that the bug was fixed but it doesn't look so...
    Also i looked into the Bug report on Bugzilla but it seems like nobody beside the concerned people are interrested into fixing it or at least explaining why this error happends...

  • DouglasHenkeDouglasHenke USUniversity ✭✭

    @PatrickKirsch said:
    Hi, and thanks for your quick response.

    Happy to help. We're all in this together. Software development is hard enough even when the tools aren't broken.

    Even if it is an bug in Xamarin, in VS2017 Xamarin is integrated into the VS2017 Installer as component. so the only way i can downgrade Xamarin is to downgrade the hole VS2017, or do i miss something?

    Just now, I downloaded the older version of Xamarin for VS2015 from here:

    https://dl.xamarin.com/XamarinforVisualStudio/Windows/Xamarin.VisualStudio_4.8.0.1289738.msi

    I installed this over the top of my existing VS2015 install, and the bug is gone!

    Caveat: You may need to be logged in to a Xamarin account to use the above download link. Here is another link to the download page just in case:

    https://store.xamarin.com/account/my/subscription/downloads

    (You want the "get previous servicing update" link.)

    Caveat #2: (This is likely specific to barcode scanning using the Zebra EMDK.) I had to reboot my target device to get things working. The buggy Xamarin/Mono stuff had apparently gotten the scan engine into a bad state such that merely re-launching the app didn't fix it.

    Also i looked into the Bug report on Bugzilla but it seems like nobody beside the concerned people are interrested into fixing it or at least explaining why this error happends...

    The Xamarin guys try. There are a lot of bugs reported. It's at least assigned to somebody. But yeah, I guess without a time-frame for a fix, I'm inclined to just stick with Xamarin 4.8.0.1289738 for now (and maybe try each new release as it comes out, knowing I can easily go back).

    Happy Hacking!

  • corwasherecorwashere Member

    Hello,

    I just want to report that I am having the exact same issue that everyone else is describing on this thread. I am also using the Zebra EMDK on a WT6000. I am using Visual Studio 2017 for Mac.

    The following error is reported just before the app crashes. This happens in both Release and Debug

    [] * Assertion at /Users/builder/jenkins/workspace/xamarin-android-d15-6/xamarin-android/external/mono/mono/metadata/threads.c:3016, condition `internal' not met
    [libc] Fatal signal 6 (SIGABRT), code -6 in tid 24079 (Thread-1041)

    Please keep this thread posted on the status of this issue as we are developing a time-critical enterprise application and this is going to be a huge roadblock.

    Regards!

  • BrendanZagaeskiBrendanZagaeski USForum Administrator, Xamarin Team Xamurai
    Accepted Answer

    Developer Community cross-reference

    I would recommend to vote on and follow that Developer Community report for updates and fix notifications.

  • SasanJamaliSasanJamali USMember ✭✭

    Hi Please Help me !!

    How Use REad Barcode in Xamarin forms pcl??

  • DouglasHenkeDouglasHenke USUniversity ✭✭

    @SasanJamali said:
    How Use REad Barcode in Xamarin forms pcl??

    Reading barcodes using the Zebra EMDK is platform-specific, so the approach I'd suggest is to use a dependency service. The general approach is:

    1) On the PCL side, create a platform-neutral interface that defines an API for barcode scanning:

    public interface IScanner { ... }

    2) On the native side, create a class implementing the interface using the Zebra EMDK. Give it an attribute so the dependency service can find it later:

    [assembly: Xamarin.Forms.Dependency(typeof(IScanner))]
    namespace My.Name.Space
    {
       public class NativeScanner : IScanner {
          ...
       }
    }

    3) On the PCL side, use the Xamarin dependency service to instantiate your scanner implementation:

    IScanner scanner = DependencyService.Get<IScanner>();

    This isn't the place for a full tutorial, but you can find more information in the Microsoft Documentation.

    The hard part of using scanning under the Zebra EMDK isn't the above, IMHO. One trick is making sure DataWedge isn't fighting with you. Another is acquiring and releasing the EMDK at the right points in your application's life cycle. (If you are holding the EMDK while your app isn't "in front of" the user, you're probably doing it wrong. Watching for Android.Content.TrimMemory.UiHidden in your application's OnTrimMemory() can be very helpful.) Making sure you don't try to use the scan API until the EMDK is (asynchronously) open is important.

    On the original topic: The bug we were talking about is fixed as of VS 2017 1.57 preview 4. I'm running preview 5 at the time of this writing, and can personally confirm that the bug is gone.

  • UnreachableCodeUnreachableCode USMember ✭✭✭

    @DouglasHenke I am writing an app that I figured would need an approach like the one you have outlined above. I am using EMDK as it appears to be one of the top barcode scanning libraries. And I need to scan using the scanners hard trigger, which EMDK supports out of the box.

  • JustDaveJustDave USMember

    I have a Xamarin project using the zebra EMDK. It requires a library that will only load on a Zebra device.

  • ChristianDaniel.9282ChristianDaniel.9282 USMember ✭✭

    So, the error was fixed and everything is fine while working with Visual Studio 2017.
    But with VS2019 (Mac & Windows) the error is back :(

  • BrendanZagaeskiBrendanZagaeski USForum Administrator, Xamarin Team Xamurai

    @ChristianDaniel.9282, are you seeing an "Assertion at..." error message? If you're not seeing that particular message but you're seeing a crash during debugging, there's a likely chance you might be seeing a different new issue:

Sign In or Register to comment.