gruhn / vue-qrcode-reader

A set of Vue.js components for detecting and decoding QR codes.
https://gruhn.github.io/vue-qrcode-reader
MIT License
2.03k stars 330 forks source link

can't open the camera in wechat browser ,iOS system #375

Closed bububear closed 9 months ago

bububear commented 9 months ago

Describe the bug Can't open the camera in Wechat browser ,iOS system reproduce this issue with one of the demos

To Reproduce One of the demos : https://vue-qrcode-reader.netlify.app/demos/ScanSameQrcodeMoreThanOnce.html

Screenshots 4a6a73dbb853bce91bee3f227f19255

Smartphone (please complete the following information):

Sec-ant commented 9 months ago

This looks like a WebRTC issue in WKWebView on early iOS devices:

bububear commented 9 months ago

On the basis of iOS 14.3 and later, the camera still cannot be turned on.

Sec-ant commented 9 months ago

I just remembered I have an iPhone SE 1st generation and I successfully reproduced this problem.

Upload three videos for demonstration:

https://github.com/gruhn/vue-qrcode-reader/assets/10386119/a1054054-23f9-48ae-977e-383d7bffac2d

https://github.com/gruhn/vue-qrcode-reader/assets/10386119/460b98be-b24d-493e-9015-9b8b86732593

https://github.com/gruhn/vue-qrcode-reader/assets/10386119/55bf92ce-de07-4a5b-882b-7bd9556db16a

iOS 15.5, Safari 15.5, WebKit 6613.2.7

I may do some debugging when I have time. Though it's not easy because I don't have a mac.


A relevant link (maybe): http://www.zhigushu.com/a/12389

Translated to English with AI:

When calling navigator.mediaDevices.getUserMedia to access the camera for facial recognition, it works on both Android's WeChat and browsers. However, on iOS, it only works in the browser, as the WeChat app displays a white screen.

During testing, getUserMedia is effective, but it was discovered that due to the lack of support for the onloadedmetadata event, the video cannot be played(). Therefore, an alternative approach was implemented by adding an event listener, canplay, where the video capture operation is executed. In this case, video.play() is called directly within the getUserMedia event.

Sec-ant commented 9 months ago

Adding this line of code

videoEl.play()

before awaiting Promise.race seems to fix this problem:

https://github.com/gruhn/vue-qrcode-reader/assets/10386119/b56a5454-50d0-47eb-a743-bd5b594de248

github-actions[bot] commented 9 months ago

:tada: This issue has been resolved in version 5.3.6 :tada:

The release is available on:

Your semantic-release bot :package::rocket: