Improve screenshare performance
This commit is contained in:
@@ -2,26 +2,56 @@ import { app } from 'electron';
|
||||
import { readDesktopSettings } from '../desktop-settings';
|
||||
|
||||
export function configureAppFlags(): void {
|
||||
linuxSpecificFlags();
|
||||
audioFlags();
|
||||
networkFlags();
|
||||
setupGpuEncodingFlags();
|
||||
chromiumFlags();
|
||||
}
|
||||
|
||||
function chromiumFlags(): void {
|
||||
// Allow media autoplay without user gesture
|
||||
app.commandLine.appendSwitch('autoplay-policy', 'no-user-gesture-required');
|
||||
|
||||
// Suppress Autofill devtools errors
|
||||
app.commandLine.appendSwitch('disable-features', 'Autofill,AutofillAssistant,AutofillServerCommunication');
|
||||
}
|
||||
|
||||
function audioFlags(): void {
|
||||
if (process.platform === 'linux') {
|
||||
// Use the new PipeWire-based audio pipeline on Linux for better screen share audio capture support
|
||||
app.commandLine.appendSwitch('enable-features', 'AudioServiceOutOfProcess');
|
||||
}
|
||||
}
|
||||
|
||||
function linuxSpecificFlags(): void {
|
||||
// Disable sandbox on Linux to avoid SUID / /tmp shared-memory issues
|
||||
if (process.platform === 'linux') {
|
||||
app.commandLine.appendSwitch('no-sandbox');
|
||||
app.commandLine.appendSwitch('disable-dev-shm-usage');
|
||||
}
|
||||
}
|
||||
|
||||
function networkFlags(): void {
|
||||
// Accept self-signed certificates in development (for --ssl dev server)
|
||||
if (process.env['SSL'] === 'true') {
|
||||
app.commandLine.appendSwitch('ignore-certificate-errors');
|
||||
}
|
||||
}
|
||||
|
||||
function setupGpuEncodingFlags(): void {
|
||||
const desktopSettings = readDesktopSettings();
|
||||
|
||||
if (!desktopSettings.hardwareAcceleration) {
|
||||
app.disableHardwareAcceleration();
|
||||
}
|
||||
|
||||
// Disable sandbox on Linux to avoid SUID / /tmp shared-memory issues
|
||||
if (process.platform === 'linux') {
|
||||
app.commandLine.appendSwitch('no-sandbox');
|
||||
app.commandLine.appendSwitch('disable-dev-shm-usage');
|
||||
app.commandLine.appendSwitch('enable-features', 'AudioServiceOutOfProcess');
|
||||
if (process.platform === 'linux' && desktopSettings.vaapiVideoEncode) {
|
||||
// Enable VA-API hardware video encoding on Linux
|
||||
app.commandLine.appendSwitch('enable-features', 'VaapiVideoEncode');
|
||||
}
|
||||
|
||||
// Suppress Autofill devtools errors
|
||||
app.commandLine.appendSwitch('disable-features', 'Autofill,AutofillAssistant,AutofillServerCommunication');
|
||||
// Allow media autoplay without user gesture
|
||||
app.commandLine.appendSwitch('autoplay-policy', 'no-user-gesture-required');
|
||||
|
||||
// Accept self-signed certificates in development (for --ssl dev server)
|
||||
if (process.env['SSL'] === 'true') {
|
||||
app.commandLine.appendSwitch('ignore-certificate-errors');
|
||||
}
|
||||
app.commandLine.appendSwitch('enable-gpu-rasterization');
|
||||
app.commandLine.appendSwitch('enable-zero-copy');
|
||||
app.commandLine.appendSwitch('enable-native-gpu-memory-buffers');
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import * as path from 'path';
|
||||
|
||||
export interface DesktopSettings {
|
||||
hardwareAcceleration: boolean;
|
||||
vaapiVideoEncode: boolean;
|
||||
}
|
||||
|
||||
export interface DesktopSettingsSnapshot extends DesktopSettings {
|
||||
@@ -12,7 +13,8 @@ export interface DesktopSettingsSnapshot extends DesktopSettings {
|
||||
}
|
||||
|
||||
const DEFAULT_DESKTOP_SETTINGS: DesktopSettings = {
|
||||
hardwareAcceleration: true
|
||||
hardwareAcceleration: true,
|
||||
vaapiVideoEncode: false
|
||||
};
|
||||
|
||||
export function getDesktopSettingsSnapshot(): DesktopSettingsSnapshot {
|
||||
@@ -38,6 +40,9 @@ export function readDesktopSettings(): DesktopSettings {
|
||||
const parsed = JSON.parse(raw) as Partial<DesktopSettings>;
|
||||
|
||||
return {
|
||||
vaapiVideoEncode: typeof parsed.vaapiVideoEncode === 'boolean'
|
||||
? parsed.vaapiVideoEncode
|
||||
: DEFAULT_DESKTOP_SETTINGS.vaapiVideoEncode,
|
||||
hardwareAcceleration: typeof parsed.hardwareAcceleration === 'boolean'
|
||||
? parsed.hardwareAcceleration
|
||||
: DEFAULT_DESKTOP_SETTINGS.hardwareAcceleration
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
"name": "metoyou",
|
||||
"version": "1.0.0",
|
||||
"description": "P2P Discord-like chat application",
|
||||
"author": "Myxelium Name <info@azaaxin.com>",
|
||||
"url": "https://git.azaaxin.com/myxelium/Toju",
|
||||
"homepage": "https://git.azaaxin.com/myxelium/Toju",
|
||||
"main": "dist/electron/main.js",
|
||||
"scripts": {
|
||||
"ng": "ng",
|
||||
|
||||
Reference in New Issue
Block a user