Browse Source

fix(safari): override min/max video constraints on safari (#1243)

* fix(safari): override min/max video constraints on safari
Override the constraints on Safari because of the following webkit bug.
https://bugs.webkit.org/show_bug.cgi?id=210932
Camera doesn't start on older macOS versions if min/max constraints are specified.
master
Jaya Allamsetty 5 years ago
parent
commit
fb997564a6
No account linked to committer's email address
2 changed files with 19 additions and 2 deletions
  1. 18
    2
      modules/RTC/RTCUtils.js
  2. 1
    0
      package.json

+ 18
- 2
modules/RTC/RTCUtils.js View File

10
 import CameraFacingMode from '../../service/RTC/CameraFacingMode';
10
 import CameraFacingMode from '../../service/RTC/CameraFacingMode';
11
 import EventEmitter from 'events';
11
 import EventEmitter from 'events';
12
 import { getLogger } from 'jitsi-meet-logger';
12
 import { getLogger } from 'jitsi-meet-logger';
13
+import clonedeep from 'lodash.clonedeep';
13
 import GlobalOnErrorHandler from '../util/GlobalOnErrorHandler';
14
 import GlobalOnErrorHandler from '../util/GlobalOnErrorHandler';
14
 import JitsiTrackError from '../../JitsiTrackError';
15
 import JitsiTrackError from '../../JitsiTrackError';
15
 import Listenable from '../util/Listenable';
16
 import Listenable from '../util/Listenable';
374
 function newGetConstraints(um = [], options = {}) {
375
 function newGetConstraints(um = [], options = {}) {
375
     // Create a deep copy of the constraints to avoid any modification of
376
     // Create a deep copy of the constraints to avoid any modification of
376
     // the passed in constraints object.
377
     // the passed in constraints object.
377
-    const constraints = JSON.parse(JSON.stringify(
378
-        options.constraints || DEFAULT_CONSTRAINTS));
378
+    const constraints = clonedeep(options.constraints || DEFAULT_CONSTRAINTS);
379
 
379
 
380
     if (um.indexOf('video') >= 0) {
380
     if (um.indexOf('video') >= 0) {
381
         if (!constraints.video) {
381
         if (!constraints.video) {
382
             constraints.video = {};
382
             constraints.video = {};
383
         }
383
         }
384
 
384
 
385
+        // Override the constraints on Safari because of the following webkit bug.
386
+        // https://bugs.webkit.org/show_bug.cgi?id=210932
387
+        // Camera doesn't start on older macOS versions if min/max constraints are specified.
388
+        // TODO: remove this hack when the bug fix is available on Mojave, Sierra and High Sierra.
389
+        if (browser.isSafari()) {
390
+            if (constraints.video.height && constraints.video.height.ideal) {
391
+                constraints.video.height = { ideal: clonedeep(constraints.video.height.ideal) };
392
+            } else {
393
+                logger.warn('Ideal camera height missing, camera may not start properly');
394
+            }
395
+            if (constraints.video.width && constraints.video.width.ideal) {
396
+                constraints.video.width = { ideal: clonedeep(constraints.video.width.ideal) };
397
+            } else {
398
+                logger.warn('Ideal camera width missing, camera may not start properly');
399
+            }
400
+        }
385
         if (options.cameraDeviceId) {
401
         if (options.cameraDeviceId) {
386
             constraints.video.deviceId = options.cameraDeviceId;
402
             constraints.video.deviceId = options.cameraDeviceId;
387
         } else {
403
         } else {

+ 1
- 0
package.json View File

22
     "current-executing-script": "0.1.3",
22
     "current-executing-script": "0.1.3",
23
     "jitsi-meet-logger": "github:jitsi/jitsi-meet-logger#5ec92357570dc8f0b7ffc1528820721c84c6af8b",
23
     "jitsi-meet-logger": "github:jitsi/jitsi-meet-logger#5ec92357570dc8f0b7ffc1528820721c84c6af8b",
24
     "js-utils": "github:jitsi/js-utils#cf11996bd866fdb47326c59a5d3bc24be17282d4",
24
     "js-utils": "github:jitsi/js-utils#cf11996bd866fdb47326c59a5d3bc24be17282d4",
25
+    "lodash.clonedeep": "4.5.0",
25
     "lodash.isequal": "4.5.0",
26
     "lodash.isequal": "4.5.0",
26
     "sdp-transform": "2.3.0",
27
     "sdp-transform": "2.3.0",
27
     "strophe.js": "1.3.4",
28
     "strophe.js": "1.3.4",

Loading…
Cancel
Save