instascan icon indicating copy to clipboard operation
instascan copied to clipboard

Invalid asm.js: Type mismatch in assignment [instascan.min.js]:18

Open Bwest981 opened this issue 5 years ago • 16 comments

I can't get my QR code scanner to function properly using another android application webview. This is the issue that displays for me.

Also, when I select to start my camera, I get a Uncaught (in promise) {name: "NotAllowedError", message: "Permission denied", constraint: undefined, toString: ƒ}.

Bwest981 avatar Aug 01 '18 21:08 Bwest981

I have now the exactly same problem!

Still works fine on Laptop Lenovo ThinkPad, Windows 10, Google Chrome Version 69.0.3497.100 (64-Bit)

Did work fine a few months ago on Google Chrome Android Version ??? @ Sony Xperia Z3 compact Andriod Version 6.0.1

Does NOT work any more on Google Chrome Android Version 69.0.3497.100, problem near to scanner.start: Invalid asm.js: Type mismatch in assignment qr.html:1 Uncaught (in promise) {name: "NotAllowedError", message: "Permission denied", constraint: undefined, toString: ƒ} Promise.then (async) E.async @ instascan.min.js:7 value @ instascan.min.js:9

Instascan is really cool! I would highly appreciate if this could be fixed :-)

HerbertDobernig avatar Oct 13 '18 05:10 HerbertDobernig

I used https domain up to now, Now I tried to explicitely refernce https domain in <script .... > but this did NOT solve the problem:

HerbertDobernig avatar Oct 13 '18 06:10 HerbertDobernig

Not working on Android Firefox 62.0.1 as well

HerbertDobernig avatar Oct 13 '18 06:10 HerbertDobernig

Working well on Android Opera 47.3.2249.130976 Working well on Android Edge 42.0.0.2549

HerbertDobernig avatar Oct 21 '18 13:10 HerbertDobernig

I think this was a uglifyJS issue, building instascan.min.js new with gulp release seems to fix this.

chris-gunawardena avatar Nov 17 '18 15:11 chris-gunawardena

I think this was a uglifyJS issue, building instascan.min.js new with gulp release seems to fix this.

Thanks! This solved the problem on my mobile phone Sony Xperia Z3 compact Andriod Version 6.0.1 Google Chrome Android Version 69.0.3497.100 Android Firefox 62.0.1

HerbertDobernig avatar Nov 17 '18 20:11 HerbertDobernig

can anyone share the gulp release minify result :(

bagus-setyawan avatar Dec 13 '18 07:12 bagus-setyawan

I couldn't build it with gulp v4 - some seemingly minor changes would be needed to the gulpfile.js I could build it with gulp v.3.9.1, but it seems the gulp-uglify still breaks it. I removed the uglify lines from the gulpfile and this error went away, at the cost of a bigger instascan.js file (~+1MB) But even so, as mentioned in #197, it's still got problems with "createObjectURL"

Edit: Found a file from comment #139 . That worked, even though it still hat the "Invalid asm" error. Thanks also to chrisgunawardena

mjcapper avatar Dec 13 '18 09:12 mjcapper

Here is the minified file: https://gist.github.com/chris-gunawardena/15d507d11dc09ef8f7653f1005eda203

chris-gunawardena avatar Dec 13 '18 09:12 chris-gunawardena

Thanks chris, but the version you linked to causes the error "Camera is not defined." (all else the same).

mjcapper avatar Dec 13 '18 10:12 mjcapper

You need to wait until its initialized. This is what I use:

const initQrCodeScanner = () => {
  let scanner = new Instascan.Scanner({ video: document.getElementById('preview') });
  Instascan.Camera.getCameras().then(cameras => {
    scanner.camera = cameras[cameras.length - 1];
    scanner.start();
  }).catch(console.error);

  scanner.addListener('scan', content => {
    scanner.stop();
    try { window.location.hash = new URL(content).hash } catch (e) { console.log(e) }
  });

};

chris-gunawardena avatar Dec 13 '18 10:12 chris-gunawardena

Hello. Please help a noob. Everything was working for me using the example and release v 1.0.0 and then I closed my computer, opened it up again, and suddenly I was getting the CreateObjectUrl problem.

So then I used the minified file pointed to in this thread, and now I get the "Camera is not defined" error just like mjcapper.

I tried to do what chris-gunawardena did (copied and pasted exactly), and now there are no errors but also there is no video on the camera.

It was working perfectly last night!! (maybe my Chrome browser had an update in the meantime? Dunno).

So I'm very frustrated. Also, for the record, I'm developing on localhost, camera was working before, is this because chrome updated? My version says:

Version 71.0.3578.98 (Official Build) (64-bit)

I also tried on IE and I can't get video. No errors, but also no video.

Help please. :(

epasquali avatar Dec 18 '18 09:12 epasquali

Working example on chrome: https://codepen.io/chris-gunawardena/pen/REGQPR?editors=1111

chris-gunawardena avatar Dec 18 '18 10:12 chris-gunawardena

It was working on all the browsers (Safari, Chrome on Mac an on Chrome Android). At the moment it works only on Firefox on Mac. On Firefox mobile is not working.

I'd like a a step by step info (for noobs) about how to fix using minfy/uglyJs/gulp. Thank you.

EDIT: it doesn't matter anymore. What I said is till true about the example privided in the main page. However the previous posted example https://codepen.io/chris-gunawardena/pen/REGQPR?editors=1111 actually fixes the problem.

tonyx avatar Dec 21 '18 14:12 tonyx

I am able to make it work by using the file from the demo page: https://schmich.github.io/instascan/ Here is the file link: https://rawgit.com/schmich/instascan-builds/master/instascan.min.js

linckosz avatar Jan 18 '19 21:01 linckosz

Working example on chrome: https://codepen.io/chris-gunawardena/pen/REGQPR?editors=1111

do I need an SSL certificate to get this to work? 'coz it works fine in localhost but not in a live webhosting without an SSL certification.

marwinxtra avatar Oct 26 '20 11:10 marwinxtra