Skip to content

Commit 2def1df

Browse files
committed
fix(stage-tamagotchi): WebGPU wasn't enabled by default for Linux
Related to electron/electron#41763
1 parent 6f27985 commit 2def1df

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

apps/stage-tamagotchi/src/main/index.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { Format, LogLevel, setGlobalFormat, setGlobalLogLevel, useLogg } from '@
99
import { createLoggLogger, injecta } from '@proj-airi/injecta'
1010
import { app, Menu, nativeImage, Tray } from 'electron'
1111
import { noop, once } from 'es-toolkit'
12-
import { isMacOS } from 'std-env'
12+
import { isLinux, isMacOS } from 'std-env'
1313

1414
import icon from '../../resources/icon.png?asset'
1515
import macOSTrayIcon from '../../resources/tray-icon-macos.png?asset'
@@ -29,6 +29,20 @@ setupDebugger()
2929

3030
const log = useLogg('main').useGlobalConfig()
3131

32+
// Thanks to [@blurymind](https://github.com/blurymind),
33+
//
34+
// When running Electron on Linux, navigator.gpu.requestAdapter() fails.
35+
// In order to enable WebGPU and process the shaders fast enough, we need the following
36+
// command line switches to be set.
37+
//
38+
// https://github.com/electron/electron/issues/41763#issuecomment-2051725363
39+
// https://github.com/electron/electron/issues/41763#issuecomment-3143338995
40+
if (isLinux) {
41+
app.commandLine.appendSwitch('enable-features', 'SharedArrayBuffer')
42+
app.commandLine.appendSwitch('enable-unsafe-webgpu')
43+
app.commandLine.appendSwitch('enable-features', 'Vulkan')
44+
}
45+
3246
app.dock?.setIcon(icon)
3347
electronApp.setAppUserModelId('ai.moeru.airi')
3448

0 commit comments

Comments
 (0)