From cd1b6121f5a4581b52ecb4d797bb0e3c21497d2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Thu, 6 Feb 2025 11:49:23 +0100 Subject: [PATCH 1/2] feat(ScreenObtainer) add fallback option for Electron If the enclosing Jitsi Meet app declares gDM in Electron is supported, ignore the `electronUseGetDisplayMedia` config flag and use the gDM flow. This facilitates having backwards compatibility since the Electron app won't know if the deployment it's about to join has the gDM flow support or not. --- modules/RTC/ScreenObtainer.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/RTC/ScreenObtainer.js b/modules/RTC/ScreenObtainer.js index d0e67270fc..1b4c7ece51 100644 --- a/modules/RTC/ScreenObtainer.js +++ b/modules/RTC/ScreenObtainer.js @@ -94,7 +94,12 @@ const ScreenObtainer = { * @param {Object} options - Optional parameters. */ obtainScreenOnElectron(onSuccess, onFailure, options = {}) { - if (window.JitsiMeetScreenObtainer && window.JitsiMeetScreenObtainer.openDesktopPicker) { + if (typeof window.JitsiMeetScreenObtainer?.openDesktopPicker === 'function') { + // Detect if we have the fallback option. + if (window.JitsiMeetScreenObtainer?.gDMSupported) { + return this.obtainScreenFromGetDisplayMedia(onSuccess, onFailure); + } + const { desktopSharingFrameRate, desktopSharingResolution, desktopSharingSources } = this.options; window.JitsiMeetScreenObtainer.openDesktopPicker( From 2e56aa99c3e9602a516846c0831ca6238cccbc6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Thu, 6 Feb 2025 13:32:47 +0100 Subject: [PATCH 2/2] fix(ScreenObtainer) improve result handling - Lower logger level to warning - Use nested conditions --- modules/RTC/ScreenObtainer.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/modules/RTC/ScreenObtainer.js b/modules/RTC/ScreenObtainer.js index 1b4c7ece51..10d7fc32be 100644 --- a/modules/RTC/ScreenObtainer.js +++ b/modules/RTC/ScreenObtainer.js @@ -298,24 +298,20 @@ const ScreenObtainer = { errorStack: error?.stack }; - logger.error('getDisplayMedia error', JSON.stringify(constraints), JSON.stringify(errorDetails)); + logger.warn('getDisplayMedia error', JSON.stringify(constraints), JSON.stringify(errorDetails)); if (errorDetails.errorMsg?.indexOf('denied by system') !== -1) { // On Chrome this is the only thing different between error returned when user cancels // and when no permission was given on the OS level. errorCallback(new JitsiTrackError(JitsiTrackErrors.PERMISSION_DENIED)); - - return; } else if (errorDetails.errorMsg === 'NotReadableError') { // This can happen under some weird conditions: // - https://issues.chromium.org/issues/369103607 // - https://issues.chromium.org/issues/353555347 errorCallback(new JitsiTrackError(JitsiTrackErrors.SCREENSHARING_GENERIC_ERROR)); - - return; + } else { + errorCallback(new JitsiTrackError(JitsiTrackErrors.SCREENSHARING_USER_CANCELED)); } - - errorCallback(new JitsiTrackError(JitsiTrackErrors.SCREENSHARING_USER_CANCELED)); }); },