If a webcam video stream is attached to a video element that is not rendered in the DOM, and then we render a video element with the same media constraints, that video element will have incorrect videoHeight and videoWidth. This issue repros in Safari 16 on desktop and mobile. For an example, go to https://codesandbox.io/s/blissful-snowflake-qdq6fo?file=/src/App.js and click "Show Webcam" In this example, a useEffect hook creates an unrendered video element and attaches a media stream to it. Clicking show webcam causes a second video element to be rendered using the same video constraints (not the same video stream), along with a canvas that we are drawing from the video to every second. The captured frame drawn on the canvas is distorted because videoHeight and videoWidth are incorrect. Webcam used was built-in webcam for M1 Macbook Pro
<rdar://problem/100254156>
I am able to reproduce this bug in Safari 16 and Safari Technology Preview 154 and the second stream video is distorted and like crushed or squeezed. While I am not able to reproduce this in Chrome Canary 108 and Firefox Nightly 107. Just wanted to update latest testing results. Thanks!
The bug is that the sections of the second video stream track are incorrect when the 'aspectRatio' constraint is used. The camera stream is captured at the correct size, but MediaTrackSettings.width and MediaTrackSettings.height have the values of the unconstrained width and height.
Pull request: https://github.com/WebKit/WebKit/pull/6093
Committed 256433@main (fc20b78a56dc): <https://commits.webkit.org/256433@main> Reviewed commits have been landed. Closing PR #6093 and removing active labels.