Skip to content

Commit 7b5421c

Browse files
authored
🤖 fix: skip splash screen on macOS dock reactivation (#854)
## Problem `ERR_FAILED (-2)` loading `splash.html` from ASAR intermittently on macOS dock reactivation because: - macOS App Nap throttles idle apps - File descriptors to ASAR archive may be reclaimed after inactivity - The `activate` event fires before I/O is fully responsive ## Solution Skip the splash screen on reactivation. Services are already loaded from initial launch, so window creation is fast (~100ms). The splash exists to cover heavy initialization—unnecessary on reactivation. **-20 LoC, +2 LoC** (net: -18) ## Alternatives Considered | Option | Tradeoff | |--------|----------| | Retry with backoff | Adds complexity, user still sees delay on failure | | Disable App Nap | System-wide side effects, not recommended | | Inline splash HTML as data URL | Avoids file I/O but complicates build | _Generated with `mux`_
1 parent 543850b commit 7b5421c

File tree

1 file changed

+2
-20
lines changed

1 file changed

+2
-20
lines changed

src/desktop/main.ts

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -557,27 +557,9 @@ if (gotTheLock) {
557557
});
558558

559559
app.on("activate", () => {
560-
// Only create window if app is ready and no window exists
561-
// This prevents "Cannot create BrowserWindow before app is ready" error
560+
// Skip splash on reactivation - services already loaded, window creation is fast
562561
if (app.isReady() && mainWindow === null) {
563-
void (async () => {
564-
try {
565-
await showSplashScreen();
566-
await loadServices();
567-
createWindow();
568-
} catch (error) {
569-
console.error(`[${timestamp()}] Failed to recreate window:`, error);
570-
closeSplashScreen();
571-
572-
const errorMessage =
573-
error instanceof Error ? `${error.message}\n\n${error.stack ?? ""}` : String(error);
574-
575-
dialog.showErrorBox(
576-
"Window Creation Failed",
577-
`Failed to recreate the application window:\n\n${errorMessage}`
578-
);
579-
}
580-
})();
562+
createWindow();
581563
}
582564
});
583565
}

0 commit comments

Comments
 (0)