Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

docs: sync the single-instance notes with the Electron-only lock

Etienne Lescote271c4344d4c
diff --git a/AGENTS.md b/AGENTS.md
index 8864fdf57..bfa79b498 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -50,7 +50,7 @@ Unit/browser tests can't exercise real capture (native screen recording, a physi
**Launch the app**
- Normal: `npm run dev` — Vite serves the renderer and `vite-plugin-electron` opens the Electron window. The main process logs `Global shortcut registered: CommandOrControl+Shift+O` when ready (Ctrl/Cmd+Shift+O toggles the HUD).
-- The app is single-instance: a lock dir at `%TEMP%/openscreen-single-instance-<user>.lock` (macOS: `$TMPDIR`). If a stale Electron process holds it, a new launch quits silently (exit 0, no window). Kill leftover `electron` processes and delete that lock dir before relaunching.
+- The app is single-instance through `app.requestSingleInstanceLock()`, which keys on the `userData` path. If a leftover Electron process still holds it, a new launch quits silently (exit 0, no window) — kill leftover `electron` processes before relaunching. The lock is held by the OS and dies with the process, so there is nothing to clean up on disk. A dev build and the installed `Openscreen` resolve different `userData` paths and can run side by side.
- **From a git worktree** (no `node_modules`/native binaries): junction/symlink `node_modules` from the main checkout (deps are usually identical — check `package-lock.json`), and copy the prebuilt native capture binaries from `electron/native/bin/<platform>/` (gitignored — rebuilding needs the full VS/Xcode toolchain). Then `npm run dev` works normally.
**Granting access**
diff --git a/technical-documentation/architecture/export-pipeline.md b/technical-documentation/architecture/export-pipeline.md
index e8e0b2067..0068fdf4c 100644
--- a/technical-documentation/architecture/export-pipeline.md
+++ b/technical-documentation/architecture/export-pipeline.md
@@ -144,9 +144,11 @@ Each cost hours and each produced a confident, wrong conclusion.
against the new renderer. It read as "export IPC not registered" once
and as "the bench flag does nothing" once. The bench now refuses to
run against one.
-9. **The installed app (`openscreen.exe`) holds the same single-instance
- lock as the dev build.** A launch exits 0 and reports nothing —
- silently.
+9. **A second instance of the same build quits silently.** The lock keys
+ on the `userData` path, so another dev build already running makes a
+ launch exit 0 and report nothing. The installed app
+ (`openscreen.exe`) resolves a different `userData` path and does not
+ conflict.
## A truncated project file is unopenable, not partially readable
diff --git a/technical-documentation/engineering/rendering-performance.md b/technical-documentation/engineering/rendering-performance.md
index af5a7189d..64d48f88a 100644
--- a/technical-documentation/engineering/rendering-performance.md
+++ b/technical-documentation/engineering/rendering-performance.md
@@ -379,7 +379,7 @@ The first frames of a 4-second export cost 358/113/28/350 ms — 10.3 ms/frame o
- Electron cannot transfer an ArrayBuffer renderer→main. The transfer list takes `MessagePort[]`; transferring a buffer silently drops the whole message ([electron#34905](https://github.com/electron/electron/issues/34905)) — it works renderer→renderer.
- `Buffer.from(typedArray)` copies. Wrapping (`Buffer.from(buf.buffer, byteOffset, byteLength)`) measured +31 %.
- A stale `dist-electron` bundle runs the *previous* main process against the new renderer. It read as "export IPC not registered" once and as "the bench flag does nothing" once. The bench now refuses to run against one.
-- The installed app (`openscreen.exe`) holds the same single-instance lock as the dev build. A launch exits 0 and reports nothing — silently.
+- A second instance of the same build quits silently: the lock keys on the `userData` path, so another dev build already running makes a launch exit 0 and report nothing. The installed app (`openscreen.exe`) resolves a different `userData` path and does not conflict.
## What the numbers mean
diff --git a/technical-documentation/testing/manual-e2e-checklist.md b/technical-documentation/testing/manual-e2e-checklist.md
index 80a47ed21..f0cce7369 100644
--- a/technical-documentation/testing/manual-e2e-checklist.md
+++ b/technical-documentation/testing/manual-e2e-checklist.md
@@ -7,7 +7,7 @@ Sections marked **v1.8.0** cover what this release changed: chat-driven editing
## How to run this
1. Drive the real Electron app with computer-use, not a browser shim. Start a dev build with `npm run dev`, or launch the packaged build under test.
-2. The app is single-instance. If a stale process holds the lock, stop the leftover Electron/OpenScreen process and remove the per-user lock directory before relaunching; a second launch can exit successfully without opening a window.
+2. The app is single-instance per `userData` path. If a leftover Electron/OpenScreen process still holds the lock, stop that process before relaunching; a second launch can exit successfully without opening a window. The lock is held by the OS and is released when the process dies, so there is nothing to delete on disk.
3. From a worktree, link or junction `node_modules` to the main checkout and provide the prebuilt native capture binaries for the platform before starting the dev build.
4. Grant computer-use access to the process name that actually owns the window: `electron.exe` or `Electron.app` for a dev build, and `Openscreen.exe` or `Openscreen.app` for a packaged build. Do not grant access only to the installed app name when testing a dev build.
5. Read [AGENTS.md](../../AGENTS.md) for the computer-use mechanics, screenshot permissions, tray interaction, and cleanup procedure. Read one check, perform it, observe the result, then continue; close each modal or popover with `Esc` before the next check.
diff --git a/tests/e2e/gif-export.spec.ts b/tests/e2e/gif-export.spec.ts
index 1ff2b74b5..887681270 100644
--- a/tests/e2e/gif-export.spec.ts
+++ b/tests/e2e/gif-export.spec.ts
@@ -27,10 +27,9 @@ async function launchApp(userDataDir: string, tmpDir: string) {
env: {
...process.env,
ELECTRON_USER_DATA_DIR: userDataDir,
- // `acquireStableInstanceLock` keys its lock directory off `os.tmpdir()` and
- // the *user id* — not off userData — so a dev instance running from any
- // worktree would otherwise make this launch quit instantly (exit code 0, no
- // window, no stderr). Giving the app its own temp dir gives it its own lock.
+ // Keep this run's scratch files out of the shared temp dir so a dev instance
+ // cannot collide with them. The single-instance lock keys on userData, which
+ // `--user-data-dir` above already makes private to this launch.
TMPDIR: tmpDir,
TMP: tmpDir,
TEMP: tmpDir,