diff --git a/GPU-FIX-README.md b/GPU-FIX-README.md index 223f878..7746327 100644 --- a/GPU-FIX-README.md +++ b/GPU-FIX-README.md @@ -21,27 +21,35 @@ This is caused by GPU compositing conflicts between Electron's Chromium renderer ### Solution -**Option 1: Automatic Detection (Recommended)** -The latest version of Nebula automatically detects SteamOS/Gamescope and applies the necessary fixes. Simply update to the latest version. +**Automatic Detection (v1.3.3+)** +The latest version of Nebula automatically detects SteamOS/Gamescope and applies the necessary fixes in both development and packaged builds. + +**For AppImage/Packaged Builds:** + +If the automatic detection isn't working, you can launch the AppImage with flags: -**Option 2: Manual Launch Script** -Use the provided `start-steamos.sh` script: ```bash -chmod +x start-steamos.sh -./start-steamos.sh +# Run the AppImage with SteamOS flags +./Nebula-*.AppImage --ozone-platform=x11 --disable-gpu-compositing --disable-gpu-vsync --no-sandbox --disable-dev-shm-usage --disable-features=VizDisplayCompositor ``` -**Option 3: Command-line Flags** -If running manually, add these flags: +**Create a custom .desktop file:** + +Copy `nebula-steamos.desktop` to `~/.local/share/applications/` for a Steam Deck optimized launcher: ```bash -electron . --ozone-platform=x11 --disable-gpu-compositing --disable-gpu-vsync --no-sandbox --disable-dev-shm-usage +cp nebula-steamos.desktop ~/.local/share/applications/ ``` -**Option 4: Environment Variable** -Set the `ELECTRON_OZONE_PLATFORM_HINT` environment variable: +**For Development:** ```bash -export ELECTRON_OZONE_PLATFORM_HINT=x11 -npm start +npm run start:steamos +``` + +**Environment Variable Override:** +You can force SteamOS mode by setting an environment variable: +```bash +export SteamDeck=1 +./Nebula-*.AppImage ``` ## Linux (General) diff --git a/main.js b/main.js index 82088eb..6ef1b26 100644 --- a/main.js +++ b/main.js @@ -1,3 +1,66 @@ +// ============================================================================ +// CRITICAL: GPU flags must be applied BEFORE Electron loads +// These must be at the VERY TOP of main.js for packaged apps +// ============================================================================ +if (process.platform === 'linux') { + const fs = require('fs'); + + // Detect SteamOS/Gamescope environment + let isSteamOS = false; + try { + if (fs.existsSync('/etc/steamos-release')) isSteamOS = true; + else if (fs.existsSync('/usr/share/steamos/steamos.conf')) isSteamOS = true; + else if (process.env.GAMESCOPE_WAYLAND_DISPLAY) isSteamOS = true; + else if (process.env.SteamDeck) isSteamOS = true; + else if (process.env.SteamAppId) isSteamOS = true; + else if (fs.existsSync('/etc/os-release')) { + const osRelease = fs.readFileSync('/etc/os-release', 'utf8'); + if (osRelease.includes('SteamOS') || osRelease.includes('steamos')) isSteamOS = true; + } + } catch (e) {} + + // Apply flags via app.commandLine BEFORE requiring electron + // We need to do this via process.argv for packaged apps + const linuxFlags = [ + '--disable-gpu-sandbox', + '--no-sandbox', + '--disable-dev-shm-usage' + ]; + + if (isSteamOS || process.env.GAMESCOPE_WAYLAND_DISPLAY) { + console.log('[GPU] SteamOS/Gamescope detected at startup - applying critical flags'); + linuxFlags.push( + '--ozone-platform=x11', + '--disable-gpu-compositing', + '--disable-gpu-vsync', + '--disable-accelerated-2d-canvas', + '--use-gl=desktop', + '--disable-features=VizDisplayCompositor', + '--enable-features=UseOzonePlatform' + ); + } else { + // General Linux - detect Wayland vs X11 + const waylandDisplay = process.env.WAYLAND_DISPLAY; + const x11Display = process.env.DISPLAY; + + if (waylandDisplay && !x11Display) { + linuxFlags.push('--ozone-platform=wayland', '--enable-features=UseOzonePlatform,WaylandWindowDecorations'); + } else if (x11Display) { + linuxFlags.push('--ozone-platform=x11'); + } + linuxFlags.push('--disable-features=VizDisplayCompositor'); + } + + // Add flags that aren't already present + linuxFlags.forEach(flag => { + const flagName = flag.split('=')[0]; + if (!process.argv.some(arg => arg.startsWith(flagName))) { + process.argv.push(flag); + } + }); +} +// ============================================================================ + const { app, BrowserWindow, ipcMain, session, screen, shell, dialog, Menu, clipboard, webContents } = require('electron'); const { autoUpdater } = require('electron-updater'); const { pathToFileURL } = require('url'); diff --git a/nebula-steamos.desktop b/nebula-steamos.desktop new file mode 100644 index 0000000..cd7cc38 --- /dev/null +++ b/nebula-steamos.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Name=Nebula Browser (SteamOS) +Comment=Nebula Browser optimized for SteamOS/Steam Deck +Exec=nebula --ozone-platform=x11 --disable-gpu-compositing --disable-gpu-vsync --no-sandbox --disable-dev-shm-usage --disable-features=VizDisplayCompositor %U +Icon=nebula +Type=Application +Categories=Network;WebBrowser; +StartupWMClass=nebula +MimeType=x-scheme-handler/http;x-scheme-handler/https; diff --git a/package.json b/package.json index 40f2eea..f65c8a1 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,25 @@ "icon": "assets/images/Logos/Nebula-Favicon.ico" }, "linux": { - "icon": "assets/images/Logos/Nebula-Favicon.png" + "icon": "assets/images/Logos/Nebula-Favicon.png", + "target": [ + { + "target": "AppImage", + "arch": ["x64"] + }, + { + "target": "deb", + "arch": ["x64"] + } + ], + "category": "Network", + "desktop": { + "StartupWMClass": "nebula" + }, + "executableArgs": [ + "--no-sandbox", + "--disable-gpu-sandbox" + ] } } }