perf(win): portable isolation + faster startup

This commit is contained in:
DeskClaw Bot
2026-04-21 18:45:36 +00:00
Unverified
parent 7e69f75801
commit f1cdb6e396

View File

@@ -57,21 +57,17 @@ if (isE2EMode && requestedUserDataDir) {
app.setPath('userData', requestedUserDataDir); app.setPath('userData', requestedUserDataDir);
} }
// Disable GPU hardware acceleration globally for maximum stability across const portableExecutableDir = process.env.PORTABLE_EXECUTABLE_DIR?.trim();
// all GPU configurations (no GPU, integrated, discrete). const isPortable = Boolean(portableExecutableDir) || process.argv.includes('--portable');
// if (process.platform === 'win32' && isPortable) {
// Rationale (following VS Code's philosophy): const baseDir = portableExecutableDir || process.cwd();
// - Page/file loading is async data fetching — zero GPU dependency. app.setPath('userData', join(baseDir, 'DeskClawData'));
// - The original per-platform GPU branching was added to avoid CPU rendering }
// competing with sync I/O on Windows, but all file I/O is now async
// (fs/promises), so that concern no longer applies. const disableGpu = process.argv.includes('--disable-gpu') || process.env.DESKCLAW_DISABLE_GPU === '1';
// - Software rendering is deterministic across all hardware; GPU compositing if (disableGpu) {
// behaviour varies between vendors (Intel, AMD, NVIDIA, Apple Silicon) and app.disableHardwareAcceleration();
// driver versions, making it the #1 source of rendering bugs in Electron. }
//
// Users who want GPU acceleration can pass `--enable-gpu` on the CLI or
// set `"disable-hardware-acceleration": false` in the app config (future).
app.disableHardwareAcceleration();
// On Linux, set CHROME_DESKTOP so Chromium can find the correct .desktop file. // On Linux, set CHROME_DESKTOP so Chromium can find the correct .desktop file.
// On Wayland this maps the running window to clawx.desktop (→ icon + app grouping); // On Wayland this maps the running window to clawx.desktop (→ icon + app grouping);
@@ -288,20 +284,6 @@ async function initialize(): Promise<void> {
`Runtime: platform=${process.platform}/${process.arch}, electron=${process.versions.electron}, node=${process.versions.node}, packaged=${app.isPackaged}, pid=${process.pid}, ppid=${process.ppid}` `Runtime: platform=${process.platform}/${process.arch}, electron=${process.versions.electron}, node=${process.versions.node}, packaged=${app.isPackaged}, pid=${process.pid}, ppid=${process.ppid}`
); );
if (!isE2EMode) {
// Warm up network optimization (non-blocking)
void warmupNetworkOptimization();
// Initialize Telemetry early
await initTelemetry();
// Apply persisted proxy settings before creating windows or network requests.
await applyProxySettings();
await syncLaunchAtStartupSettingFromStore();
} else {
logger.info('Running in E2E mode: startup side effects minimized');
}
// Set application menu // Set application menu
createMenu(); createMenu();
@@ -313,6 +295,22 @@ async function initialize(): Promise<void> {
createTray(window); createTray(window);
} }
if (!isE2EMode) {
void (async () => {
void warmupNetworkOptimization();
const telemetryEnabled = await getSetting('telemetryEnabled');
if (telemetryEnabled) {
await initTelemetry();
}
await applyProxySettings();
await syncLaunchAtStartupSettingFromStore();
})().catch((error) => {
logger.warn('Deferred startup initialization failed:', error);
});
} else {
logger.info('Running in E2E mode: startup side effects minimized');
}
// Override security headers ONLY for the OpenClaw Gateway Control UI. // Override security headers ONLY for the OpenClaw Gateway Control UI.
// The URL filter ensures this callback only fires for gateway requests, // The URL filter ensures this callback only fires for gateway requests,
// avoiding unnecessary overhead on every other HTTP response. // avoiding unnecessary overhead on every other HTTP response.