fix screenshare crash on OSX 14

This commit is contained in:
yash-signal 2024-12-02 13:22:24 -06:00 committed by GitHub
parent 64409372d9
commit 7ba9745582
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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 },