Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ScreenObtainer) add fallback option for Electron #2632

Merged
merged 2 commits into from
Feb 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions modules/RTC/ScreenObtainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just remembered that we apply the min fps constraint on the stream returned by obtainScreenFromGetDisplayMedia so that the 0 Hz mode for SS doesn't kick in automatically for browser. Do you think we need to run that on Electron clients as well? I am not sure if that will cause any issues in Electron though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd expect not to cause issues since it will be the same code path than for chrome.

}

const { desktopSharingFrameRate, desktopSharingResolution, desktopSharingSources } = this.options;

window.JitsiMeetScreenObtainer.openDesktopPicker(
Expand Down Expand Up @@ -293,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));
});
},

Expand Down