Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

fix(desktop): solid Apps and Settings pop-ups when Linux renders without a GPU

AdityaUmale0f703b5030b4
diff --git a/electron/linux-gpu.mjs b/electron/linux-gpu.mjs
index 405c7bde08..6ef033fd0a 100644
--- a/electron/linux-gpu.mjs
+++ b/electron/linux-gpu.mjs
@@ -7,3 +7,6 @@ export function linuxDisablesGpu({ env = process.env, exists = fs.existsSync } =
if (env.OMB_LINUX_GPU === "on") return false;
return exists("/proc/driver/nvidia/version") || exists("/sys/module/nvidia");
}
+
+// The main window's page is told so its glass pop-ups drop the backdrop blur, which is redrawn on the CPU here.
+export const SOFTWARE_RENDERING_ARG = "--omb-software-rendering=1";
diff --git a/electron/linux-gpu.node-test.mjs b/electron/linux-gpu.node-test.mjs
index e49de27325..7e39562e56 100644
--- a/electron/linux-gpu.node-test.mjs
+++ b/electron/linux-gpu.node-test.mjs
@@ -1,7 +1,8 @@
import assert from "node:assert/strict";
+import { readFileSync } from "node:fs";
import test from "node:test";
-import { linuxDisablesGpu } from "./linux-gpu.mjs";
+import { linuxDisablesGpu, SOFTWARE_RENDERING_ARG } from "./linux-gpu.mjs";
const only = (...paths) => (p) => paths.includes(p);
@@ -18,3 +19,11 @@ test("OMB_LINUX_GPU overrides detection either way", () => {
assert.equal(linuxDisablesGpu({ env: { OMB_LINUX_GPU: "off" }, exists: only() }), true);
assert.equal(linuxDisablesGpu({ env: { OMB_LINUX_GPU: "on" }, exists: only("/sys/module/nvidia") }), false);
});
+
+test("the main window tells its page when it renders without a GPU, so pop-ups drop their blur", () => {
+ const main = readFileSync(new URL("./main.mjs", import.meta.url), "utf8");
+ const preload = readFileSync(new URL("./preload.cjs", import.meta.url), "utf8");
+ assert.match(main, /linuxSoftwareRendering \? \[SOFTWARE_RENDERING_ARG\] : \[\]/);
+ assert.equal(SOFTWARE_RENDERING_ARG, "--omb-software-rendering=1");
+ assert.match(preload, /softwareRendering: process\.argv\.includes\("--omb-software-rendering=1"\)/);
+});
diff --git a/electron/main.mjs b/electron/main.mjs
index 3430f8c505..20bf454151 100644
--- a/electron/main.mjs
+++ b/electron/main.mjs
@@ -11,7 +11,7 @@ import { createAndroidDeviceController } from "./android-device.mjs";
import { finishSpeech, speechBusy, startSpeech, stopSpeech } from "./speech.mjs";
import { installTalk, isTalkPanel } from "./talk-main.mjs";
import { openBlankTerminal } from "./terminal-launch.mjs";
-import { linuxDisablesGpu } from "./linux-gpu.mjs";
+import { linuxDisablesGpu, SOFTWARE_RENDERING_ARG } from "./linux-gpu.mjs";
import { pasteMenuItem } from "./paste-menu-item.mjs";
import { attachUpdaterWindow, startUpdater, registerUpdaterIpc, sendUpdaterState, reopenedOutOfSight, quietSignals } from "./updater.mjs";
import {
@@ -178,10 +178,9 @@ function applyUnreadBadge(win = mainWindow) {
}
// GNOME groups the window with its desktop entry only when both identities match; set before ready.
-if (process.platform === "linux") {
- if (linuxDisablesGpu()) app.disableHardwareAcceleration();
- app.setDesktopName("com.openmausbot.app.desktop");
-}
+const linuxSoftwareRendering = process.platform === "linux" && linuxDisablesGpu();
+if (linuxSoftwareRendering) app.disableHardwareAcceleration();
+if (process.platform === "linux") app.setDesktopName("com.openmausbot.app.desktop");
if (!app.requestSingleInstanceLock()) {
console.log("[desktop] OpenMausBot is already running — focusing that window");
@@ -1980,7 +1979,7 @@ function createWindow({ deferNavigation = false } = {}) {
contextIsolation: true,
preload: path.join(__dirname, "preload.cjs"),
additionalArguments: [...desktopCompanionRendererArguments(rendererOrigin(), desktopRemoteAccess),
- ...(app.isPackaged && !desktopRemoteAccess ? ["--omb-company-desktop=1"] : []), `--omb-app-version=${app.getVersion()}`],
+ ...(app.isPackaged && !desktopRemoteAccess ? ["--omb-company-desktop=1"] : []), `--omb-app-version=${app.getVersion()}`, ...(linuxSoftwareRendering ? [SOFTWARE_RENDERING_ARG] : [])],
},
});
mainWindow = win; hiddenStart = false; chromeRail.attach(win);
diff --git a/electron/preload.cjs b/electron/preload.cjs
index da01c30ac1..96d65169bc 100644
--- a/electron/preload.cjs
+++ b/electron/preload.cjs
@@ -143,6 +143,8 @@ function invokeWithPlainError(channel, ...args) {
const bridge = {
platform: process.platform,
+ /** Linux without a GPU (electron/linux-gpu.mjs): the page drops its backdrop blurs. */
+ softwareRendering: process.argv.includes("--omb-software-rendering=1"),
/** This app's version, and whether this page is this app's own (served by this computer, not a server from the Server menu). */
app: { version: appVersion, ownPage: isLocalPage },
// Safe on a cloud page: the person chooses in a native menu, or a circle of the rail main listed (only for this app's
diff --git a/src/lib/glass-surface.test.ts b/src/lib/glass-surface.test.ts
index 229dcb715c..a3f4fa11e1 100644
--- a/src/lib/glass-surface.test.ts
+++ b/src/lib/glass-surface.test.ts
@@ -56,6 +56,14 @@ describe("glass surface", () => {
expect(surface).toContain("backdrop-filter: none");
});
+ it("is the opaque menu colour, without a blur, when the desktop app renders without a GPU", () => {
+ const surface = rule(":root[data-software-rendering] .glass-surface");
+ expect(surface).toContain("background: var(--color-menu)");
+ expect(surface).toContain("-webkit-backdrop-filter: none");
+ expect(surface).toContain("backdrop-filter: none");
+ expect(css.indexOf(":root[data-software-rendering] .glass-surface {")).toBeGreaterThan(css.indexOf(".glass-surface {"));
+ });
+
it("lives outside every skin block, and every skin still defines the tokens it reads", () => {
const blocks = skinBlocks();
expect(blocks).toHaveLength(SKIN_IDS.length);
diff --git a/src/lib/software-rendering.test.ts b/src/lib/software-rendering.test.ts
new file mode 100644
index 0000000000..4e12d8c064
--- /dev/null
+++ b/src/lib/software-rendering.test.ts
@@ -0,0 +1,28 @@
+// @vitest-environment happy-dom
+import { afterEach, describe, expect, it } from "vitest";
+import { applySoftwareRendering } from "./software-rendering";
+
+afterEach(() => {
+ delete document.documentElement.dataset.softwareRendering;
+ delete (window as { ogb?: unknown }).ogb;
+});
+
+describe("applySoftwareRendering", () => {
+ it("marks the page when the desktop app renders without a GPU", () => {
+ (window as { ogb?: unknown }).ogb = { platform: "linux", softwareRendering: true };
+ applySoftwareRendering();
+ expect(document.documentElement.dataset.softwareRendering).toBe("");
+ });
+
+ it("leaves the page alone with a GPU, on other platforms and in a browser", () => {
+ (window as { ogb?: unknown }).ogb = { platform: "linux" };
+ applySoftwareRendering();
+ expect(document.documentElement.dataset.softwareRendering).toBeUndefined();
+ (window as { ogb?: unknown }).ogb = { platform: "darwin", softwareRendering: false };
+ applySoftwareRendering();
+ expect(document.documentElement.dataset.softwareRendering).toBeUndefined();
+ delete (window as { ogb?: unknown }).ogb;
+ applySoftwareRendering();
+ expect(document.documentElement.dataset.softwareRendering).toBeUndefined();
+ });
+});
diff --git a/src/lib/software-rendering.ts b/src/lib/software-rendering.ts
new file mode 100644
index 0000000000..8c0a4196a0
--- /dev/null
+++ b/src/lib/software-rendering.ts
@@ -0,0 +1,4 @@
+/** Linux without a GPU (electron/linux-gpu.mjs) redraws every backdrop blur on the CPU, so styles.css drops the pop-ups' blur. */
+export function applySoftwareRendering(): void {
+ if (window.ogb?.softwareRendering === true) document.documentElement.dataset.softwareRendering = "";
+}
diff --git a/src/main.tsx b/src/main.tsx
index 2aecd331a0..89ac913ba6 100644
--- a/src/main.tsx
+++ b/src/main.tsx
@@ -9,6 +9,7 @@ import { loadPageLanguage } from "./lib/language-preference";
import { applySkinChoice, readSkinChoice } from "./lib/skins";
import { applyChatWidth, readChatWidth } from "./lib/chat-width";
import { applyFont, readFont } from "./lib/fonts";
+import { applySoftwareRendering } from "./lib/software-rendering";
import { settleAdvancedModeDefault } from "./lib/interface-mode";
import { BrowserSignInPage } from "./pair/BrowserSignInPage";
import { PairPage } from "./pair/PairPage";
@@ -21,6 +22,7 @@ import "./styles.css";
settleAdvancedModeDefault();
applySkinChoice(readSkinChoice());
applyFont(readFont());
+applySoftwareRendering();
applyChatWidth(readChatWidth());
const pageLanguage = loadPageLanguage();
diff --git a/src/styles.css b/src/styles.css
index d8f1f0e614..2848e601f6 100644
--- a/src/styles.css
+++ b/src/styles.css
@@ -1678,6 +1678,13 @@ body {
background: color-mix(in srgb, black 50%, transparent);
}
}
+/* Linux without a GPU (electron/linux-gpu.mjs): the blur is redrawn on the CPU and keeps the fan busy, so pop-ups are solid. */
+:root[data-software-rendering] .glass-surface {
+ background: var(--color-menu);
+ -webkit-backdrop-filter: none;
+ backdrop-filter: none;
+}
+:root[data-software-rendering] .glass-surface .bg-card { background: var(--color-card); }
@media (forced-colors: active) {
.glass-surface,
.glass-card {
diff --git a/src/types/ogb.d.ts b/src/types/ogb.d.ts
index 2a64afa7f5..919cf389f0 100644
--- a/src/types/ogb.d.ts
+++ b/src/types/ogb.d.ts
@@ -117,6 +117,7 @@ const __APP_VERSION__: string;
interface Window {
ogb?: {
platform: NodeJS.Platform;
+ softwareRendering?: boolean;
/** This app's own version, and whether this page is this app's own: false on a server added in the Server menu,
* whose page carries that server's version. Absent in desktop builds before it. */
app?: { version: string; ownPage: boolean };