server: break out electron runtimes

This commit is contained in:
Koushik Dutta
2024-08-21 12:51:23 -07:00
parent 09fc609c7f
commit 5713935ccc
3 changed files with 25 additions and 8 deletions

View File

@@ -11,7 +11,7 @@ export class ElectronForkWorker extends ChildProcessWorker {
static allocatedDisplays = new Set<number>();
allocatedDisplay: number;
constructor(_mainFilename: string, pluginId: string, options: RuntimeWorkerOptions, runtime: ScryptedRuntime) {
constructor(_mainFilename: string, pluginId: string, options: RuntimeWorkerOptions, runtime: ScryptedRuntime, mode: 'default' | 'webgl' | 'webgpu') {
super(pluginId, options);
const { env } = options;
@@ -24,6 +24,13 @@ export class ElectronForkWorker extends ChildProcessWorker {
'--disable-features=BlockInsecurePrivateNetworkRequests,PrivateNetworkAccessSendPreflights',
'--enable-features=SharedArrayBuffer',
];
if (mode !== 'default') {
args.push(
'--ignore-gpu-blocklist',
);
}
if (process.platform === 'linux') {
// crappy but should work.
for (let i = 50; i < 100; i++) {
@@ -44,11 +51,15 @@ export class ElectronForkWorker extends ChildProcessWorker {
// https://github.com/gpuweb/gpuweb/wiki/Implementation-Status#chromium-chrome-edge-etc
args.push(
'--no-sandbox',
'--enable-unsafe-webgpu',
'--ignore-gpu-blocklist',
'--enable-features=Vulkan',
'--disable-vulkan-surface',
);
if (mode === 'webgpu') {
args.push(
'--enable-unsafe-webgpu',
'--enable-features=Vulkan',
'--disable-vulkan-surface',
);
}
}
if (process.platform === 'darwin') {

View File

@@ -13,7 +13,13 @@ export function getBuiltinRuntimeHosts() {
pluginHosts.set('custom', (_, pluginId, options, runtime) => new CustomRuntimeWorker(pluginId, options, runtime));
pluginHosts.set('python', (_, pluginId, options) => new PythonRuntimeWorker(pluginId, options));
pluginHosts.set('node', (mainFilename, pluginId, options) => new NodeForkWorker(mainFilename, pluginId, options));
pluginHosts.set('electron', (mainFilename, pluginId, options, runtime) => new ElectronForkWorker(mainFilename, pluginId, options, runtime));
// safe
pluginHosts.set('electron', (mainFilename, pluginId, options, runtime) => new ElectronForkWorker(mainFilename, pluginId, options, runtime, 'default'));
// mostly safe
pluginHosts.set('electron-webgl', (mainFilename, pluginId, options, runtime) => new ElectronForkWorker(mainFilename, pluginId, options, runtime, 'webgl'));
// there be dragons
pluginHosts.set('electron-webgpu', (mainFilename, pluginId, options, runtime) => new ElectronForkWorker(mainFilename, pluginId, options, runtime, 'webgpu'));
return pluginHosts;
}