Fix screenshare portals linux
All checks were successful
Queue Release Build / prepare (push) Successful in 14s
Queue Release Build / build-windows (push) Successful in 34m25s
Queue Release Build / build-linux (push) Successful in 40m26s
Queue Release Build / finalize (push) Successful in 3m44s

This commit is contained in:
2026-03-11 17:54:04 +01:00
parent 7b3caa0b61
commit be465fd297
5 changed files with 104 additions and 43 deletions

View File

@@ -225,6 +225,7 @@ export class ScreenShareManager {
this.activeScreenStream = await this.startWithLinuxElectronAudioRouting(shareOptions, preset);
captureMethod = 'linux-electron';
} catch (error) {
this.rethrowIfScreenShareAborted(error);
this.logger.warn('Linux Electron audio routing failed; falling back to standard capture', error);
}
}
@@ -241,6 +242,7 @@ export class ScreenShareManager {
captureMethod = null;
}
} catch (error) {
this.rethrowIfScreenShareAborted(error);
this.logger.warn('getDisplayMedia with system audio failed; falling back to Electron desktop capture', error);
}
}
@@ -253,10 +255,7 @@ export class ScreenShareManager {
shareOptions.includeSystemAudio = electronCapture.includeSystemAudio;
captureMethod = 'electron-desktop';
} catch (error) {
if (this.isScreenShareSelectionAborted(error)) {
throw error;
}
this.rethrowIfScreenShareAborted(error);
this.logger.warn('Electron desktop capture failed; falling back to getDisplayMedia', error);
}
}
@@ -392,7 +391,15 @@ export class ScreenShareManager {
}
private isElectronDesktopCaptureAvailable(): boolean {
return !!this.getElectronApi()?.getSources;
return !!this.getElectronApi()?.getSources && !this.isLinuxElectron();
}
private isLinuxElectron(): boolean {
if (!this.getElectronApi() || typeof navigator === 'undefined') {
return false;
}
return /linux/i.test(`${navigator.userAgent} ${navigator.platform}`);
}
private isWindowsElectron(): boolean {
@@ -725,7 +732,14 @@ export class ScreenShareManager {
}
private isScreenShareSelectionAborted(error: unknown): boolean {
return error instanceof Error && error.name === 'AbortError';
return error instanceof Error
&& (error.name === 'AbortError' || error.name === 'NotAllowedError');
}
private rethrowIfScreenShareAborted(error: unknown): void {
if (this.isScreenShareSelectionAborted(error)) {
throw error;
}
}
private isLinuxElectronAudioRoutingSupported(): boolean {
@@ -766,13 +780,11 @@ export class ScreenShareManager {
throw new Error(activation.reason || 'Failed to activate Linux Electron audio routing.');
}
const desktopCapture = await this.startWithElectronDesktopCapturer({
desktopStream = await this.startWithDisplayMedia({
...options,
includeSystemAudio: false
}, preset);
desktopStream = desktopCapture.stream;
const { audioTrack, captureInfo } = await this.startLinuxScreenShareMonitorTrack();
const stream = new MediaStream([...desktopStream.getVideoTracks(), audioTrack]);