darryncampbell / react-native-datawedge-intents

React Native interface for Zebra's DataWedge Intent API
MIT License
43 stars 46 forks source link

Double scan and reloading app #13

Closed sergeykotor closed 3 years ago

sergeykotor commented 3 years ago

Hello! In the debug mode, when scanning the date matrix codes, it is reloaded. There is also the problem of double scanning, when the scanner does not go into disabled mode immediately, but only after the second scan. And if it turns out to be scanned once, then two entries are displayed in the console. React version 0.63, device TC70

sergeykotor commented 3 years ago

https://user-images.githubusercontent.com/53668790/104464720-4edd2980-55c4-11eb-9f4c-7a6555e692e3.mp4

sergeykotor commented 3 years ago

https://snack.expo.io/@sergeykotor/8f9ff2 source, but i dont use expo, just for show

darryncampbell commented 3 years ago

Thanks for sharing, I have a few questions / points:

sergeykotor commented 3 years ago

Thanks for answer!

  1. I cant install this project.
  2. Attached a video of the behavior of this photo_2021-01-14_09-59-35 photo_2021-01-14_09-59-51 photo_2021-01-14_09-59-15

https://user-images.githubusercontent.com/53668790/104555412-dec7b580-564e-11eb-93eb-6b94ab043422.MOV

sergeykotor commented 3 years ago

@darryncampbell I built your application and now it seems to work correctly

https://user-images.githubusercontent.com/53668790/104565365-3e2cc200-565d-11eb-9acc-f8e6f305c258.mp4

darryncampbell commented 3 years ago

That is so strange. Could it be that you are running in debug and something to do with hot reload causing multiple broadcast receivers (or observers?) to be registered without unregistering the previous ones, that would explain why you are getting inconsistent behaviour and the multiple scans, though would not explain the app reloading behaviour.

I see a genericReceiver object that is not unregistered in the onHostPause() method, that could be the root cause. I also see a comment at https://github.com/darryncampbell/react-native-datawedge-intents/blob/master/android/src/main/java/com/darryncampbell/rndatawedgeintents/RNDataWedgeIntentsModule.java#L100 saying this is expected behaviour... it has been a long time since I looked at this code but it looks as though there was some discussion on how it should work when I first implemented it - that could be the root cause of what you are seeing but if I'm right, and this is related to hot reload, this would only be seen during development.

sergeykotor commented 3 years ago

@darryncampbell Thanks for the answer! Maybe this is really hot reload. And I noticed another bug in the builded version, after several scans (10-15) new barcodes are not added to the beginning of the list.

https://user-images.githubusercontent.com/53668790/104689056-e94b8300-5712-11eb-9919-d20f69425178.MOV

darryncampbell commented 3 years ago

in the builded version, after several scans (10-15) new barcodes are not added to the beginning of the list.

That would definitely be some problem with my app rather than the Intent plugin - I add the scan to the array at https://github.com/darryncampbell/DataWedgeReactNative/blob/master/App.js#L259, I guess there is something wrong with that logic

sergeykotor commented 3 years ago

@darryncampbell Please, sorry about offtop! Сan android 5.1 with gms be installed for my tc70 TC700H-KC11ES-IN android 4.4 without gms?

darryncampbell commented 3 years ago

@sergeykotor Yes, you can (the link to the download is https://www.zebra.com/us/en/support-downloads/software/operating-system/tc70-operating-system.html) but you need to have a support contract or some other eligibility to download the image. If you don't have those then there is a 'contact support' button in the top right hand corner.

Once you have access to the download, follow the instructions in the ReadMe and be aware of step 5g:

Next step only if you are switching between GMS and NON-GMS software, otherwise this
step is not required.
• If you are updating device from GMS to NON-GMS or Vice Versa, it is required to
either use T70N0LXXARFXX21002.zip (Factory Reset Package v02.10.02) (Factory
Reset, this will give complete OOB experience) or at Minimum, please do a
T70N0LXXAREXX21002.zip (Enterprise Reset Package v02.10.02)
sergeykotor commented 3 years ago

image I need these files? Because i can download without support contract now.

darryncampbell commented 3 years ago

Yes, that is right. Install the Full Software Update, Factory Reset, then the Mandatory Patch, then the latest Lifeguard release (17). Instructions should be in the readme but in short:

Note, all data on the device will be lost when you Factory Reset!!!

sergeykotor commented 3 years ago

@darryncampbell Thank you! I am grateful for your advice.

sergeykotor commented 3 years ago

I updated android, installed liveguard update, and now all problems (with debugging, double scanning, etc.) are gone. Thank you again

sergeykotor commented 3 years ago

The problem with multiple scans is still present, it appears if you make code edits in the debug.

darryncampbell commented 3 years ago

There is a bug in the sample app, you will need to unregister / reregister the event emitter during a reload, like this:

  componentDidMount()
  {
    this.state.deviceEmitterSubscription = DeviceEventEmitter.addListener('datawedge_broadcast_intent', (intent) => {this.broadcastReceiver(intent)});
    this.registerBroadcastReceiver();
    this.determineVersion();
  }

  componentWillUnmount()
  {
    this.state.deviceEmitterSubscription.remove();
  }
darryncampbell commented 3 years ago

https://github.com/darryncampbell/DataWedgeReactNative/commit/79d5325f486bae3c4cd7c45486f7ded189ca5a9c

sergeykotor commented 3 years ago

@darryncampbell I've done this before, and it didn't help

sergeykotor commented 3 years ago

@darryncampbell I downloaded the project from the git again and now the logs are working normally, but at start is sends a signal that a scan has occurred. Some kind of intent not related to the scanner comes https://github.com/darryncampbell/DataWedgeReactNative/blob/a915464dff023b7b276e9fee3354618e7e3521ef/App.js#L140 image

darryncampbell commented 3 years ago

Strange, I could not reproduce that "Scan: undefined" message - do you just launch the app and then see it or are there other reproduction steps?

sergeykotor commented 3 years ago

I launched the application after a few days and the error disappeared. Maybe it was my problem.