Repository navigation
Process Management
Role. Start each browser in a known, isolated state, and never leave one behind: not a process, not a profile, not a cache. Module process, package internal/process.
- In: a discovered browser (executable, family), a root for temp dirs, and per family a few options (font parity, viewport, a template profile).
-
Out: a running browser the drivers can talk to (
Blink,Gecko,WebKitfor WebKitGTK, WPE and Safari), each with aClosethat kills the whole tree and deletes its temp dir.
Every browser starts through spawn:
- A fresh temp dir
<root>/omnisnap-<pid>-<n>/with anowner.locknaming omnisnap's pid, and agroup.locknaming the browser's pid, which is its process group id (profile.go). The profile lives inside it; never the user's profile (Chrome 136 and later also refuse remote debugging on the default data dir). - The browser leads its own process group on Unix (
pgroup_unix.go), so renderers, the zygote and utility processes can be signalled at once. On Windows it goes into a Job Object withJOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE(job_windows.go). - The last 16 KB of its output are kept for error messages.
Handle.Close kills the tree (the group, or the job), waits for the exit, and only then removes the temp dir.
| Family | Launch |
|---|---|
| Blink |
--headless=new --hide-scrollbars --no-first-run --no-default-browser-check --force-device-scale-factor=1 --disk-cache-size=1 --media-cache-size=1 --remote-debugging-port=0 --user-data-dir=<temp> (blink.go). OMNISNAP_NO_SANDBOX=1 adds --no-sandbox --disable-dev-shm-usage for restricted hosts (CI containers, Ubuntu 24.04+ AppArmor); the product never sets it itself. |
| Gecko | headless, --remote-debugging-port=0, a profile whose user.js sets overlay scrollbars, devPixelsPerPx 1.0, no disk cache, and the font-parity font.name.<generic>.<lang> prefs (prefs.go). Snap Firefox gets its profile under ~/snap/firefox/common/, because its /tmp is private. |
| WebKitGTK (Linux) |
WebKitWebDriver on a free port; MiniBrowser with font-family arguments, on a private Weston headless display started for it (webkit.go). No GPU and no desktop session: GSK_RENDERER=cairo, WEBKIT_DISABLE_DMABUF_RENDERER=1, GDK_DEBUG=no-portals. Without Weston, or with WEBKIT_HEADLESS=0, the windows are visible. |
| WPE (Linux) |
WPEWebDriver; MiniBrowser --headless --size=<viewport> and a config file carrying the font families (wpe.go). No compositor; the viewport is exact. |
| Safari (macOS) |
safaridriver on a free port (safari_darwin.go); a visible window by design. |
Branded browsers start from a copy of a warmed template profile (template.go, Branded browsers). Only the branded checks start Blink with a window (StartBlinkVisible); the product always runs it headless.
-
Normal exit. The CLI closes every engine with
defer(run.go): sessions, the process tree, the temp dir. -
Abnormal exit. SIGINT, SIGTERM and SIGHUP cancel the job's context (
root.go,signals_unix.go), and the samedeferruns. On Windows, if omnisnap is killed outright, the kernel closes the Job Object handle and kills every browser in it. -
The next start. Before any command other than
versionandhelp, the sweeper removesomnisnap-*temp dirs whoseowner.locknames a process that is gone, and kills the process group in theirgroup.lock(sweep.go,root.go). This is what recovers from SIGKILL and power loss. Foreign directories, and the current process's own, are never touched.
No disk caches are kept: a crawl would otherwise write hundreds of MB per session, and on WSL the virtual disk never gives the space back.
A browser that does not come up (no DevTools endpoint, a driver that does not answer GET /status) returns an error with its output tail; the CLI skips that engine with the reason. A crashed browser during a job is replaced once by the CLI's restartable wrapper (CLI and orchestration, Capture pipeline).
-
TestCloseKillsTheProcessGroup,TestExitedBrowserIsReapedOnlyByClose. -
TestJobObjectKillsTheProcessTreeandTestTerminatingOmnisnapKillsEveryBrowser: it builds the binary, starts a job against a page that never finishes, callsTerminateProcesson omnisnap, and checks that every descendant exits. -
sweep_test.go: the sweep decisions, the leftover group killed, andTestTwentyKilledRunsAreSwept. -
TestBlinkArgsMatchTheSpec,TestGeckoPrefsGolden,TestWebKitFontArgs,TestGDKDebugNoPortals. - Launch and close cycles with real browsers (
browsersbuild tag):TestBlinkLaunchCloseCycles,TestGeckoLaunch,TestWebKitLaunch,TestWebKitCyclesLeaveNoProcesses.
- No cap on live browsers. The spec asks for "a configurable cap on concurrently live browsers (default 3)". There is none in the code; the number is bounded only by one browser per engine per job.
-
Weston per WebKitGTK launch, not per process. The spec has one private Weston per omnisnap process, started lazily.
StartWebKitstarts a display for each WebKitGTK launch and stops it onClose. In a job that is one display, since there is one browser per engine; a relaunched WebKitGTK gets a new one.
-
internal/process/launch.go:Handle: spawn, the profile,Close -
internal/process/blink.go:StartBlink: Blink's flags -
internal/process/blink_visible_linux.go: visible Blink windows on Linux -
internal/process/blink_visible_other.go: visible Blink windows elsewhere -
internal/process/gecko.go:StartGecko: Firefox's flags and the BiDi wait -
internal/process/prefs.go: Firefox's user.js preferences -
internal/process/webkit.go: WebKitGTK and its Weston display (Linux) -
internal/process/wpe.go:StartWPE(Linux) -
internal/process/safari_darwin.go:StartSafari(macOS) -
internal/process/driver.go: waiting for a WebDriver server -
internal/process/profile.go: temporary profile directories -
internal/process/sweep.go:Sweep: leftovers from a killed run -
internal/process/launch_unix.go: killing the process tree, on Unix -
internal/process/launch_windows.go: killing the process tree, on Windows -
internal/process/pgroup_unix.go: process groups, on Unix -
internal/process/pgroup_windows.go: process groups, on Windows -
internal/process/job_windows.go: Windows job objects -
internal/process/wait_linux.go: waiting for an exit without reaping, on Linux -
internal/process/wait_other.go: the same, elsewhere
This wiki is published from docs/internals/ on main. Edits made here are overwritten on the next publish: change the pages there, in a pull request. The specs are normative; where a page and a spec disagree, the page says what the code does.
Start
Contracts
Capture side
Analysis side
Output
Quality