Skip to content

armgit / SOMA

Public Imported from GitHub
0

Desktop app for designing parametric 3D models in CadQuery together with the coding agent of your choice

App: Unter Linux ohne nutzbaren Grafiktreiber Neustart mit Software-Rendering, sonst Meldung statt leerem Fenster

Kai-Jungsthoefel7518a7ca7329
diff --git a/app/src/main/main.ts b/app/src/main/main.ts
index 13e5d57..ab868f5 100644
--- a/app/src/main/main.ts
+++ b/app/src/main/main.ts
@@ -355,8 +355,27 @@ function createWindow(): void {
win.on('closed', () => { ctl.close(); ctl.renders.close(); controller = null; win = null; });
}
+/**
+ * Linux ohne nutzbaren Grafiktreiber (VM, Remote-Desktop, xvfb): Chromium sperrt WebGL2 auf dem Software-Renderer
+ * llvmpipe, ohne WebGL gibt es keinen Viewer. Dann einmal neu starten und die Sperrliste übergehen. Rechner mit
+ * funktionierendem Treiber bleiben unberührt. Der Schalter wirkt nur beim Start, deshalb der Neustart, und zwar vor dem
+ * ersten Fenster. Scheitert WebGL danach noch, meldet es das Fenster (renderer/main.ts).
+ */
+async function relaunchForSoftwareGl(): Promise<boolean> {
+ if (process.platform !== 'linux' || app.commandLine.hasSwitch('ignore-gpu-blocklist')) return false;
+ // Der Status gilt erst, wenn der GPU-Prozess Auskunft gegeben hat
+ await Promise.race([app.getGPUInfo('basic').catch(() => null), new Promise((r) => setTimeout(r, 3000))]);
+ const status = app.getGPUFeatureStatus().webgl2;
+ if (status.startsWith('enabled')) return false;
+ console.log(`[gpu] WebGL2 ${status}, restarting with --ignore-gpu-blocklist (software rendering)`);
+ app.relaunch({ args: [...process.argv.slice(1), '--ignore-gpu-blocklist'] });
+ app.exit(0);
+ return true;
+}
+
// Erst die Verbindung für `soma render` (E58), dann das Fenster: Die Terminals bekommen Adresse und Schlüssel beim Anlegen
app.whenReady().then(async () => {
+ if (await relaunchForSoftwareGl()) return;
adoptLoginShellPath(); // macOS und Linux: PATH wie im Terminal, sonst fehlen die Agenten
// Python schon jetzt vorwärmen: Bis das Fenster steht und das letzte Modell offen ist, ist cadquery geladen (build.ts)
warmUp();
diff --git a/app/src/renderer/main.ts b/app/src/renderer/main.ts
index aeb82f2..98fb2de 100644
--- a/app/src/renderer/main.ts
+++ b/app/src/renderer/main.ts
@@ -31,7 +31,22 @@ import { PickResult, Viewer, ViewName } from './viewer';
hydrateIcons();
const api = window.soma;
-const viewer = new Viewer($('viewer'));
+/**
+ * Ohne WebGL gibt es keine 3D-Ansicht, und die ganze Oberfläche hängt am Viewer. Unter Linux hat der Hauptprozess dann
+ * schon Software-Rendering versucht (main/main.ts). Klar sagen, was fehlt, statt mit leerem Fenster stehen zu bleiben.
+ */
+function createViewer(): Viewer {
+ try {
+ return new Viewer($('viewer'));
+ } catch (e) {
+ document.body.replaceChildren(el('div', { className: 'fatal' },
+ el('h1', {}, '3D view unavailable'),
+ el('p', {}, 'SOMA needs WebGL 2 for the 3D view, but this system could not provide it. Install or update the graphics driver, or start SOMA on a machine with graphics acceleration.'),
+ el('pre', {}, String(e instanceof Error ? e.message : e))));
+ throw e;
+ }
+}
+const viewer = createViewer();
viewer.attachCube($('cube-view'));
const terminals = new TerminalTabs($('term-tabs'), $('term-panes'), $('btn-term-add'), $('strip-tabs'));
diff --git a/app/src/renderer/style.css b/app/src/renderer/style.css
index af6ea1e..155d512 100644
--- a/app/src/renderer/style.css
+++ b/app/src/renderer/style.css
@@ -1097,3 +1097,9 @@ code { font-family:var(--mono); font-size:.95em; }
.st-comp-grid .n { color:var(--tx); }
.st-comp-grid .ver { font-family:var(--mono); color:var(--tx2); }
.st-comp-grid .lic { color:var(--tx3); }
+
+/* Ohne WebGL kein Viewer: Meldung statt leerer Oberfläche (renderer/main.ts) */
+.fatal { max-width:640px; margin:15vh auto 0; padding:0 24px; }
+.fatal h1 { font-size:18px; font-weight:600; color:var(--err); margin:0 0 12px; }
+.fatal p { color:var(--tx2); margin:0 0 16px; }
+.fatal pre { font-family:var(--mono); font-size:12px; color:var(--tx3); white-space:pre-wrap; background:var(--s2); border:1px solid var(--line); border-radius:6px; padding:10px 12px; margin:0; }