From 2def1df1d84e8d2ca98e6bd08b8d4a99156ab763 Mon Sep 17 00:00:00 2001 From: Neko Ayaka Date: Sun, 12 Oct 2025 03:28:43 +0800 Subject: [PATCH] fix(stage-tamagotchi): WebGPU wasn't enabled by default for Linux Related to https://github.com/electron/electron/issues/41763 --- apps/stage-tamagotchi/src/main/index.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/apps/stage-tamagotchi/src/main/index.ts b/apps/stage-tamagotchi/src/main/index.ts index e09d7ddd8..dfa7ee3f6 100644 --- a/apps/stage-tamagotchi/src/main/index.ts +++ b/apps/stage-tamagotchi/src/main/index.ts @@ -9,7 +9,7 @@ import { Format, LogLevel, setGlobalFormat, setGlobalLogLevel, useLogg } from '@ import { createLoggLogger, injecta } from '@proj-airi/injecta' import { app, Menu, nativeImage, Tray } from 'electron' import { noop, once } from 'es-toolkit' -import { isMacOS } from 'std-env' +import { isLinux, isMacOS } from 'std-env' import icon from '../../resources/icon.png?asset' import macOSTrayIcon from '../../resources/tray-icon-macos.png?asset' @@ -29,6 +29,20 @@ setupDebugger() const log = useLogg('main').useGlobalConfig() +// Thanks to [@blurymind](https://github.com/blurymind), +// +// When running Electron on Linux, navigator.gpu.requestAdapter() fails. +// In order to enable WebGPU and process the shaders fast enough, we need the following +// command line switches to be set. +// +// https://github.com/electron/electron/issues/41763#issuecomment-2051725363 +// https://github.com/electron/electron/issues/41763#issuecomment-3143338995 +if (isLinux) { + app.commandLine.appendSwitch('enable-features', 'SharedArrayBuffer') + app.commandLine.appendSwitch('enable-unsafe-webgpu') + app.commandLine.appendSwitch('enable-features', 'Vulkan') +} + app.dock?.setIcon(icon) electronApp.setAppUserModelId('ai.moeru.airi')