Bug 258312 - getUserMedia produces different results for the same constraints
Summary: getUserMedia produces different results for the same constraints
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebRTC (show other bugs)
Version: Safari 16
Hardware: iPhone / iPad iOS 16
: P2 Major
Assignee: Nobody
URL: https://replit.com/@burzomir/iOS-165-...
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2023-06-20 11:14 PDT by burzomirdev
Modified: 2023-10-19 13:37 PDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description burzomirdev 2023-06-20 11:14:00 PDT
Video track constraints aren't correctly applied and calling getUserMedia two times in the row with the same constraints provides different results. First time camera tracks is in portrait orientation and ignores constraints that tell it should be landscape. Second time it looks like camera track in portrait orientation is cropped to match the constraints.

https://replit.com/@burzomir/iOS-165-getUserMedia-portrait-video-constraints-issue#index.html

To reproduce open this page on iOS 16.5: https://ios-165-getusermedia-portrait-video-constraints-issue.burzomir.repl.co

```
async function start(stopFirstStream) {
      const firstVideo = document.querySelector('#first-video')
      const secondVideo = document.querySelector('#second-video')

      const constraints = {
        video: {
          width: { ideal: 1280 },
          height: { ideal: 720 }
        }
      }

      const firstStream = await navigator.mediaDevices.getUserMedia(constraints)
      firstVideo.srcObject = firstStream

      // first stream provides a track in a portrait orientation
      // ignoring landscape constraints
      // if not stopped before getting the seconds stream
      // the video track provided by the second stream is cut to match constraints
      // tested on iPhone XS iOS 16.5
      if (stopFirstStream) {
        firstStream.getTracks().forEach(track => {
          track.stop()
        })
      }

      const secondStream = await navigator.mediaDevices.getUserMedia(constraints)
      secondVideo.srcObject = secondStream
    }
```
Comment 1 Radar WebKit Bug Importer 2023-06-27 11:14:17 PDT
<rdar://problem/111401777>
Comment 2 youenn fablet 2023-07-03 01:55:53 PDT
This does not repro for me on WebKit ToT using the link.
Would you be able to test it on iOS 17 beta?