Преглед на файлове

Merge pull request #1815 from jitsi/fix_audio_only_off

fix(AudioOnly+web): crash when untoggle audio only
efficient_tiling
Saúl Ibarra Corretgé преди 8 години
родител
ревизия
fa86d2ab9e
променени са 4 файла, в които са добавени 45 реда и са изтрити 9 реда
  1. 20
    1
      conference.js
  2. 11
    2
      react/features/base/media/middleware.js
  3. 1
    5
      react/features/base/tracks/functions.js
  4. 13
    1
      react/features/base/tracks/middleware.js

+ 20
- 1
conference.js Целия файл

752
         if (!this._localTracksInitialized) {
752
         if (!this._localTracksInitialized) {
753
             this.videoMuted = mute;
753
             this.videoMuted = mute;
754
 
754
 
755
+            return;
756
+        } else if (localVideo && localVideo.isMuted() === mute) {
757
+            // NO-OP
755
             return;
758
             return;
756
         }
759
         }
757
 
760
 
1994
         );
1997
         );
1995
 
1998
 
1996
         APP.UI.addListener(UIEvents.TOGGLE_AUDIO_ONLY, audioOnly => {
1999
         APP.UI.addListener(UIEvents.TOGGLE_AUDIO_ONLY, audioOnly => {
1997
-            this.muteVideo(audioOnly);
2000
+
2001
+            // FIXME On web video track is stored both in redux and in
2002
+            // 'localVideo' field, video is attempted to be unmuted twice when
2003
+            // turning off the audio only mode. This will crash the app with
2004
+            // 'unmute operation is already in progress'.
2005
+            // Because there's no logic in redux about creating new track in
2006
+            // case unmute when not track exists the things have to go through
2007
+            // muteVideo logic in such case.
2008
+            const tracks = APP.store.getState()['features/base/tracks'];
2009
+            const isTrackInRedux
2010
+                = Boolean(
2011
+                    tracks.find(
2012
+                        track => track.jitsiTrack
2013
+                            && track.jitsiTrack.getType() === 'video'));
2014
+            if (!isTrackInRedux) {
2015
+                this.muteVideo(audioOnly);
2016
+            }
1998
 
2017
 
1999
             // Immediately update the UI by having remote videos and the large
2018
             // Immediately update the UI by having remote videos and the large
2000
             // video update themselves instead of waiting for some other event
2019
             // video update themselves instead of waiting for some other event

+ 11
- 2
react/features/base/media/middleware.js Целия файл

9
     setCameraFacingMode,
9
     setCameraFacingMode,
10
     setVideoMuted
10
     setVideoMuted
11
 } from './actions';
11
 } from './actions';
12
-import { CAMERA_FACING_MODE } from './constants';
12
+import { CAMERA_FACING_MODE, MEDIA_TYPE } from './constants';
13
 
13
 
14
 /**
14
 /**
15
  * Middleware that captures CONFERENCE_LEFT action and restores initial state
15
  * Middleware that captures CONFERENCE_LEFT action and restores initial state
70
     // fired before track gets to state.
70
     // fired before track gets to state.
71
     if (track.muted !== muted) {
71
     if (track.muted !== muted) {
72
         track.muted = muted;
72
         track.muted = muted;
73
-        setTrackMuted(track.jitsiTrack, muted);
73
+        setTrackMuted(track.jitsiTrack, muted)
74
+            .catch(error => {
75
+                console.error(`setTrackMuted(${muted}) failed`, error);
76
+                const setMuted
77
+                    = track.mediaType === MEDIA_TYPE.AUDIO
78
+                        ? setAudioMuted : setVideoMuted;
79
+
80
+                // Failed to sync muted state - dispatch rollback action
81
+                store.dispatch(setMuted(!muted));
82
+            });
74
     }
83
     }
75
 }
84
 }

+ 1
- 5
react/features/base/tracks/functions.js Целия файл

174
 
174
 
175
     const f = muted ? 'mute' : 'unmute';
175
     const f = muted ? 'mute' : 'unmute';
176
 
176
 
177
-    return track[f]()
178
-        .catch(err => {
179
-            console.warn(`Track ${f} was rejected:`, err);
180
-            throw err;
181
-        });
177
+    return track[f]();
182
 }
178
 }

+ 13
- 1
react/features/base/tracks/middleware.js Целия файл

160
 function _setMuted(store, action, mediaType: MEDIA_TYPE) {
160
 function _setMuted(store, action, mediaType: MEDIA_TYPE) {
161
     const localTrack = _getLocalTrack(store, mediaType);
161
     const localTrack = _getLocalTrack(store, mediaType);
162
 
162
 
163
-    localTrack && setTrackMuted(localTrack.jitsiTrack, action.muted);
163
+    if (localTrack) {
164
+        setTrackMuted(localTrack.jitsiTrack, action.muted)
165
+            .catch(error => {
166
+                console.error(`setTrackMuted(${action.muted}) failed`, error);
167
+
168
+                const setMuted
169
+                    = mediaType === MEDIA_TYPE.AUDIO
170
+                        ? setAudioMuted : setVideoMuted;
171
+
172
+                // Failed to modify muted state - dispatch rollback action
173
+                store.dispatch(setMuted(!action.muted));
174
+            });
175
+    }
164
 }
176
 }
165
 
177
 
166
 /**
178
 /**

Loading…
Отказ
Запис