Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config.debug ignored. console.warn only contains debug info #541

Open
lewismoten opened this issue May 19, 2024 · 3 comments
Open

config.debug ignored. console.warn only contains debug info #541

lewismoten opened this issue May 19, 2024 · 3 comments

Comments

@lewismoten
Copy link

Hello. I've had fun with the Barcode Detection API, but found that Safari and Chrome doesn't support it on iOS. I have found your library looking for a way to work around the issues and polyfill the API.

Every time I call Quagga to decodeSingle, it adds a bunch of warnings to the console to the point that its difficult to debug anything else when streaming video. It seems that these warnings are diagnostic information for debugging rather than actual warnings. I have tried changing the configuration debug setting to false, but the warnings still appear.

* initCanvas getCanvasAndContext
* initCanvas getCanvasAndContext
*** frame_grabber_browser: willReadFrequency=undefined canvas= <canvas class="imgBuffer" width="800" height="500">
Invalid asm.js: Unexpected token

Here is my code. In this case, the src is a data url from canvas.toDataURL()

// https://cdn.jsdelivr.net/npm/@ericblade/quagga2/dist/quagga.min.js

const config = {
  src,
  decoder: {
    readers: ['code_128_reader']
  },
  debug: false
};
const callback = result => {
  if(result) {
    console.log('got a result', result);
  } else {
    console.log('nothing');
  }
};
window.Quagga.decodeSingle(config, callback)

I reviewed the quagga2 source code and found that all of the console messages are hard-coded to write output without checking any of the configuration debug settings.

https://github.com/search?q=repo%3Aericblade%2Fquagga2%20console.warn&type=code

Copy link

Thank you for filing an issue! Please be patient. :-)

@lewismoten lewismoten changed the title Console has warning logs that only contain diagnostic information when debug is false config.debug ignored. console.warn only contains debug info May 19, 2024
@lewismoten
Copy link
Author

The workaround that I'm using is to hijack the console.warn method temporarily and restore it after the decoder responds.

const warn = console.warn;
console.warn = () => {};
const config = {
  src,
  decoder: {
    readers: ['code_128_reader']
  },
  debug: false
};
const callback = result => {
  console.warn = warn.bind(console);
  if(result) {
    console.log('got a result', result);
  }
  resolve([])
};
window.Quagga.decodeSingle(config, callback)

@ericblade
Copy link
Owner

Thanks for reporting that, probably left some stuff in there while I was diagnosing a previous failure. My bad.

I haven't had much time to go routing around in my working application lately. Apologies. :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants