WebRTC `getUserMedia` api return stream swapped height and width randomly

Environment: iPhone 13/14, iOS 16, Chrome, Safari

Description: We use WebRTC api to stream camera to <video>. We did some business logics according to stream's width and height. But the height and width value swapped randomly.

Expected result: video stream height is always larger than width on portrait mode.

Actual result: video stream width height swapped randomly.

How to reproduce: 1.Visit on mobile https://yari-demos.prod.mdn.mozit.cloud/en-US/docs/Web/API/Media_Capture_and_Streams_API/Constraints/_sample_.Example_Constraint_exerciser.html

  1. Click start button above "Requested video constraints:"
  2. See the outputs in "Actual video settings":

"height" is larger than "width" in portrait mode

  1. Repeat clicking start button and see the outputs multiple times.

You can see "height" will be smaller than "width"

I am also suffering from the same problem. Have you found any good solutions?

The Problem persists and breaks our video support solution. The behaviour appears to be deterministic when the stream and track is stopped before requesting a new one. Which is less than ideal since IOS takes a lot of time to re-request the same camera for some reason. Not sure if this should rather be reported to Safari. Here clearly nobody cares..

WebRTC `getUserMedia` api return stream swapped height and width randomly
 
 
Q