dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.22k stars 1.75k forks source link

Multiple Duplicate Scans Generated in Rapid Succession with Zebra EMDK #17031

Closed DCox2016 closed 8 months ago

DCox2016 commented 1 year ago

Description

Environment: Platform: Android .NET MAUI Version: 7.0.86/7.0.100 Zebra EMDK Library Version: 8.0.0.9

When rapidly performing multiple scans using the Zebra EMDK library within a .NET MAUI project, we're experiencing an issue where scans are being submitted multiple times in a row with identical SKU numbers and timestamps. As a result, we observe duplicates, triplicates, and sometimes even quadruplicates of the same scan entry.

Steps to Reproduce

  1. Open the .NET MAUI application on an Android device.
  2. Navigate to the scanning interface.
  3. Quickly perform multiple scans on the same item.
  4. Observe the submitted scans in the application or backend.

Link to public reproduction project repository

No response

Version with bug

7.0.92

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 10

Did you find any workaround?

yes, we tired to use a data wedge, interface, and event handler but the same thing. To prevent the issue we had to do platform check on the maui side of code and execute the Android side code this skipped the abstracted dependency mechanism and the duplicates stopped. i.e

@if __Android ___ //instance of android class AndroidClass ac = new AndroidClass(); var somefunction = ac.TestFunction() @endIf

Relevant log output

No response

ghost commented 1 year ago

Hi @DCox2016. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

rmarinho commented 1 year ago

Hello @DCox2016 shouldn't this be logged on the developer.zebra.com ?

DCox2016 commented 1 year ago

I'll need to consult with my supervisor regarding the allocation of time for creating a minimal reproducible example. With respect to logging this issue on developer.zebra.com, I believe it's not necessary. The EMDK library from Zebra is performing as anticipated; it successfully scans and returns the correct barcode number. The root of the challenge appears to be the dependency mechanism within Maui and Xamarin. Our observations indicate that rapid scanning exacerbates the lag between the platform-specific code and the Maui or Xamarin layers. However, in our tests using a Xamarin Android-only app that exclusively utilized Android-native code, we observed no such bottleneck or duplicate entries.

Eilon commented 1 year ago

@DCox2016 I think we need more info to be able to take action on this. I'm not familiar with the Zebra library. Where is the data being received incorrectly? Do you have a sense of where the problem might be?

ghost commented 1 year ago

Hi @DCox2016. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

acaliaro commented 1 year ago

@DCox2016 Zebra emdk is deprecated to read barcodes. You should use datawedge and intents.

https://acaliaro.wordpress.com/2023/06/08/read-a-barcode-with-zebra-terminals-using-datawedge-and-dotnetmaui/

ghost commented 1 year ago

Hi @DCox2016. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

DCox2016 commented 1 year ago

@Eilon the issue is not scanning the data it's that Maui is posting the data multiply times to the database. The scanner only returns the barcode or sku once. I have added advance logs to capture this. I added a count on the post to see how many time the post happens on the Maui side and the count happens more than once, so the data is being posted over and over again in a matter of seconds.

DCox2016 commented 1 year ago

@acaliaro actual I did try the data wedge approach with weak reference manager and the same thing happened. What actual worked for me was invoking platform side code. I did a test with Android Xamarin project and the duplicates did not happen. https://learn.microsoft.com/en-us/dotnet/maui/platform-integration/invoke-platform-code also the EMDK is not deprecated Zebra does have documentation on how to add it https://developer.zebra.com/blog/developing-net-maui-zebra-androidtm-devices . I know #if Android in the code is not pretty but this helps without using an interface which I believe had something that might have been a part of the issue.

Eilon commented 1 year ago

@Eilon the issue is not scanning the data it's that Maui is posting the data multiply times to the database. The scanner only returns the barcode or sku once. I have added advance logs to capture this. I added a count on the post to see how many time the post happens on the Maui side and the count happens more than once, so the data is being posted over and over again in a matter of seconds.

MAUI doesn't post data to any database, so there must be some other code in there that's running. Are you able to set a breakpoint in the database update code and see why it's getting called twice? Make sure you disable "Just My Code" so that the entire stack trace can be seen.

acaliaro commented 1 year ago

@acaliaro actual I did try the data wedge approach with weak reference manager and the same thing happened. What actual worked for me was invoking platform side code. I did a test with Android Xamarin project and the duplicates did not happen. https://learn.microsoft.com/en-us/dotnet/maui/platform-integration/invoke-platform-code also the EMDK is not deprecated Zebra does have documentation on how to add it https://developer.zebra.com/blog/developing-net-maui-zebra-androidtm-devices . I know #if Android in the code is not pretty but this helps without using an interface which I believe had something that might have been a part of the issue.

image you have not to use emdk to read a barcode. Have you tried my sample on github? Do you have the same problem with it?

DCox2016 commented 1 year ago

Yes, it is not the data wedge or the emdk that the issue it is Maui sending multiple post. The data comes from the Android platform once but it post multiply times on the Maui side of code. What resolved the issue was invoking platform side code. No, I did not use your solution we have a data wedge solution with event handlers and multiple post still happen. The issue only reproduceable on a Zebra T51 and T52. Due to emulators not having the emdk you can not use an emulator.

Eilon commented 12 months ago

@DCox2016 do you have more details about "it is Maui sending multiple post"? .NET MAUI doesn't send or post anything to anywhere, so I'm not sure what could be doing that. Do you have a call stack that shows what is doing the "multiple post" each time?

jfversluis commented 8 months ago

From what I read here this seems like this should be fixed in the business logic and not something that originates from within .NET MAUI.

There has not been a response for a good while now and there have been repeated asks for relevant code or a reproduction sample which can't be provided. Without it, it will be impossible to determine if there is action for us to take here. As such, I'm closing this on our end.

Thanks for the input here everyone!