diff --git a/electron-builder.json5 b/electron-builder.json5 index 1bc4db5d4..33f516d38 100644 --- a/electron-builder.json5 +++ b/electron-builder.json5 @@ -171,7 +171,20 @@ // `app.setName()` in electron/main.ts sets the same string for an unpackaged // run, where there is no Info.plist to read. "CFBundleDisplayName": "RoleModel Studio", - "CFBundleName": "RoleModel Studio", + // CFBundleName is deliberately NOT overridden. + // + // Electron resolves its helper apps from CFBundleName. electron-builder names + // them after `productName`, so they ship as "Openscreen Helper.app" — and + // setting CFBundleName to "RoleModel Studio" made Electron look for + // "RoleModel Studio Helper.app", find nothing, and abort before drawing a + // window: + // + // FATAL:electron_main_delegate_mac.mm:65] Unable to find helper app + // + // That is what made v0.0.1 unopenable. Nothing is lost by leaving it alone: + // the menu bar reads "RoleModel Studio" because electron/main.ts calls + // `app.setName(PRODUCT_NAME)` at module scope, and Finder, the Dock, the + // About panel and every permission prompt read CFBundleDisplayName above. // These are quoted verbatim in the macOS permission dialogs, so they say the // name of the app the person is being asked about. "NSAudioCaptureUsageDescription": "RoleModel Studio needs audio capture permission to record system audio.", diff --git a/electron/main.ts b/electron/main.ts index dee0edc7f..97025bfbe 100644 --- a/electron/main.ts +++ b/electron/main.ts @@ -1092,6 +1092,13 @@ if (!cliCommand) { app.on("activate", () => { if (cliCommand) return; + // `activate` can arrive before `whenReady`, the same way `open-file` can — and + // the window this ends up building measures the primary display, which throws + // "The 'screen' module can't be used before the app 'ready' event" and takes the + // main process with it. Launching the binary directly is enough to see it. + // Nothing is lost by ignoring an early activate: whenReady creates the window + // anyway, and macOS re-sends activate when the dock icon is clicked. + if (!app.isReady()) return; // On macOS, re-open a window when the dock icon is clicked and none are open. const hasVisibleWindow = BrowserWindow.getAllWindows().some((window) => { if (window.isDestroyed() || !window.isVisible()) {