Bug 212733 - [iOS] applyConstraints should take into account rotation when computing width and height for video tracks
Summary: [iOS] applyConstraints should take into account rotation when computing width...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebRTC (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-06-04 02:05 PDT by youenn fablet
Modified: 2022-12-30 22:09 PST (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description youenn fablet 2020-06-04 02:05:59 PDT
[iOS] applyConstraints should take into account rotation when computing width and height for video tracks
Comment 1 milen 2021-08-05 09:02:18 PDT
This issue causes applyConstraints() to be not usable at all in our case.
The case is:

1) Get HD video.
2) Show preview.
3) Later switch to SD video. 

Tested on iPhone SE with iOS 14.7.1 in portrait orientation.
In landscape orientation the case works fine.

The result is:
The HD video preview is good. (the preview is in portrait orientation)
The SD video preview is cropped. (the preview is in landscape orientation even the phone is in portrait)

This is the code to reproduce the issue:
-----
let constraintsHD = {
    width: {ideal: 1280},
    height: {ideal: 720},
};

let constraintsSD = {
    width: {ideal: 640},
    height: {ideal: 360},
};

navigator.mediaDevices.getUserMedia({video: constraintsHD, audio: false})
.then(stream => {

    setTimeout(() => {
        let videoTrack = stream.getVideoTracks()[0];
        console.log("SETTINGS HD: ", videoTrack.getSettings());
    }, 1000);
    
    setTimeout(() => {
        let videoTrack = stream.getVideoTracks()[0];
        videoTrack.applyConstraints(constraintsSD).then(() => {
            let settings = videoTrack.getSettings();
            console.log("SETTINGS SD: ", videoTrack.getSettings());
        })
    }, 3000);
});
-----

It logs:
Settings HD: height: 1280, width: 720
Settings SD: height: 360, width: 640

As a workaround we don't use applyConstraints() and always use SD video on iOS.
The same case works fine in Chrome/Android.
Comment 2 Davy De Durpel 2021-11-05 02:54:48 PDT
I'm facing the same issue.  In our case we want to reduce the size of the video when we move it in PiP.  This allows us to reduce lots of bandwidth and as such reduce our carbon footprint to save mother planet :-)
Comment 3 Levi Li 2022-12-30 22:09:40 PST
I'm facing the same issue too