LazarSoft / jsqrcode

Javascript QRCode scanner
http://www.webqr.com
Apache License 2.0
3.96k stars 1.16k forks source link

Fixed infinite-loop when >3 centres #45

Closed invertedtomato closed 8 years ago

invertedtomato commented 9 years ago

Infinite loop caused when more than 3 centres are found in image. Occurs often when more than one QR code is in view.

fantaclaus commented 7 years ago

@invertedtomato Could you please explain how had you achieved the infinite-loop here? On which platform? I can not reproduce such behavior. I guess it is impossible at all.

Also I have another question. You have removed this condition: this.possibleCenters.length > 3. So, now it is possible that less than three or even none of the centers would remain in the array. But according to the old code (and to the original code in ZXing library) the function must return an array of exactly three best centers or throw an exception. Have I missed something here?

invertedtomato commented 7 years ago

Hey fantaclaus. It's been a long time since I made this comment - apologies, I can't recall the particulars. The issue was occurring when I was scanning an image that had multiple QR codes in view. Approximately 90% of cases resulted in the code infinite looping.

I understand my fix was not perfect (I was in a rush). Sounds like you're in a prime position to make a better fix :).

As long as it safely rejects scans with multiple QRs in view, then I'm happy.