-
Notifications
You must be signed in to change notification settings - Fork 2k
Enhancement: WQHD/High-DPI compatibility and Zoom Algorithm Refinements #372
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
43ae073
0085fc5
5e26a63
2f13dc9
ef883b4
a682d4f
dc895e3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,13 +18,33 @@ import { createEditorWindow, createHudOverlayWindow, createSourceSelectorWindow | |
|
|
||
| const __dirname = path.dirname(fileURLToPath(import.meta.url)); | ||
|
|
||
| // Single instance lock | ||
| const gotTheLock = app.requestSingleInstanceLock(); | ||
|
|
||
| if (!gotTheLock) { | ||
| app.quit(); | ||
| } else { | ||
| app.on("second-instance", (_event, _commandLine, _workingDirectory) => { | ||
| // Someone tried to run a second instance, we should focus our window. | ||
| if (mainWindow) { | ||
| if (mainWindow.isMinimized()) mainWindow.restore(); | ||
| mainWindow.focus(); | ||
| } | ||
| }); | ||
| } | ||
|
Comment on lines
+21
to
+34
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. race condition after yo, this is lowkey risky. when common fix is to wrap all app initialization inside the 🛠️ suggested fix - wrap init code in the else block const gotTheLock = app.requestSingleInstanceLock();
if (!gotTheLock) {
app.quit();
-} else {
+ // Note: app.quit() is async, but we need to prevent further initialization
+ // The process will exit soon, but we should not continue setup
+}
+
+// Only proceed with app initialization if we got the lock
+if (gotTheLock) {
app.on("second-instance", (_event, _commandLine, _workingDirectory) => {
// Someone tried to run a second instance, we should focus our window.
if (mainWindow) {
if (mainWindow.isMinimized()) mainWindow.restore();
mainWindow.focus();
}
});
-}
+
+ // ... rest of initialization should be inside this block or guardedalternatively, you could add a guard before if (!gotTheLock) {
app.quit();
// Prevent any further initialization
throw new Error("Another instance is already running");
}or restructure to check the lock before any heavy setup runs. 🤖 Prompt for AI Agents |
||
|
|
||
| // Use Screen & System Audio Recording permissions instead of CoreAudio Tap API on macOS. | ||
| // CoreAudio Tap requires NSAudioCaptureUsageDescription in the parent app's Info.plist, | ||
| // which doesn't work when running from a terminal/IDE during development, makes my life easier | ||
| if (process.platform === "darwin") { | ||
| app.commandLine.appendSwitch("disable-features", "MacCatapLoopbackAudioForScreenShare"); | ||
| } | ||
|
|
||
| if (process.platform === "win32") { | ||
| app.setAppUserModelId("com.siddharthvaddem.openscreen"); | ||
| app.commandLine.appendSwitch("high-dpi-support", "1"); | ||
| } | ||
|
|
||
| export const RECORDINGS_DIR = path.join(app.getPath("userData"), "recordings"); | ||
|
|
||
| async function ensureRecordingsDir() { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
How to configure macOS entitlements in electron-builder for audio input access?💡 Result:
To get microphone (audio input) access working on macOS with electron-builder, you need both:
1) Create an entitlements file (recommended)
build/entitlements.mac.plistApple documents
com.apple.security.device.audio-inputas the entitlement that allows microphone/audio-input access. [1]2) Point electron-builder at the entitlements (+ hardened runtime)
In your
electron-builderconfig:package.json{ "build": { "mac": { "hardenedRuntime": true, "entitlements": "build/entitlements.mac.plist", "entitlementsInherit": "build/entitlements.mac.plist", "extendInfo": { "NSMicrophoneUsageDescription": "This app needs microphone access for voice input." } } } }entitlementssigns the main app with your entitlements.entitlementsInheritsigns helper apps/frameworks with inherited entitlements (electron-builder explicitly supports this and recommends using it). [2]3) If you capture system/desktop audio, add
NSAudioCaptureUsageDescriptiontoo (macOS 14.2+)If you use
desktopCapturerto capture audio, Electron documents that on macOS 14.2+ you must add:NSAudioCaptureUsageDescriptiontoInfo.plist(viaextendInfo) [4]Example:
4) Trigger the permission prompt at runtime
macOS won’t prompt just because the keys exist; you must actually request/use the microphone, e.g.:
navigator.mediaDevices.getUserMedia({ audio: true })(renderer), orsystemPreferences.askForMediaAccess('microphone')(main)(And you must have
NSMicrophoneUsageDescriptionpresent, as above.)Common gotcha
If permissions work in development but not after packaging: the signed .app is a different binary identity than the dev Electron app, so macOS permissions must be granted to (and prompted by) the packaged app.
Sources: Apple entitlement reference [1]; electron-builder Mac configuration (
entitlementsInherit) [2]; electron-builder hardened runtime/notarization guidance [3]; ElectrondesktopCapturerdocs forNSAudioCaptureUsageDescriptionrequirement [4].com.apple.security.device.audio-inputneeds to be in an entitlements file, not extendInfoheads up -
com.apple.security.device.audio-inputis a code signing entitlement, not an Info.plist key. sticking it inextendInfowon't actually do anything. if you're relying on this for sandboxed audio input, it's gonna silently fail.the
NS*keys are legit though - those are meant forextendInfo.you'll need to set this up properly via electron-builder:
build/entitlements.mac.plistwith the entitlementelectron-builder.json5(orpackage.json):keep the
NSMicrophoneUsageDescriptionandNSAudioCaptureUsageDescriptioninextendInfo- those are needed for the permission prompts to actually show up.🤖 Prompt for AI Agents