Improve screenshare performance
This commit is contained in:
@@ -2,26 +2,56 @@ import { app } from 'electron';
|
|||||||
import { readDesktopSettings } from '../desktop-settings';
|
import { readDesktopSettings } from '../desktop-settings';
|
||||||
|
|
||||||
export function configureAppFlags(): void {
|
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();
|
const desktopSettings = readDesktopSettings();
|
||||||
|
|
||||||
if (!desktopSettings.hardwareAcceleration) {
|
if (!desktopSettings.hardwareAcceleration) {
|
||||||
app.disableHardwareAcceleration();
|
app.disableHardwareAcceleration();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disable sandbox on Linux to avoid SUID / /tmp shared-memory issues
|
if (process.platform === 'linux' && desktopSettings.vaapiVideoEncode) {
|
||||||
if (process.platform === 'linux') {
|
// Enable VA-API hardware video encoding on Linux
|
||||||
app.commandLine.appendSwitch('no-sandbox');
|
app.commandLine.appendSwitch('enable-features', 'VaapiVideoEncode');
|
||||||
app.commandLine.appendSwitch('disable-dev-shm-usage');
|
|
||||||
app.commandLine.appendSwitch('enable-features', 'AudioServiceOutOfProcess');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Suppress Autofill devtools errors
|
app.commandLine.appendSwitch('enable-gpu-rasterization');
|
||||||
app.commandLine.appendSwitch('disable-features', 'Autofill,AutofillAssistant,AutofillServerCommunication');
|
app.commandLine.appendSwitch('enable-zero-copy');
|
||||||
// Allow media autoplay without user gesture
|
app.commandLine.appendSwitch('enable-native-gpu-memory-buffers');
|
||||||
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');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import * as path from 'path';
|
|||||||
|
|
||||||
export interface DesktopSettings {
|
export interface DesktopSettings {
|
||||||
hardwareAcceleration: boolean;
|
hardwareAcceleration: boolean;
|
||||||
|
vaapiVideoEncode: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DesktopSettingsSnapshot extends DesktopSettings {
|
export interface DesktopSettingsSnapshot extends DesktopSettings {
|
||||||
@@ -12,7 +13,8 @@ export interface DesktopSettingsSnapshot extends DesktopSettings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const DEFAULT_DESKTOP_SETTINGS: DesktopSettings = {
|
const DEFAULT_DESKTOP_SETTINGS: DesktopSettings = {
|
||||||
hardwareAcceleration: true
|
hardwareAcceleration: true,
|
||||||
|
vaapiVideoEncode: false
|
||||||
};
|
};
|
||||||
|
|
||||||
export function getDesktopSettingsSnapshot(): DesktopSettingsSnapshot {
|
export function getDesktopSettingsSnapshot(): DesktopSettingsSnapshot {
|
||||||
@@ -38,6 +40,9 @@ export function readDesktopSettings(): DesktopSettings {
|
|||||||
const parsed = JSON.parse(raw) as Partial<DesktopSettings>;
|
const parsed = JSON.parse(raw) as Partial<DesktopSettings>;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
vaapiVideoEncode: typeof parsed.vaapiVideoEncode === 'boolean'
|
||||||
|
? parsed.vaapiVideoEncode
|
||||||
|
: DEFAULT_DESKTOP_SETTINGS.vaapiVideoEncode,
|
||||||
hardwareAcceleration: typeof parsed.hardwareAcceleration === 'boolean'
|
hardwareAcceleration: typeof parsed.hardwareAcceleration === 'boolean'
|
||||||
? parsed.hardwareAcceleration
|
? parsed.hardwareAcceleration
|
||||||
: DEFAULT_DESKTOP_SETTINGS.hardwareAcceleration
|
: DEFAULT_DESKTOP_SETTINGS.hardwareAcceleration
|
||||||
|
|||||||
@@ -2,6 +2,9 @@
|
|||||||
"name": "metoyou",
|
"name": "metoyou",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "P2P Discord-like chat application",
|
"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",
|
"main": "dist/electron/main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"ng": "ng",
|
"ng": "ng",
|
||||||
|
|||||||
Reference in New Issue
Block a user