From 83dfb67f2310011bff9da41e0108422b15fb71e7 Mon Sep 17 00:00:00 2001 From: William Liang Date: Thu, 29 Sep 2022 11:26:07 -0400 Subject: [PATCH] fix(video-mute) prevent multiple camera track creation --- conference.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/conference.js b/conference.js index 6374507f5..bb9400208 100644 --- a/conference.js +++ b/conference.js @@ -459,6 +459,11 @@ export default { */ _localTracksInitialized: false, + /** + * Flag used to prevent the creation of another local video track in this.muteVideo if one is already in progress. + */ + isCreatingLocalTrack: false, + isSharingScreen: false, /** @@ -1028,11 +1033,13 @@ export default { const localVideo = getLocalJitsiVideoTrack(APP.store.getState()); - if (!localVideo && !mute) { + if (!localVideo && !mute && !this.isCreatingLocalTrack) { const maybeShowErrorDialog = error => { showUI && APP.store.dispatch(notifyCameraError(error)); }; + this.isCreatingLocalTrack = true; + // Try to create local video if there wasn't any. // This handles the case when user joined with no video // (dismissed screen sharing screen or in audio only mode), but @@ -1054,6 +1061,9 @@ export default { logger.debug(`muteVideo: calling useVideoStream for track: ${videoTrack}`); return this.useVideoStream(videoTrack); + }) + .finally(() => { + this.isCreatingLocalTrack = false; }); } else { // FIXME show error dialog if it fails (should be handled by react)