Bug 174810 - videoWidth and videoHeight are 0 when using Mock Capture Devices and a muted video track
Summary: videoWidth and videoHeight are 0 when using Mock Capture Devices and a muted ...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Media (show other bugs)
Version: Safari Technology Preview
Hardware: Mac macOS 10.12.4
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-07-24 20:33 PDT by Adam
Modified: 2017-07-27 13:47 PDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Adam 2017-07-24 20:33:56 PDT
If you have a muted video track with real devices you still get the correct videoWidth and videoHeight on the video element. However if you are using the Mock Capture Devices then you get 0x0.

Here is some sample code to reproduce the problem: https://output.jsbin.com/kokeqob

navigator.mediaDevices.getUserMedia({
  audio: true,
  video: true
}).then(stream => {
  stream.getVideoTracks()[0].enabled = false;
  const vid = document.createElement('video');
  vid.srcObject = stream;
  document.body.appendChild(vid);
  checkVideoDimensions(vid);
  vid.play();
}).catch(err => {
  console.error(err);
});

function checkVideoDimensions(vid) {
  const showDimensions = () => {
    videoWidth.innerHTML = vid.videoWidth;
    videoHeight.innerHTML = vid.videoHeight;
  };
  
  vid.addEventListener('loadedmetadata', showDimensions);
  vid.addEventListener('timeupdate', showDimensions);
  setInterval(showDimensions, 2000);
}

If you visit that URL and allow access to your camera using real devices you will see that videoWidth and videoHeight are 640x480. However if you choose the Mock Capture Devices option then you get 0x0.
Comment 1 Radar WebKit Bug Importer 2017-07-27 13:47:42 PDT
<rdar://problem/33575504>