Browse Source

fix(gum) add event handling for SLOW_GET_USER_MEDIA

Show an overlay with a spinner when slow gUM is fired
master
Tudor-Ovidiu Avram 4 years ago
parent
commit
f50fd7b7bd

+ 28
- 13
conference.js View File

@@ -115,7 +115,7 @@ import {
115 115
     submitFeedback
116 116
 } from './react/features/feedback';
117 117
 import { showNotification } from './react/features/notifications';
118
-import { mediaPermissionPromptVisibilityChanged } from './react/features/overlay';
118
+import { mediaPermissionPromptVisibilityChanged, toggleSlowGUMOverlay } from './react/features/overlay';
119 119
 import { suspendDetected } from './react/features/power-monitor';
120 120
 import {
121 121
     initPrejoin,
@@ -502,6 +502,11 @@ export default {
502 502
             );
503 503
         }
504 504
 
505
+        JitsiMeetJS.mediaDevices.addEventListener(
506
+            JitsiMediaDevicesEvents.SLOW_GET_USER_MEDIA,
507
+            () => APP.store.dispatch(toggleSlowGUMOverlay(true))
508
+        );
509
+
505 510
         let tryCreateLocalTracks;
506 511
 
507 512
         // On Electron there is no permission prompt for granting permissions. That's why we don't need to
@@ -519,8 +524,10 @@ export default {
519 524
 
520 525
                     return createLocalTracksF({
521 526
                         devices: [ 'audio' ],
522
-                        timeout
523
-                    }, true)
527
+                        timeout,
528
+                        firePermissionPromptIsShownEvent: true,
529
+                        fireSlowPromiseEvent: true
530
+                    })
524 531
                         .then(([ audioStream ]) =>
525 532
                             [ desktopStream, audioStream ])
526 533
                         .catch(error => {
@@ -536,8 +543,10 @@ export default {
536 543
                     return requestedAudio
537 544
                         ? createLocalTracksF({
538 545
                             devices: [ 'audio' ],
539
-                            timeout
540
-                        }, true)
546
+                            timeout,
547
+                            firePermissionPromptIsShownEvent: true,
548
+                            fireSlowPromiseEvent: true
549
+                        })
541 550
                         : [];
542 551
                 })
543 552
                 .catch(error => {
@@ -551,8 +560,10 @@ export default {
551 560
         } else {
552 561
             tryCreateLocalTracks = createLocalTracksF({
553 562
                 devices: initialDevices,
554
-                timeout
555
-            }, true)
563
+                timeout,
564
+                firePermissionPromptIsShownEvent: true,
565
+                fireSlowPromiseEvent: true
566
+            })
556 567
                 .catch(err => {
557 568
                     if (requestedAudio && requestedVideo) {
558 569
 
@@ -574,8 +585,10 @@ export default {
574 585
                         return (
575 586
                             createLocalTracksF({
576 587
                                 devices: [ 'audio' ],
577
-                                timeout
578
-                            }, true));
588
+                                timeout,
589
+                                firePermissionPromptIsShownEvent: true,
590
+                                fireSlowPromiseEvent: true
591
+                            }));
579 592
                     } else if (requestedAudio && !requestedVideo) {
580 593
                         errors.audioOnlyError = err;
581 594
 
@@ -598,8 +611,9 @@ export default {
598 611
                     return requestedVideo
599 612
                         ? createLocalTracksF({
600 613
                             devices: [ 'video' ],
601
-                            timeout
602
-                        }, true)
614
+                            firePermissionPromptIsShownEvent: true,
615
+                            fireSlowPromiseEvent: true
616
+                        })
603 617
                         : [];
604 618
                 })
605 619
                 .catch(err => {
@@ -619,6 +633,7 @@ export default {
619 633
         // the user inputs their credentials, but the dialog would be
620 634
         // overshadowed by the overlay.
621 635
         tryCreateLocalTracks.then(tracks => {
636
+            APP.store.dispatch(toggleSlowGUMOverlay(false));
622 637
             APP.store.dispatch(mediaPermissionPromptVisibilityChanged(false));
623 638
 
624 639
             return tracks;
@@ -882,7 +897,7 @@ export default {
882 897
                 showUI && APP.store.dispatch(notifyMicError(error));
883 898
             };
884 899
 
885
-            createLocalTracksF({ devices: [ 'audio' ] }, false)
900
+            createLocalTracksF({ devices: [ 'audio' ] })
886 901
                 .then(([ audioTrack ]) => audioTrack)
887 902
                 .catch(error => {
888 903
                     maybeShowErrorDialog(error);
@@ -996,7 +1011,7 @@ export default {
996 1011
             //
997 1012
             // FIXME when local track creation is moved to react/redux
998 1013
             // it should take care of the use case described above
999
-            createLocalTracksF({ devices: [ 'video' ] }, false)
1014
+            createLocalTracksF({ devices: [ 'video' ] })
1000 1015
                 .then(([ videoTrack ]) => videoTrack)
1001 1016
                 .catch(error => {
1002 1017
                     // FIXME should send some feedback to the API on error ?

+ 8
- 0
css/overlay/_overlay.scss View File

@@ -33,4 +33,12 @@
33 33
         bottom: 24px;
34 34
         width: 100%;
35 35
     }
36
+
37
+    &__spinner-container {
38
+        display: flex;
39
+        width: 100%;
40
+        height: 100%;
41
+        justify-content: center;
42
+        align-items: center;
43
+    }
36 44
 }

+ 2
- 2
package-lock.json View File

@@ -10343,8 +10343,8 @@
10343 10343
       }
10344 10344
     },
10345 10345
     "lib-jitsi-meet": {
10346
-      "version": "github:jitsi/lib-jitsi-meet#7f919faaccb268ef307d619992260919a6535e95",
10347
-      "from": "github:jitsi/lib-jitsi-meet#7f919faaccb268ef307d619992260919a6535e95",
10346
+      "version": "github:jitsi/lib-jitsi-meet#c534f748849a308d08b06e306f5a66709ccae056",
10347
+      "from": "github:jitsi/lib-jitsi-meet#c534f748849a308d08b06e306f5a66709ccae056",
10348 10348
       "requires": {
10349 10349
         "@jitsi/js-utils": "1.0.2",
10350 10350
         "@jitsi/sdp-interop": "1.0.3",

+ 1
- 1
package.json View File

@@ -56,7 +56,7 @@
56 56
     "jquery-i18next": "1.2.1",
57 57
     "js-md5": "0.6.1",
58 58
     "jwt-decode": "2.2.0",
59
-    "lib-jitsi-meet": "github:jitsi/lib-jitsi-meet#7f919faaccb268ef307d619992260919a6535e95",
59
+    "lib-jitsi-meet": "github:jitsi/lib-jitsi-meet#c534f748849a308d08b06e306f5a66709ccae056",
60 60
     "libflacjs": "github:mmig/libflac.js#93d37e7f811f01cf7d8b6a603e38bd3c3810907d",
61 61
     "lodash": "4.17.19",
62 62
     "moment": "2.19.4",

+ 0
- 1
react/features/base/tracks/actions.js View File

@@ -127,7 +127,6 @@ export function createLocalTracksA(options = {}) {
127 127
                             options.facingMode || CAMERA_FACING_MODE.USER,
128 128
                         micDeviceId: options.micDeviceId
129 129
                     },
130
-                    /* firePermissionPromptIsShownEvent */ false,
131 130
                     store)
132 131
                 .then(
133 132
                     localTracks => {

+ 27
- 8
react/features/base/tracks/functions.js View File

@@ -63,16 +63,25 @@ export async function createLocalPresenterTrack(options, desktopHeight) {
63 63
  * @param {string|null} [options.micDeviceId] - Microphone device id or
64 64
  * {@code undefined} to use app's settings.
65 65
  * @param {number|undefined} [oprions.timeout] - A timeout for JitsiMeetJS.createLocalTracks used to create the tracks.
66
- * @param {boolean} [firePermissionPromptIsShownEvent] - Whether lib-jitsi-meet
66
+ * @param {boolean} [options.firePermissionPromptIsShownEvent] - Whether lib-jitsi-meet
67 67
  * should check for a {@code getUserMedia} permission prompt and fire a
68 68
  * corresponding event.
69
+ * @param {boolean} [options.fireSlowPromiseEvent] - Whether lib-jitsi-meet
70
+ * should check for a slow {@code getUserMedia} request and fire a
71
+ * corresponding event.
69 72
  * @param {Object} store - The redux store in the context of which the function
70 73
  * is to execute and from which state such as {@code config} is to be retrieved.
71 74
  * @returns {Promise<JitsiLocalTrack[]>}
72 75
  */
73
-export function createLocalTracksF(options = {}, firePermissionPromptIsShownEvent, store) {
76
+export function createLocalTracksF(options = {}, store) {
74 77
     let { cameraDeviceId, micDeviceId } = options;
75
-    const { desktopSharingSourceDevice, desktopSharingSources, timeout } = options;
78
+    const {
79
+        desktopSharingSourceDevice,
80
+        desktopSharingSources,
81
+        firePermissionPromptIsShownEvent,
82
+        fireSlowPromiseEvent,
83
+        timeout
84
+    } = options;
76 85
 
77 86
     if (typeof APP !== 'undefined') {
78 87
         // TODO The app's settings should go in the redux store and then the
@@ -114,11 +123,12 @@ export function createLocalTracksF(options = {}, firePermissionPromptIsShownEven
114 123
                     devices: options.devices.slice(0),
115 124
                     effects,
116 125
                     firefox_fake_device, // eslint-disable-line camelcase
126
+                    firePermissionPromptIsShownEvent,
127
+                    fireSlowPromiseEvent,
117 128
                     micDeviceId,
118 129
                     resolution,
119 130
                     timeout
120
-                },
121
-                firePermissionPromptIsShownEvent)
131
+                })
122 132
             .catch(err => {
123 133
                 logger.error('Failed to create local tracks', options.devices, err);
124 134
 
@@ -161,7 +171,10 @@ export function createPrejoinTracks() {
161 171
         // Resolve with no tracks
162 172
         tryCreateLocalTracks = Promise.resolve([]);
163 173
     } else {
164
-        tryCreateLocalTracks = createLocalTracksF({ devices: initialDevices }, true)
174
+        tryCreateLocalTracks = createLocalTracksF({
175
+            devices: initialDevices,
176
+            firePermissionPromptIsShownEvent: true
177
+        })
165 178
                 .catch(err => {
166 179
                     if (requestedAudio && requestedVideo) {
167 180
 
@@ -169,7 +182,10 @@ export function createPrejoinTracks() {
169 182
                         errors.audioAndVideoError = err;
170 183
 
171 184
                         return (
172
-                            createLocalTracksF({ devices: [ 'audio' ] }, true));
185
+                            createLocalTracksF({
186
+                                devices: [ 'audio' ],
187
+                                firePermissionPromptIsShownEvent: true
188
+                            }));
173 189
                     } else if (requestedAudio && !requestedVideo) {
174 190
                         errors.audioOnlyError = err;
175 191
 
@@ -190,7 +206,10 @@ export function createPrejoinTracks() {
190 206
 
191 207
                     // Try video only...
192 208
                     return requestedVideo
193
-                        ? createLocalTracksF({ devices: [ 'video' ] }, true)
209
+                        ? createLocalTracksF({
210
+                            devices: [ 'video' ],
211
+                            firePermissionPromptIsShownEvent: true
212
+                        })
194 213
                         : [];
195 214
                 })
196 215
                 .catch(err => {

+ 11
- 0
react/features/overlay/actionTypes.js View File

@@ -14,6 +14,17 @@
14 14
 export const MEDIA_PERMISSION_PROMPT_VISIBILITY_CHANGED
15 15
     = 'MEDIA_PERMISSION_PROMPT_VISIBILITY_CHANGED';
16 16
 
17
+/**
18
+ * The type of the Redux action which signals that the overlay for slow gUM is visible or not.
19
+ *
20
+ * {
21
+ *     type: TOGGLE_SLOW_GUM_OVERLAY,
22
+ *     isVisible: {boolean},
23
+ * }
24
+ * @public
25
+ */
26
+export const TOGGLE_SLOW_GUM_OVERLAY = 'TOGGLE_SLOW_GUM_OVERLAY';
27
+
17 28
 /**
18 29
  * Adjust the state of the fatal error which shows/hides the reload screen. See
19 30
  * action methods's description for more info about each of the fields.

+ 20
- 1
react/features/overlay/actions.js View File

@@ -2,7 +2,8 @@
2 2
 
3 3
 import {
4 4
     MEDIA_PERMISSION_PROMPT_VISIBILITY_CHANGED,
5
-    SET_FATAL_ERROR
5
+    SET_FATAL_ERROR,
6
+    TOGGLE_SLOW_GUM_OVERLAY
6 7
 } from './actionTypes';
7 8
 
8 9
 /**
@@ -26,6 +27,24 @@ export function mediaPermissionPromptVisibilityChanged(isVisible: boolean, brows
26 27
     };
27 28
 }
28 29
 
30
+/**
31
+ * Signals that the prompt for media permission is visible or not.
32
+ *
33
+ * @param {boolean} isVisible - If the value is true - the prompt for media
34
+ * permission is visible otherwise the value is false/undefined.
35
+ * @public
36
+ * @returns {{
37
+*     type: SLOW_GET_USER_MEDIA_OVERLAY,
38
+*     isVisible: {boolean}
39
+* }}
40
+*/
41
+export function toggleSlowGUMOverlay(isVisible: boolean) {
42
+    return {
43
+        type: TOGGLE_SLOW_GUM_OVERLAY,
44
+        isVisible
45
+    };
46
+}
47
+
29 48
 /**
30 49
  * The action indicates that an unrecoverable error has occurred and the reload
31 50
  * screen will be displayed or hidden.

+ 33
- 0
react/features/overlay/components/web/AbstractSlowGUMOverlay.js View File

@@ -0,0 +1,33 @@
1
+// @flow
2
+
3
+import { Component } from 'react';
4
+
5
+/**
6
+ * The type of the React {@code Component} props of
7
+ * {@link AbstractSlowGUMOverlay}.
8
+ */
9
+type Props = {
10
+
11
+    /**
12
+     * The function to translate human-readable text.
13
+     */
14
+    t: Function
15
+};
16
+
17
+/**
18
+ * Implements a React {@link Component} for slow gUM overlay. Shown when
19
+ * a slow gUM promise resolution is detected
20
+ */
21
+export default class AbstractSlowGUMOverlay extends Component<Props> {
22
+    /**
23
+     * Determines whether this overlay needs to be rendered (according to a
24
+     * specific redux state). Called by {@link OverlayContainer}.
25
+     *
26
+     * @param {Object} state - The redux state.
27
+     * @returns {boolean} - If this overlay needs to be rendered, {@code true};
28
+     * {@code false}, otherwise.
29
+     */
30
+    static needsRender(state: Object) {
31
+        return state['features/overlay'].isSlowGUMOverlayVisible;
32
+    }
33
+}

+ 36
- 0
react/features/overlay/components/web/SlowGUMOverlay.js View File

@@ -0,0 +1,36 @@
1
+// @flow
2
+import Spinner from '@atlaskit/spinner';
3
+import React from 'react';
4
+
5
+import { translate } from '../../../base/i18n';
6
+
7
+import AbstractSlowGUMOverlay from './AbstractSlowGUMOverlay';
8
+import OverlayFrame from './OverlayFrame';
9
+
10
+/**
11
+ * Implements a React {@link Component} for slow gUM overlay. Shown when
12
+ * a slow gUM promise resolution is detected
13
+ */
14
+class SlowGUMOverlay extends AbstractSlowGUMOverlay {
15
+    /**
16
+     * Implements React's {@link Component#render()}.
17
+     *
18
+     * @inheritdoc
19
+     * @returns {ReactElement}
20
+     */
21
+    render() {
22
+        // const { t } = this.props;
23
+
24
+        return (
25
+            <OverlayFrame>
26
+                <div className = { 'overlay__spinner-container' }>
27
+                    <Spinner
28
+                        invertColor = { true }
29
+                        size = { 'large' } />
30
+                </div>
31
+            </OverlayFrame>
32
+        );
33
+    }
34
+}
35
+
36
+export default translate(SlowGUMOverlay);

+ 1
- 0
react/features/overlay/components/web/index.js View File

@@ -5,3 +5,4 @@ export { default as OverlayFrame } from './OverlayFrame';
5 5
 export { default as PageReloadOverlay } from './PageReloadOverlay';
6 6
 export { default as SuspendedOverlay } from './SuspendedOverlay';
7 7
 export { default as UserMediaPermissionsOverlay } from './UserMediaPermissionsOverlay';
8
+export { default as SlowGUMOverlay } from './SlowGUMOverlay';

+ 3
- 1
react/features/overlay/overlays.web.js View File

@@ -2,6 +2,7 @@
2 2
 
3 3
 import {
4 4
     PageReloadOverlay,
5
+    SlowGUMOverlay,
5 6
     SuspendedOverlay,
6 7
     UserMediaPermissionsOverlay
7 8
 } from './components/web';
@@ -17,6 +18,7 @@ export function getOverlays(): Array<Object> {
17 18
     return [
18 19
         PageReloadOverlay,
19 20
         SuspendedOverlay,
20
-        UserMediaPermissionsOverlay
21
+        UserMediaPermissionsOverlay,
22
+        SlowGUMOverlay
21 23
     ];
22 24
 }

+ 22
- 1
react/features/overlay/reducer.js View File

@@ -5,7 +5,8 @@ import { assign, ReducerRegistry, set } from '../base/redux';
5 5
 
6 6
 import {
7 7
     MEDIA_PERMISSION_PROMPT_VISIBILITY_CHANGED,
8
-    SET_FATAL_ERROR
8
+    SET_FATAL_ERROR,
9
+    TOGGLE_SLOW_GUM_OVERLAY
9 10
 } from './actionTypes';
10 11
 
11 12
 /**
@@ -28,6 +29,8 @@ ReducerRegistry.register('features/overlay', (state = { }, action) => {
28 29
     case SET_FATAL_ERROR:
29 30
         return _setFatalError(state, action);
30 31
 
32
+    case TOGGLE_SLOW_GUM_OVERLAY:
33
+        return _toggleSlowGUMOverlay(state, action);
31 34
     }
32 35
 
33 36
     return state;
@@ -52,6 +55,24 @@ function _mediaPermissionPromptVisibilityChanged(
52 55
     });
53 56
 }
54 57
 
58
+/**
59
+ * Reduces a specific redux action TOGGLE_SLOW_GUM_OVERLAY of
60
+ * the feature overlay.
61
+ *
62
+ * @param {Object} state - The redux state of the feature overlay.
63
+ * @param {Action} action - The redux action to reduce.
64
+ * @private
65
+ * @returns {Object} The new state of the feature overlay after the reduction of
66
+ * the specified action.
67
+ */
68
+function _toggleSlowGUMOverlay(
69
+        state,
70
+        { isVisible }) {
71
+    return assign(state, {
72
+        isSlowGUMOverlayVisible: isVisible
73
+    });
74
+}
75
+
55 76
 /**
56 77
  * Sets the {@code LoadConfigOverlay} overlay visible or not.
57 78
  *

Loading…
Cancel
Save