ericblade / quagga2

An advanced barcode-scanner written in Javascript and TypeScript - Continuation from https://github.com/serratus/quaggajs
MIT License
766 stars 85 forks source link

Invalid asm.js: Unexpected token. (In skeletonize.js) #414

Open FlyveHest opened 2 years ago

FlyveHest commented 2 years ago

When I am using the latest (1.6.0) version of Quagga2, I am getting a Invalid asm.js: Unexpected token warning when starting Quagga.

The error seems to occur in skeletonize line 14, inImagePtr |= 0;, at least thats what Chrome is telling me.

The parsing part of Quagga works, though, and I can scan barcodes just fine, what doesn't work is using the onProcessed function to draw bounding boxes around the barcodes, as is done in the example.

I tried using the same version of quagga as the example does, and it works as expected, no asm.js errors, so I kept on downgrading, and when I came to v1.1.0 the functionality started working again.

Furthermore, using the latest version and logging the result variable from onProcessed just gives me an empty array instead of the expcted result object.

Running in Chrome 100.0.4896.127

github-actions[bot] commented 2 years ago

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

ericblade commented 2 years ago

OK, there's a couple of issues here, and I don't think they are related -- but if you can help me prove they are (or aren't) that would be great!

I use onProcessed in my code, and I also get that same Invalid asm.js when running my application on Chrome, so I don't believe your issue and the Asm.js error are related. It's my understanding that that error is thrown when Chrome doesn't understand the Asm.js code, and then it runs it in normal mode instead of Asm mode, or something similar to that. Also the Asm.js error has occurred for me since before I forked this project, when running in Chrome.

It would be really helpful if you could provide an example of the code (and hopefully a barcode sample) that displays a functional difference between 1.6.0 and 1.1.0 -- if there's a particular case that doesn't work now that should, that needs to be fixed.

Releases tend to get tested pretty thoroughly -- for the features I personally use -- as I use Quagga2 in a webapp that is vital to my business, and several other people do as well. It is also used in a few other fairly successful applications out there.

That said, it's very possible that some functionality that did work in 1.1.0 but was never being tested by either automated testing, or my own application's usage, and has broken now.

So sample code would be very helpful at helping to track it down. Thank you very much!!

FlyveHest commented 2 years ago

If you take the example from the repo, live_w_locator.html, and switch the following line

<script src="../dist/quagga.js" type="text/javascript"></script>

for either

<script src="https://cdn.jsdelivr.net/npm/@ericblade/quagga2@1.1.0/dist/quagga.js"></script> or <script src="https://cdn.jsdelivr.net/npm/@ericblade/quagga2@1.6.0/dist/quagga.js"></script>

you can see that when using 1.1.0 you get the green bounding boxes on the livestream, and when using 1.6.0 you do not.

Adding console.log(result); inside the if (result) { scope in Quagga.onProcessed(function(result) in live_w_locator.js and I get an array of objects with boxes definitions using 1.1.0, but when I use 1.6.0 I just get empty arrays.

ericblade commented 2 years ago

@FlyveHest Can you provide what settings you are performing this with, and perhaps an image of a barcode or two?

FlyveHest commented 2 years ago

Settings are the default settings in the live_w_locator.html page, I didn't change anything other than the version of the quagga library.

Barcode image attached below.

image

ericblade commented 2 years ago

Thanks! I'll give this a spin when I can and see what I can find out.

ericblade commented 2 years ago

good news re: Asm.js error, sort of: asm.js error is basically a warning. It just runs the code as javascript since it can't interpret it properly into what it's looking for. bad news, although i can fix the one in this code, after i fix up several of them, i end up with one that the original author wrote which is also invalid, and i don't have any idea how to fix it, and information about asm.js is pretty sparse these days.

ericblade commented 2 years ago

so... on this particular barcode, i'm only able to actually decode it after i doctor the image by converting it to grayscale first, and then feeding these settings

image

it looks like it works. i'm not seeing issues with onProcessed .. unless i just don't understand the issue