fix: disable GPU sandbox for elevated Windows startup

This commit is contained in:
Memory
2026-05-25 20:38:53 +08:00
committed by GitHub
parent e42adaad56
commit 3207c1f73e

View File

@@ -1,4 +1,4 @@
import { spawn, exec } from 'child_process'
import { spawn, exec, execSync } from 'child_process'
import { promisify } from 'util'
import { stat } from 'fs/promises'
import { existsSync } from 'fs'
@@ -54,6 +54,20 @@ export function setupPlatformSpecifics(): void {
if (process.platform === 'win32' && !exePath().startsWith('C') && electronMajor < 38) {
app.commandLine.appendSwitch('in-process-gpu')
}
if (process.platform === 'win32' && isWindowsElevatedSync()) {
app.commandLine.appendSwitch('disable-gpu-sandbox')
}
}
function isWindowsElevatedSync(): boolean {
if (process.platform !== 'win32') return false
try {
execSync('fltmc', { stdio: 'ignore', windowsHide: true })
return true
} catch {
return false
}
}
export function setupAppLifecycle(): void {