diff --git a/app/updateDefaultSession.ts b/app/updateDefaultSession.ts index 656f7db67d..0ea87670ea 100644 --- a/app/updateDefaultSession.ts +++ b/app/updateDefaultSession.ts @@ -2,7 +2,7 @@ // SPDX-License-Identifier: AGPL-3.0-only import type { Session, DesktopCapturerSource, IpcMainEvent } from 'electron'; -import { desktopCapturer, ipcMain } from 'electron'; +import { desktopCapturer, ipcMain, systemPreferences } from 'electron'; import { v4 as generateUuid } from 'uuid'; import OS from '../ts/util/os/osMain'; @@ -28,6 +28,16 @@ export function updateDefaultSession( strictAssert(videoRequested, 'Not requesting video'); strictAssert(!audioRequested, 'Requesting audio'); + // macOS: if screen sharing is actively denied, Sonoma will crash + // when we try to get the sources. + if ( + OS.isMacOS() && + systemPreferences.getMediaAccessStatus('screen') === 'denied' + ) { + callback({}); + return; + } + const sources = await desktopCapturer.getSources({ fetchWindowIcons: true, thumbnailSize: { height: 102, width: 184 },