fix: Linux sandbox issue
This commit is contained in:
@@ -10,9 +10,14 @@ const path = require("path");
|
|||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const os = require("os");
|
const os = require("os");
|
||||||
|
|
||||||
// Only disable hardware acceleration if explicitly requested or on older systems
|
if (process.platform === "linux") {
|
||||||
if (process.env.DISABLE_GPU === "1") {
|
app.commandLine.appendSwitch("--no-sandbox");
|
||||||
|
app.commandLine.appendSwitch("--disable-setuid-sandbox");
|
||||||
|
app.commandLine.appendSwitch("--disable-dev-shm-usage");
|
||||||
|
|
||||||
app.disableHardwareAcceleration();
|
app.disableHardwareAcceleration();
|
||||||
|
app.commandLine.appendSwitch("--disable-gpu");
|
||||||
|
app.commandLine.appendSwitch("--disable-gpu-compositing");
|
||||||
}
|
}
|
||||||
|
|
||||||
app.commandLine.appendSwitch("--ignore-certificate-errors");
|
app.commandLine.appendSwitch("--ignore-certificate-errors");
|
||||||
@@ -20,22 +25,6 @@ app.commandLine.appendSwitch("--ignore-ssl-errors");
|
|||||||
app.commandLine.appendSwitch("--ignore-certificate-errors-spki-list");
|
app.commandLine.appendSwitch("--ignore-certificate-errors-spki-list");
|
||||||
app.commandLine.appendSwitch("--enable-features=NetworkService");
|
app.commandLine.appendSwitch("--enable-features=NetworkService");
|
||||||
|
|
||||||
if (process.platform === "linux") {
|
|
||||||
// Use GPU acceleration on Linux
|
|
||||||
app.commandLine.appendSwitch("--enable-features", "VaapiVideoDecoder");
|
|
||||||
app.commandLine.appendSwitch("--disable-dev-shm-usage");
|
|
||||||
|
|
||||||
// Only disable sandboxing if running in problematic environments
|
|
||||||
// Check if we're in an AppImage or if CHROME_DEVEL_SANDBOX is not set properly
|
|
||||||
const isAppImage = process.env.APPIMAGE != null;
|
|
||||||
const hasProperSandbox = process.env.CHROME_DEVEL_SANDBOX != null;
|
|
||||||
|
|
||||||
if (isAppImage && !hasProperSandbox) {
|
|
||||||
// AppImage environments often have sandbox issues
|
|
||||||
app.commandLine.appendSwitch("--no-sandbox");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let mainWindow = null;
|
let mainWindow = null;
|
||||||
|
|
||||||
const isDev = process.env.NODE_ENV === "development" || !app.isPackaged;
|
const isDev = process.env.NODE_ENV === "development" || !app.isPackaged;
|
||||||
@@ -66,6 +55,12 @@ function createWindow() {
|
|||||||
? "macOS"
|
? "macOS"
|
||||||
: "Linux";
|
: "Linux";
|
||||||
|
|
||||||
|
if (process.platform === "linux") {
|
||||||
|
console.log("DISPLAY:", process.env.DISPLAY);
|
||||||
|
console.log("WAYLAND_DISPLAY:", process.env.WAYLAND_DISPLAY);
|
||||||
|
console.log("XDG_SESSION_TYPE:", process.env.XDG_SESSION_TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
mainWindow = new BrowserWindow({
|
mainWindow = new BrowserWindow({
|
||||||
width: 1200,
|
width: 1200,
|
||||||
height: 800,
|
height: 800,
|
||||||
@@ -81,8 +76,9 @@ function createWindow() {
|
|||||||
partition: "persist:termix",
|
partition: "persist:termix",
|
||||||
allowRunningInsecureContent: true,
|
allowRunningInsecureContent: true,
|
||||||
webviewTag: true,
|
webviewTag: true,
|
||||||
|
offscreen: process.platform === "linux",
|
||||||
},
|
},
|
||||||
show: false,
|
show: process.platform === "linux",
|
||||||
});
|
});
|
||||||
|
|
||||||
if (process.platform !== "darwin") {
|
if (process.platform !== "darwin") {
|
||||||
@@ -103,11 +99,16 @@ function createWindow() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (isDev) {
|
if (isDev) {
|
||||||
|
console.log("Loading dev URL: http://localhost:5173");
|
||||||
mainWindow.loadURL("http://localhost:5173");
|
mainWindow.loadURL("http://localhost:5173");
|
||||||
mainWindow.webContents.openDevTools();
|
mainWindow.webContents.openDevTools();
|
||||||
} else {
|
} else {
|
||||||
const indexPath = path.join(appRoot, "dist", "index.html");
|
const indexPath = path.join(appRoot, "dist", "index.html");
|
||||||
mainWindow.loadFile(indexPath);
|
console.log("Loading file:", indexPath);
|
||||||
|
console.log("File exists:", fs.existsSync(indexPath));
|
||||||
|
mainWindow.loadFile(indexPath).catch(err => {
|
||||||
|
console.error("Failed to load file:", err);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
mainWindow.webContents.session.webRequest.onHeadersReceived(
|
mainWindow.webContents.session.webRequest.onHeadersReceived(
|
||||||
@@ -170,9 +171,17 @@ function createWindow() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
mainWindow.once("ready-to-show", () => {
|
mainWindow.once("ready-to-show", () => {
|
||||||
|
console.log("Window ready-to-show event fired");
|
||||||
mainWindow.show();
|
mainWindow.show();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
if (mainWindow && !mainWindow.isVisible()) {
|
||||||
|
console.log("Forcing window to show after timeout");
|
||||||
|
mainWindow.show();
|
||||||
|
}
|
||||||
|
}, 3000);
|
||||||
|
|
||||||
mainWindow.webContents.on(
|
mainWindow.webContents.on(
|
||||||
"did-fail-load",
|
"did-fail-load",
|
||||||
(event, errorCode, errorDescription, validatedURL) => {
|
(event, errorCode, errorDescription, validatedURL) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user