You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Support Safari 12.1, fix canvas leak, and improve recognition
https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/srcObject
On Safari 12 (and indeed later verisons of other browsers), the `video.src =
URL.createObjectURL(mediaStream);` syntax is deprecated. Instead, it's
been replaced by `video.srcObject`.
However, using the srcObject syntax also lead to hundreds of individual canvases
being created in Safari 12.1. This used lots of memory, slowing the app, and
Safari then stopped the website from creating further canvasses and scanning
failed to work. The longer the video preview was open the worse things became.
This version of the code now uses a single canvas for rendering, rather than
relying on garbage collection to clean them up over time.
Additionally, Safari requires a new `playsinline` attribute for the display
element in the html.
Additionally, I found that on Safari 12.1 with an iPhone 6s plus, the generated
image was vertically `squished`, and the bar-code wouldn't be recognised as it
was not square. This changes the code to use the rendered window size for the
canvas, rather than what the camera has been detected as. This seems to
dramatically improve QR code recognition.
0 commit comments