cozmo / jsQR

A pure javascript QR code reading library. This library takes in raw images and will locate, extract and parse any QR code found within.
https://cozmo.github.io/jsQR/
Apache License 2.0
3.73k stars 607 forks source link

Can't read QR code on iOS16 #230

Open stcanbe opened 2 years ago

stcanbe commented 2 years ago

I am unable to read QR codes on iOS16.

const code = jsQR(imageData, width, height);

Each argument is set correctly, but the result is null. There is no error message. I was able to read QR codes until iOS15. Could anyone help me solve this problem?

sief commented 1 year ago

Same problem here. I doubt this has anything to do with this library. Looks to me like the autofocus is not working properly. I found several hints that this might be related to the iPhone's auto-macro option.:

https://developer.apple.com/forums/thread/715568 https://www.iphonetricks.org/camera-not-focusing-ios-16-issue-fix/ https://www.phoneswiki.com/ios-16-camera-app-issues/

The fix described here didn't solve the problem for me, I guess this only works for the native camera app. I also tried to set MediaTrackSettings.zoom, but apparently that's not supported by Safari/iOS.

@stcanbe have you tried to scan with the selfie camera on iOS 16?

stcanbe commented 1 year ago

@sief Thank you for your comment. I can read the QR code with my camera, but cannot read the QR code image from the album. I don't know if that has anything to do with the autofocus issue.

mp-pallain commented 1 year ago

This is also an issue for me... I am converting a pdf to a png and then getting my imagedata, width and height. it is working in 90%+ of cases but sometimes i am getting null.. I am able to use my phone to get the data from the qr code.. would be great if anybody has in suggestions. currently when i get this null value i have it set up to create a ticket and from there i manually intervene.

luBubble commented 1 year ago

我是在HTMLImageElement元素发送onload通知后,将HTMLImageElement元素转成imageData进行识别,在ios16中大概率识别失败,猜测是onload时机有问题,所以我做了一个处理,在onload通知发送后,延迟50ms进行imageData获取以及二维码识别,成功解决了这个问题,如果你们的识别逻辑也依赖onload事件,可以试试这个办法