Skip to content

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

fix(linux): gate evdev readers on cursor mode, and document the input group

Etienne Lescot0cbcc42e0469
diff --git a/electron/native/README.md b/electron/native/README.md
index 4b12c7061..9bd69ae81 100644
--- a/electron/native/README.md
+++ b/electron/native/README.md
@@ -89,8 +89,8 @@ Encoder selection: by default the helper keeps the existing sink-writer path fir
Frame input path: the helper feeds the encoder from the GPU when it can. On that path it copies the WGC frame across a keyed-mutex bridge to a second D3D11 device, converts BGRA to NV12 with the D3D11 video processor, and submits an allocator-owned DXGI sample to the hardware H.264 encoder, so no frame ever passes through system memory. The alternative is the original path: a staging texture, `Map(D3D11_MAP_READ)`, and a row-by-row copy into an `IMFMediaBuffer` — which is where a driver stall costs a recording (issue #252). The GPU path is a preference, never a requirement: it is skipped outright for `preferSoftwareEncoder` and for inline webcam PiP (both need the frame in system memory), and it degrades to the CPU path on its own if the encoding device, the NV12 video processor, the shared bridge texture, the DXGI sample allocator, or the hardware sink writer is unavailable. The GPU path is OFF by default: it fixed #252 on the machine that reproduces it and broke recording outright in #336, and its fallbacks only cover failures during `initialize()`, not one that appears once frames are flowing. Set `OPENSCREEN_WGC_ENABLE_DXGI_INPUT=1` to turn it on. Because the two paths land on different encoders and hardware MFTs default to constant bitrate, the GPU path asks for VBR through `ICodecAPI`; without it a static screen spends the full configured budget (measured 16.9 Mbps against 1.95 for the same desktop).
-The helper reports the outcome through the `encoder-selection` stdout event (`video` is `default`, `software-preferred`, or `software-fallback`; `videoInput` is `dxgi-nv12` or `cpu-rgb32`; `container` is `fragmented-mp4` or `mp4`; all three report what the encoder settled on rather than what was asked for). On the GPU path the helper also prints one `[frame-drops] gpu_bridge_contended=<n>` line to stderr at stop: a frame the bridge was too busy to take is skipped rather than failing the recording, and a large count there is the first thing to look at in a report about missing frames. When the app sees `software-fallback` — the default encoder failed and the helper switched on its own — it shows a small dismissible notice in the recording HUD with a "Don't show again" option, because software encoding can raise CPU usage. An explicit `software-preferred` selection shows no notice, and the event stays available for diagnostics either way.
-
+The helper reports the outcome through the `encoder-selection` stdout event (`video` is `default`, `software-preferred`, or `software-fallback`; `videoInput` is `dxgi-nv12` or `cpu-rgb32`; `container` is `fragmented-mp4` or `mp4`; all three report what the encoder settled on rather than what was asked for). On the GPU path the helper also prints one `[frame-drops] gpu_bridge_contended=<n>` line to stderr at stop: a frame the bridge was too busy to take is skipped rather than failing the recording, and a large count there is the first thing to look at in a report about missing frames. When the app sees `software-fallback` — the default encoder failed and the helper switched on its own — it shows a small dismissible notice in the recording HUD with a "Don't show again" option, because software encoding can raise CPU usage. An explicit `software-preferred` selection shows no notice, and the event stays available for diagnostics either way.
+
At startup the helper also emits `capture-adapter`, naming the GPU its D3D device landed on and the one actually driving the captured display, each with its LUID, plus one `[adapters]` line per enumerated adapter on stderr. `createD3DDevice` asks for the *default* adapter and nothing checks that it is the one driving the display; when they differ every frame crosses an adapter boundary before the caller touches it. The LUIDs are there because the descriptions are not enough to tell: an IddCx virtual display driver renders through the physical GPU and inherits its description string while being a separate DXGI adapter, so the configuration this diagnostic exists to catch is precisely the one where both names are identical and only the LUIDs differ (measured: `NVIDIA Quadro RTX 4000` at LUID `0:24084` driving the display, the same string at `0:12889146` for the virtual adapter). `monitorLookup` says which of three things happened: `ok`, `no-output-claims-it` (the enumeration finished and nothing owns the captured monitor, which is what an active virtual display looks like), or `unavailable` (`EnumOutputs` refused, as it does in session 0 — the outputs were never inspected, so the absence means nothing about the hardware).
Encoder diagnostic on final sink-writer failure: when the final sink-writer attempt fails (`MFCreateSinkWriterFromMediaSink` on the fragmented container, `MFCreateSinkWriterFromURL` on the plain one; the message names which), the helper logs the registered H.264 video encoder MFT count (via `MFTEnumEx`), the registered AAC encoder count when audio was requested, and the hex HRESULT. If no H.264 encoder is registered, it additionally emits the four-bullet actionable error (missing Media Feature Pack / GPU driver registration / empty `HKLM:\SOFTWARE\Microsoft\Windows Media Foundation\Transforms` / reboot). If an H.264 encoder IS registered but the sink writer still failed, it logs a hint pointing at invalid output path, missing MP4 mux, or GPU driver incompatibility. There is still no fail-fast pre-flight gate because `MFTEnumEx` and the sink writer can disagree about which H.264 encoders are available in non-interactive / Session 0 contexts.
diff --git a/electron/native/pipewire-capture/src/input.rs b/electron/native/pipewire-capture/src/input.rs
index a94f2188c..96ce9dc9c 100644
--- a/electron/native/pipewire-capture/src/input.rs
+++ b/electron/native/pipewire-capture/src/input.rs
@@ -35,16 +35,33 @@ pub fn is_left_button_press(event_type: EventType, code: u16, value: i32) -> boo
event_type == EventType::KEY && code == KeyCode::BTN_LEFT.0 && value == 1
}
+/// What [`spawn_readers`] settled on — the caller uses it to tell the log why
+/// Linux clicks are or are not being captured.
+///
+/// The two ways of ending up without clicks are NOT the same event: no readable
+/// node is a permission the operator may still want to grant, while `DISABLE_ENV`
+/// is one they explicitly declined — recommending the `input` group there answers
+/// a question nobody asked.
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub enum ClickCapture {
+ /// Turned off by `OPENSCREEN_DISABLE_CLICK_CAPTURE`; nothing was opened.
+ Disabled,
+ /// No readable `/dev/input` node reports `BTN_LEFT` — the common case, when
+ /// the user is not in the `input` group.
+ NoDevice,
+ /// At least one device is open, with a reader thread running on it.
+ Active,
+}
+
/// Opens every readable pointer device that reports `BTN_LEFT` and spawns a
-/// reader thread per device. Returns whether at least one was opened — the caller
-/// uses that to tell the log why Linux clicks are or are not being captured.
+/// reader thread per device.
///
/// Never fails: an unreadable node (the common case, when the user is not in the
/// `input` group) is skipped by `evdev::enumerate`, and no readable node at all
/// simply means every sample stays `"move"`, exactly as before this existed.
-pub fn spawn_readers(sender: &Sender<Message>) -> bool {
+pub fn spawn_readers(sender: &Sender<Message>) -> ClickCapture {
if std::env::var_os(DISABLE_ENV).is_some() {
- return false;
+ return ClickCapture::Disabled;
}
let mut opened = 0usize;
for (_path, device) in evdev::enumerate() {
@@ -55,7 +72,11 @@ pub fn spawn_readers(sender: &Sender<Message>) -> bool {
let forward = sender.clone();
thread::spawn(move || read_device(device, forward));
}
- opened > 0
+ if opened > 0 {
+ ClickCapture::Active
+ } else {
+ ClickCapture::NoDevice
+ }
}
fn device_reports_left_button(device: &Device) -> bool {
diff --git a/electron/native/pipewire-capture/src/main.rs b/electron/native/pipewire-capture/src/main.rs
index 0a21fc0af..51387eb7f 100644
--- a/electron/native/pipewire-capture/src/main.rs
+++ b/electron/native/pipewire-capture/src/main.rs
@@ -298,11 +298,16 @@ fn main() {
let (sender, receiver) = mpsc::channel::<Message>();
spawn_stdin_reader(sender.clone());
spawn_portal(sender.clone(), cursor_mode);
- // Left-button telemetry from evdev. Absent when the user is not in the
- // `input` group; a session that paints no cursor has no use for it either.
- // Warn in that case so a "clicks do nothing on Linux" report is answerable
- // from the log alone rather than looking like a capture bug.
- if !input::spawn_readers(&sender) && cursor_mode.reports_cursor() {
+ // Left-button telemetry from evdev. Gated on the cursor mode FIRST: a session
+ // that paints no cursor emits no samples to tag, so opening every pointer node
+ // and blocking a thread on each would buy nothing. Warn only when the devices
+ // are unreadable — never when the operator opted out through the env var,
+ // which would recommend the permission they just declined — so a "clicks do
+ // nothing on Linux" report is answerable from the log alone rather than
+ // looking like a capture bug.
+ if cursor_mode.reports_cursor()
+ && input::spawn_readers(&sender) == input::ClickCapture::NoDevice
+ {
let _ = emitter.emit(&Event::Warning {
code: "click-capture-unavailable".to_owned(),
message: "no readable /dev/input pointer device — add this user to the 'input' \
diff --git a/website/docs/installation.md b/website/docs/installation.md
index d71f0197c..1a4272625 100644
--- a/website/docs/installation.md
+++ b/website/docs/installation.md
@@ -24,7 +24,7 @@ Download the latest installer for your platform from the [download page](/downlo
|---|---|---|
| **Windows** | Windows 10 version 1903 (build 18362) or later, Intel 8th Gen / AMD Ryzen 2000 series or newer | Windows 11, Intel 12th Gen / AMD Ryzen 4000 series or newer |
| **macOS** | macOS 12.3 (Monterey) — required by ScreenCaptureKit for native capture | macOS 14 or later |
-| **Linux** | `xdg-desktop-portal` and PipeWire for native capture and system audio (default on Ubuntu 22.04+, Fedora 34+) — recording still works without them through the [browser-capture fallback](#platform-differences), with fewer capabilities | Same, kept up to date |
+| **Linux** | `xdg-desktop-portal` and PipeWire for native capture and system audio (default on Ubuntu 22.04+, Fedora 34+) — recording still works without them through the [browser-capture fallback](#platform-differences), with fewer capabilities. Recording mouse clicks on Wayland additionally needs your user in the `input` group — see [Mouse clicks on Wayland](#mouse-clicks-on-wayland) | Same, kept up to date |
| **RAM** | 8 GB | 16 GB |
:::note Older integrated graphics on Windows
@@ -111,6 +111,18 @@ Home Manager users can use `openscreen.homeManagerModules.default` with the same
You may need to grant screen-recording permission depending on your desktop environment.
+### Mouse clicks on Wayland
+
+Wayland exposes no portal for input events, so OpenScreen reads left-button presses straight from the kernel's evdev interface (`/dev/input/event*`) instead. Those device nodes are owned by `root:input`, so a recording only distinguishes a click from ordinary cursor movement when your user is in the `input` group:
+
+```bash
+sudo usermod -aG input $USER
+```
+
+Log out and back in for the new group to take effect. Nothing breaks without it — recording works exactly as it did before, and every cursor sample is simply recorded as a move.
+
+The scope is deliberately narrow: only the left mouse button (`BTN_LEFT`) is ever read, never keystrokes. To turn the reader off entirely even where the permission exists, set `OPENSCREEN_DISABLE_CLICK_CAPTURE=1` in the environment OpenScreen is launched from.
+
## Platform differences
The editing tools are the same everywhere — zooms, backgrounds, crop/trim/speed, annotations, transcription, captions, and projects. Every export format works on every platform; what differs is **capture**, and how fast MP4 encodes on Linux: