Closed Bug 1280449 Opened 8 years ago Closed 8 years ago

New style for getUserMedia constraints for video size doesn't work correctly

Categories

(Core :: WebRTC: Audio/Video, defect)

47 Branch
Unspecified
macOS
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 1180725

People

(Reporter: tsaregradskyi, Unassigned)

Details

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.84 Safari/537.36

Steps to reproduce:

Open any web page in Firefox and execute following code from console:

navigator.mediaDevices.getUserMedia({
		video: {
			width: { min: 1920, max: 1920 },
			height: { min: 1080, max: 1080 }
		}
	})
	.then(function(stream){
		let video = document.createElement('video');
		video.src = URL.createObjectURL(stream);
		video.onloadedmetadata = function() {
      			console.log('width is', this.videoWidth);
      			console.log('height is', this.videoHeight);
	    	};
		video.play();
		document.body.appendChild(video);
	})
	.catch(e => console.log(e));

See the video itself and console.log output.


Actual results:

Even if your camera doesn't support 1920x1080 resolution, console.log still logs it as 1920 and 1080.
Image from camera looks like it's interpolated.
If your camera doesn't support 16:9 aspect ratio (e.g. it has max resolution of 640x480), it's still reported as 1920x1080 and also it has distorted proportions.
Tried with Facetime HD camera on MacBook Pro 13" early 2011 and Logitech C170 webcam.


Expected results:

Ideally it should fail with "ConstraintNotSatisfiedError".
Or at least the result should be the same as using old-style syntax for constraints

navigator.mediaDevices.getUserMedia({
		video: {
			mandatory: { 
				minWidth: 1920, 
				maxWidth: 1920, 
				minHeight: 1080, 
				maxHeight: 1080 
			}
		}
	})
	.then(function(stream){
		let video = document.createElement('video');
		video.src = URL.createObjectURL(stream);
		video.onloadedmetadata = function() {
      			console.log('width is', this.videoWidth);
      			console.log('height is', this.videoHeight);
	    	};
		video.play();
		document.body.appendChild(video);
	})
	.catch(e => console.log(e));

In this case correct size is logged and no distortion occurs due to aspect ratio.
Component: Untriaged → Device Permissions
Component: Device Permissions → WebRTC: Audio/Video
Product: Firefox → Core
Can you re-try this with Nightly? We recently replaced the backend on mac with one that will tell us the camera's resolution, and that may be all that is needed.
Flags: needinfo?(tsaregradskyi)
Paging our resident gUM expert.
Flags: needinfo?(jib)
Tried with 50.0a1 (2016-06-17). Everything works! Thank you very much.
Status: UNCONFIRMED → RESOLVED
Closed: 8 years ago
Flags: needinfo?(tsaregradskyi)
Resolution: --- → WORKSFORME
Flags: needinfo?(jib)
Resolution: WORKSFORME → DUPLICATE
OS: Unspecified → Mac OS X
Fixed in 49 (Firefox DevEdition)
You need to log in before you can comment on or make changes to this bug.