Browse Source

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.
master
Pawel Domas 4 years ago
parent
commit
6ebe2c2809

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

4
 
4
 
5
 import { translate } from '../../../../base/i18n';
5
 import { translate } from '../../../../base/i18n';
6
 import { IconMicrophoneEmpty, IconVolumeEmpty } from '../../../../base/icons';
6
 import { IconMicrophoneEmpty, IconVolumeEmpty } from '../../../../base/icons';
7
+import JitsiMeetJS from '../../../../base/lib-jitsi-meet';
7
 import { equals } from '../../../../base/redux';
8
 import { equals } from '../../../../base/redux';
8
 import { createLocalAudioTracks } from '../../../functions';
9
 import { createLocalAudioTracks } from '../../../functions';
9
 
10
 
11
 import MicrophoneEntry from './MicrophoneEntry';
12
 import MicrophoneEntry from './MicrophoneEntry';
12
 import SpeakerEntry from './SpeakerEntry';
13
 import SpeakerEntry from './SpeakerEntry';
13
 
14
 
15
+const browser = JitsiMeetJS.util.browser;
16
+
14
 export type Props = {
17
 export type Props = {
15
 
18
 
16
    /**
19
    /**
169
      * @returns {void}
172
      * @returns {void}
170
      */
173
      */
171
     async _setTracks() {
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
         this._disposeTracks(this.state.audioTracks);
183
         this._disposeTracks(this.state.audioTracks);
173
 
184
 
174
         const audioTracks = await createLocalAudioTracks(
185
         const audioTracks = await createLocalAudioTracks(
244
                     {this.state.audioTracks.map((data, i) =>
255
                     {this.state.audioTracks.map((data, i) =>
245
                         this._renderMicrophoneEntry(data, i),
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
                     {outputDevices.map((data, i) =>
263
                     {outputDevices.map((data, i) =>
251
                         this._renderSpeakerEntry(data, i),
264
                         this._renderSpeakerEntry(data, i),
252
                     )}
265
                     )}

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

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

Loading…
Cancel
Save