quagga2 icon indicating copy to clipboard operation
quagga2 copied to clipboard

Invalid typed array length when using resolution 1920+ ? Investigate

Open ericblade opened this issue 4 years ago • 1 comments

From https://github.com/serratus/quaggaJS/issues/432

The screencap in the source issue indicates that a 36864 size array is out of bounds, somehow. According to MDN, typed arrays should be able to accept any positive number up to 2^32. I wonder if it's somehow using a signed 16-bit number somewhere, so a size that creates an array larger than 32k causes it to attempt to initialize negative... that .. doesn't make much sense, but it's all i can think of right off hand.

Should be able to see it fail using the sample app, I know it fails when set to 1920 no matter the actual resolution of the image you feed it. It might be possible that one of our changes in this lib since the fork has fixed it, if not, it probably should be fixed.

It'd be good if we could get a sample barcode image that was that high a resolution or higher, so we could make sure it works, or at least doesn't break.

ericblade avatar May 04 '20 07:05 ericblade

https://github.com/serratus/quaggaJS/issues/432#issuecomment-624909077

Looks like it's an issue in the library, due to needing a much larger image inside barcode_locator#initBuffers than what is presently allowed.

I'm not sure if that's a great solution just blindly increasing the size there, we should probably try to understand what the code is doing, as well as write a test for it, before we go plugging in new magic numbers. (also, i hate magic numbers, so it probably should be refactored to fit what is necessary at the time, rather than an arbitrary 64k or 256k or whatever, buffer)

ericblade avatar May 07 '20 01:05 ericblade