Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

fix(conference.js): prevent multiple GUM calls on presenter unmute

paweldomasf810483ff6db
diff --git a/conference.js b/conference.js
index c901b6dd22..6f36a8707e 100644
--- a/conference.js
+++ b/conference.js
@@ -130,6 +130,15 @@ const eventEmitter = new EventEmitter();
let room;
let connection;
+/**
+ * This promise is used for chaining mutePresenterVideo calls in order to avoid calling GUM multiple times if it takes
+ * a while to finish.
+ *
+ * @type {Promise<void>}
+ * @private
+ */
+let _prevMutePresenterVideo = Promise.resolve();
+
/*
* Logic to open a desktop picker put on the window global for
* lib-jitsi-meet to detect and invoke
@@ -447,6 +456,7 @@ export default {
/**
* The local presenter video track (if any).
+ * @type {JitsiLocalTrack|null}
*/
localPresenterVideo: null,
@@ -858,7 +868,10 @@ export default {
}
if (this.isSharingScreen) {
- return this._mutePresenterVideo(mute);
+ // Chain _mutePresenterVideo calls
+ _prevMutePresenterVideo = _prevMutePresenterVideo.then(() => this._mutePresenterVideo(mute));
+
+ return;
}
// If not ready to modify track's state yet adjust the base/media
@@ -1636,6 +1649,15 @@ export default {
APP.store.dispatch(notifyCameraError(error));
};
+ // Check for NO-OP
+ if (mute && (!this.localPresenterVideo || this.localPresenterVideo.isMuted())) {
+
+ return;
+ } else if (!mute && this.localPresenterVideo && !this.localPresenterVideo.isMuted()) {
+
+ return;
+ }
+
if (!this.localPresenterVideo && !mute) {
// create a new presenter track and apply the presenter effect.
let { height } = this.localVideo.track.getSettings();