Bug 245511 - The size of a video track's settings is incorrect in the second MediaStream created when the 'aspectRatio' contraint is applied
Summary: The size of a video track's settings is incorrect in the second MediaStream c...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebRTC (show other bugs)
Version: Safari 16
Hardware: All Unspecified
: P2 Normal
Assignee: Eric Carlson
URL: https://codesandbox.io/s/blissful-sno...
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-09-21 20:06 PDT by inanelit
Modified: 2022-11-07 17:16 PST (History)
9 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description inanelit 2022-09-21 20:06:55 PDT
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
Comment 1 Radar WebKit Bug Importer 2022-09-21 20:42:31 PDT
<rdar://problem/100254156>
Comment 2 Ahmad Saleem 2022-09-23 13:10:16 PDT
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!
Comment 3 Eric Carlson 2022-11-03 11:12:26 PDT
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.
Comment 4 Eric Carlson 2022-11-03 11:29:45 PDT
Pull request: https://github.com/WebKit/WebKit/pull/6093
Comment 5 EWS 2022-11-07 17:16:56 PST
Committed 256433@main (fc20b78a56dc): <https://commits.webkit.org/256433@main>

Reviewed commits have been landed. Closing PR #6093 and removing active labels.