mebjas / html5-qrcode

A cross platform HTML5 QR code reader. See end to end implementation at: https://scanapp.org
https://qrcode.minhazav.dev
Apache License 2.0
4.9k stars 959 forks source link

Compatibility - [Android]Xiaomi browser crashes on scanning QR code #718

Open MonsterPi13 opened 1 year ago

MonsterPi13 commented 1 year ago

Description

When using the HTML5 QR code library on Xiaomi browser, the browser crashes and closes unexpectedly. This issue occurs on Android 12 with Xiaomi MIUI browser version 17.4.240216. The user agent string is: Mozilla/5.0 (Linux: U: Android 12: zh-cn: 22011211C Build/SP1A.210812.016) AppleWebKit/537.36(KHTMLlike Gecko) Version/4.0 Chrome/100.0.4896127 Mobile Safari/537.36 XiaoMi/MiuiBrowser/17.4.240216 swan-mibrowser

On another Xiaomi phone, the browser launches the built-in QR code scanner. The user agent string is: Mozilla/5.0 (Linux: U: Android 12: zh-cn: M2102J2SCBuild/SKQ1.211006.001) AppleWebKit/537.36(KHTML. like Gecko) Version/4.0 Chrome/100.0.4896.127 Mobile Safari/537.36XiaoMi/MiuiBrowser/17.4.240216 swan-mibrowser

Steps to reproduce

  1. Open Xiaomi MIUI browser on an Android 12 device.
  2. Navigate to a web page that uses the HTML5 QR code library.
  3. Use the device's camera to scan a QR code on the page.
  4. The browser crashes and closes unexpectedly.

Expected behavior

The HTML5 QR code library should be able to scan QR codes without causing the Xiaomi browser to crash.

Actual behavior

The Xiaomi browser crashes and closes unexpectedly when using the HTML5 QR code library.

Additional information

Xiaomi MIUI browser version: 17.4.240216 Android version: 12


Is there a way to avoid this from happening?

bugaio commented 1 year ago

我也遇到了, 具体 为什么 会 闪退, 也不知道,
逐行 注释 , 发现是 code-decoderBarcodeDetectorDelegate 的问题 所以

function Html5QrcodeShim(requestedFormats, useBarCodeDetectorIfSupported, verbose, logger) {
        this.EXECUTIONS_TO_REPORT_PERFORMANCE = 100;
        this.executions = 0;
        this.executionResults = [];
        this.wasPrimaryDecoderUsedInLastDecode = false;
        this.verbose = verbose;
        // 移除其他, 只有 zxing
        this.primaryDecoder = new ZXingHtml5QrcodeDecoder(requestedFormats, verbose, logger);
    }

小米可以用了