capacitor-community / barcode-scanner

A fast and efficient (QR) barcode scanner for Capacitor
MIT License
437 stars 167 forks source link

[need urgent help] nothing happens when scanning?! #256

Open catalin560 opened 1 year ago

catalin560 commented 1 year ago

using latest version of ionic react

configured AndroidManifest.xml according to here

css:

body.scanner-active {
  background: transparent;
  --background: transparent;
  --ion-background-color: transparent;

  #rootapp {
    opacity: 0;
  }
}

js:

BarcodeScanner.hideBackground();
document.body.classList.add("scanner-active");
BarcodeScanner.startScan()
        .then((result) => {
          // if the result has content
          if (result.hasContent) {
            document.body.classList.remove("scanner-active");

            // show alert with data
            alert(result.content);
          } 
        })
        .finally(() => {
          document.body.classList.remove("scanner-active");
        });

then I open app in android studio, I point at code and nothing happens: Capture2

Logcat seems to explode with a bunch of error messages as soon as camera turns on: Capture

this is the error: BufferQueueProducer E [SurfaceTexture-0-7706-0](id:1e1a00000001,api:4,p:518,c:7706) dequeueBuffer: attempting to exceed the max dequeued buffer count (4)

I used QR code generated online that should say "testing" or something: test

Please advise!

thegnuu commented 1 year ago

Which version of the plugin are you using?

catalin560 commented 1 year ago

Which version of the plugin are you using?

"@capacitor-community/barcode-scanner": "^4.0.1",
"@capacitor/android": "5.0.4",
    "@capacitor/app": "5.0.2",
    "@capacitor/browser": "^5.0.2",
    "@capacitor/core": "^5.0.4",
    "@capacitor/device": "^5.0.2",
    "@capacitor/ios": "5.0.4",
    "@capacitor/splash-screen": "^5.0.2",
    "@ionic/react": "^7.0.7",
    "@ionic/react-router": "^7.0.7",
    "@ionic/storage": "^4.0.0",
thegnuu commented 1 year ago

Are you able to share your project? Unfortunately, I cannot reproduce your issue on my end and it is nearly impossible to find your issue if I cannot check some nonworking code.

catalin560 commented 1 year ago

Are you able to share your project? Unfortunately, I cannot reproduce your issue on my end and it is nearly impossible to find your issue if I cannot check some nonworking code.

I was able to reproduce this issue within a sample project: scantest.zip

video

catalin560 commented 1 year ago

Hi, @thegnuu! Were you able to take a look at scantest.zip? Is there something I'm doing wrong? What am I missing?

thegnuu commented 1 year ago

Unfortunately, your ZIP is not working... Can you quickly create a demo repo? This way I can make a PR if I can find an error and easily share it with you.

catalin560 commented 1 year ago

Unfortunately, your ZIP is not working... Can you quickly create a demo repo? This way I can make a PR if I can find an error and easily share it with you.

ok... I've sent you an invite to scantest)

thegnuu commented 1 year ago

Thanks! I quickly checked out your project and I was able to run it on my Pixel 6a without any issues. Your provided QR code works as well. I was never able to set up an emulator with a working camera, even though all settings seem to be okay, so I cannot test this - but your code works without any issues on my end.

Can you test it on a real device? I am not sure if the issue is related to the emulator somehow, and I don't really have time to look at this at the moment since this is not really an urgent issue IMHO

catalin560 commented 1 year ago

yeah... I tried building an apk to test it on my phone and it does the same... to me it is kinda urgent seeing as I can't get it to work at all, but thanks, I guess...

thegnuu commented 1 year ago

Not urgent was related to emulator-specific problems. The fact is, that I cannot do anything if I am not able to reproduce the issue. I am as well pretty sure that the issue is not related to the plugin itself, we are just using zxing to detect codes on Android, and since there is no usage of SurfaceTexture in this repo, the issue has to be on a deeper level.

The only thing I can offer you right now is to switch to the beta release on npm based on this branch: https://github.com/capacitor-community/barcode-scanner/tree/ml-kit

This is quite a big rewrite and zxing is replaced with ml-kit, the camera handling has changed as well, it might be possible that this version is running on your end. As a bonus, you will get better and faster results too.

Crylion commented 1 year ago

@thegnuu This is not entirely related to this issue, but I'm also trying to use the ML-Kit version and I noticed the latest Release (5.0.0-beta.2) does not seem to have actually been released. The latest version showing up in NPM is 5.0.0-beta.1. And I think I might need the fix mentioned in the release notes of beta.2 😅

daniel-ricado commented 1 year ago

having the same issue on a oppoA series and windows/chrome laptop. The camera opens but there is not target overlay and nothing happens.

Edit: what I've found is there is no target overlay like the older plugins, so scanning the code is a bit of guess work. adding a crosshair/ target bpoundary by default would be helpful