diff --git a/conference.js b/conference.js index a592dadfc..4a9ba92ff 100644 --- a/conference.js +++ b/conference.js @@ -1426,6 +1426,9 @@ export default { } this._stopProxyConnection(); + if (config.enableScreenshotCapture) { + APP.store.dispatch(toggleScreenshotCaptureEffect(false)); + } // It can happen that presenter GUM is in progress while screensharing is being turned off. Here it needs to // wait for that GUM to be resolved in order to prevent leaking the presenter track(this.localPresenterVideo @@ -1461,9 +1464,6 @@ export default { } else { promise = promise.then(() => this.useVideoStream(null)); } - if (config.enableScreenshotCapture) { - APP.store.dispatch(toggleScreenshotCaptureEffect(false)); - } return promise.then( () => { diff --git a/react/features/screenshot-capture/actions.js b/react/features/screenshot-capture/actions.js index eb7bcb381..ec028d09a 100644 --- a/react/features/screenshot-capture/actions.js +++ b/react/features/screenshot-capture/actions.js @@ -34,17 +34,13 @@ export function toggleScreenshotCaptureEffect(enabled: boolean) { if (state['features/screenshot-capture'].capturesEnabled !== enabled) { const { jitsiTrack } = getLocalVideoTrack(state['features/base/tracks']); + // Screenshot capture effect doesn't return a modified stream. Therefore, we don't have to + // switch the stream at the conference level, starting/stopping the effect will suffice here. return createScreenshotCaptureEffect(state) - .then(effect => - jitsiTrack.setEffect(enabled ? effect : undefined) - .then(() => { - dispatch(setScreenshotCapture(enabled)); - }) - .catch(() => { - dispatch(setScreenshotCapture(!enabled)); - }) - ) - .catch(() => dispatch(setScreenshotCapture(false))); + .then(effect => { + enabled ? effect.startEffect(jitsiTrack.getOriginalStream()) : effect.stopEffect(); + dispatch(setScreenshotCapture(enabled)); + }); } return Promise.resolve();