36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
export interface ChromiumSwitch {
|
|
name: string
|
|
value?: string
|
|
}
|
|
|
|
export interface GpuPolicyInput {
|
|
platform: NodeJS.Platform
|
|
headlessSmoke: boolean
|
|
softwareGl: boolean
|
|
}
|
|
|
|
export function resolveChromiumGpuSwitches(input: GpuPolicyInput): ChromiumSwitch[] {
|
|
if (input.headlessSmoke || input.softwareGl) {
|
|
return [
|
|
{ name: 'disable-gpu' },
|
|
{ name: 'use-gl', value: 'angle' },
|
|
{ name: 'use-angle', value: 'swiftshader' },
|
|
{ name: 'enable-unsafe-swiftshader' },
|
|
]
|
|
}
|
|
|
|
// Avoid forcing enable-zero-copy / enable-gpu-rasterization / force_high_performance_gpu:
|
|
// on Windows dual-GPU setups with high baseline VRAM usage they can provoke driver TDRs.
|
|
const switches: ChromiumSwitch[] = [{ name: 'disable-renderer-backgrounding' }]
|
|
if (input.platform === 'linux') {
|
|
switches.push({ name: 'ozone-platform-hint', value: 'auto' })
|
|
}
|
|
return switches
|
|
}
|
|
|
|
export function isGpuProcessCrash(
|
|
details: { type?: string; reason?: string } | null | undefined,
|
|
): boolean {
|
|
return Boolean(details && details.type === 'GPU' && details.reason !== 'clean-exit')
|
|
}
|