fix screenshare crash on OSX 14

Co-authored-by: yash-signal <yash@signal.org>
This commit is contained in:
automated-signal 2024-12-02 13:56:21 -06:00 committed by GitHub
parent e624759003
commit 195d519301
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 },