Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-5231

removing a barcodescanner immediately right after the browser renders it causes javascript error

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Later Later
    • None
    • 9.6.2
    • None
    • Security Level: Jimmy
    • None

      Steps to Reproduce

      1. load the attached zul
      2. open developer tool > console tab
      3. click "remove" button right at the page loading within 2 seconds

      Current Result

      a browser could show one of the following errors:

      error 1

      zkmax.barscanner.wpd:1650 Uncaught TypeError: Cannot read properties of undefined (reading 'data')
      at g (zkmax.barscanner.wpd:1650:31)
      at n (zkmax.barscanner.wpd:1663:46)
      at y (zkmax.barscanner.wpd:1664:8)
      at m (zkmax.barscanner.wpd:1668:50)
      at Object.start (zkmax.barscanner.wpd:1828:9)
      at Object._quaggaDecode [as decode] (zkmax.barscanner.wpd:13677:14)
      at zkmax.barscanner.wpd:13390:13
      at zkmax.barscanner.wpd:13431:15

      error 2

      zkmax.barscanner.wpd:13176 Uncaught TypeError: Cannot read properties of undefined (reading 'width')
      at init._setReaders (zkmax.barscanner.wpd:13176:50)
      at zkmax.barscanner.wpd:13232:13
      at zkmax.barscanner.wpd:13257:13

      Expected Result

      no error

      Debug Information

      • If you wait about 3 seconds and then click the remove button, the error doesn't happen.
        Because I found the reader doesn't start when a browser renders the page.

      if you set a breakpoint/logpoint in the line below:

          _quaggaDecode: function _quaggaDecode(wgt, reader) {
            reader.processing = true;
            reader.start(); //set log point here    
      },
      

      Check its calling stack trace, it runs by several asynchronous function like Promise, setTimeout(), setInterval(). So because _requestCamera() is an asynchronous call, it takes 2~3 seconds to start a reader, if you remove the barcodescanner component/widget before the internal reader is ready. It will produce the js error above.

      • From the use-case perspective, remove a barcodescanner immediately is a sort of unreasonable usage, so we treat this as low priority. Just record it the reference.

      Workaround


            Unassigned Unassigned
            hawk hawk
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: