Sfoglia il codice sorgente

audio output selection in safari blocks the UI

It appears that at the time of this writing, creating audio tracks blocks
the browser's main thread for a long time on safari. Wasn't able to confirm
which part of track creation does the blocking exactly, but not creating
the tracks seems to help and makes the UI much more responsive.
j8
Pawel Domas 4 anni fa
parent
commit
6ebe2c2809

+ 16
- 3
react/features/settings/components/web/audio/AudioSettingsContent.js Vedi File

@@ -4,6 +4,7 @@ import React, { Component } from 'react';
4 4
 
5 5
 import { translate } from '../../../../base/i18n';
6 6
 import { IconMicrophoneEmpty, IconVolumeEmpty } from '../../../../base/icons';
7
+import JitsiMeetJS from '../../../../base/lib-jitsi-meet';
7 8
 import { equals } from '../../../../base/redux';
8 9
 import { createLocalAudioTracks } from '../../../functions';
9 10
 
@@ -11,6 +12,8 @@ import AudioSettingsHeader from './AudioSettingsHeader';
11 12
 import MicrophoneEntry from './MicrophoneEntry';
12 13
 import SpeakerEntry from './SpeakerEntry';
13 14
 
15
+const browser = JitsiMeetJS.util.browser;
16
+
14 17
 export type Props = {
15 18
 
16 19
    /**
@@ -169,6 +172,14 @@ class AudioSettingsContent extends Component<Props, State> {
169 172
      * @returns {void}
170 173
      */
171 174
     async _setTracks() {
175
+        if (browser.isSafari()) {
176
+
177
+            // It appears that at the time of this writing, creating audio tracks blocks the browser's main thread for
178
+            // long time on safari. Wasn't able to confirm which part of track creation does the blocking exactly, but
179
+            // not creating the tracks seems to help and makes the UI much more responsive.
180
+            return;
181
+        }
182
+
172 183
         this._disposeTracks(this.state.audioTracks);
173 184
 
174 185
         const audioTracks = await createLocalAudioTracks(
@@ -244,9 +255,11 @@ class AudioSettingsContent extends Component<Props, State> {
244 255
                     {this.state.audioTracks.map((data, i) =>
245 256
                         this._renderMicrophoneEntry(data, i),
246 257
                     )}
247
-                    <AudioSettingsHeader
248
-                        IconComponent = { IconVolumeEmpty }
249
-                        text = { t('settings.speakers') } />
258
+                    { outputDevices.length > 0 && (
259
+                        <AudioSettingsHeader
260
+                            IconComponent = { IconVolumeEmpty }
261
+                            text = { t('settings.speakers') } />)
262
+                    }
250 263
                     {outputDevices.map((data, i) =>
251 264
                         this._renderSpeakerEntry(data, i),
252 265
                     )}

+ 4
- 3
react/features/settings/components/web/audio/MicrophoneEntry.js Vedi File

@@ -140,7 +140,7 @@ export default class MicrophoneEntry extends Component<Props, State> {
140 140
      *
141 141
      * @inheritdoc
142 142
      */
143
-    compmonentWillUnmount() {
143
+    componentWillUnmount() {
144 144
         this._stopListening(this.props.jitsiTrack);
145 145
     }
146 146
 
@@ -150,7 +150,7 @@ export default class MicrophoneEntry extends Component<Props, State> {
150 150
      * @inheritdoc
151 151
      */
152 152
     render() {
153
-        const { children, hasError, isSelected } = this.props;
153
+        const { children, hasError, isSelected, jitsiTrack } = this.props;
154 154
 
155 155
         return (
156 156
             <div
@@ -161,10 +161,11 @@ export default class MicrophoneEntry extends Component<Props, State> {
161 161
                     isSelected = { isSelected }>
162 162
                     {children}
163 163
                 </AudioSettingsEntry>
164
-                <Meter
164
+                { Boolean(jitsiTrack) && <Meter
165 165
                     className = 'audio-preview-meter-mic'
166 166
                     isDisabled = { hasError }
167 167
                     level = { this.state.level } />
168
+                }
168 169
             </div>
169 170
         );
170 171
     }

Loading…
Annulla
Salva