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

When starting camera without qrbox in settings the error occurs #343

Closed
vedran-milic opened this issue Nov 1, 2021 · 3 comments · Fixed by #371
Closed

When starting camera without qrbox in settings the error occurs #343

vedran-milic opened this issue Nov 1, 2021 · 3 comments · Fixed by #371

Comments

@vedran-milic
Copy link

Qr box setting qrbox should be optional when calling the camera, but it's not.
If I leave it out of the settings I get a console error.

Reproduction:
Call start on html5QrCode without setting the qrbox in the options.

this.html5QrCode.start(
    { facingMode: "environment" }, // no qr box in the settings
    decodedText => {
      this.scanData = decodedText;
    },
    () => {
      this.displayGenericMessage();
    }
  )

Following error occurs.

html5-qrcode.js?4c20:478 Uncaught TypeError: Cannot read properties of undefined (reading 'width')
    at Proxy.Html5Qrcode.validateQrboxConfig (html5-qrcode.js?4c20:478)
    at Proxy.Html5Qrcode.setupUi (html5-qrcode.js?4c20:491)
    at HTMLVideoElement.videoElement.onplaying (html5-qrcode.js?4c20:589)

Tracing the error lead me to this part of the code, where it says that if qr box does not have width or height, the error should be thrown, which makes no sense if this is optional

 Html5Qrcode.prototype.validateQrboxConfig = function (qrboxSize) {
        if (typeof qrboxSize === "number") {
            return;
        }
        if (qrboxSize.width === undefined || qrboxSize.height === undefined) {
            throw "Invalid instance of QrDimensions passed for "
                + "'config.qrbox'.";
        }
    };
@leocharrua
Copy link

+1

1 similar comment
@kenjilaurel
Copy link

+1

@mebjas mebjas added this to V2.1.x candidates (bug fix) in Release tracker Dec 20, 2021
@mebjas
Copy link
Owner

mebjas commented Dec 20, 2021

Thanks for raising this issue. If the qrbox size is not set - it will default to the size of video stream starting version 2.1.5.

@mebjas mebjas mentioned this issue Dec 20, 2021
@mebjas mebjas moved this from V2.1.x candidates (bug fix) to Work in progress in Release tracker Dec 20, 2021
@mebjas mebjas moved this from Work in progress to released / wont fix in Release tracker Dec 20, 2021
msoucy added a commit to chopshop-166/ChopshopSignin that referenced this issue Dec 23, 2021
bot190 pushed a commit to chopshop-166/SignInWebApp that referenced this issue Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Release tracker
released / wont fix
Development

Successfully merging a pull request may close this issue.

4 participants