Skip to content

feat(linux): auto-sample X11 cursor telemetry when portal metadata is missing - #1

Open
Jasonsu22 wants to merge 486 commits into
mainfrom
cursor/x11-cursor-telemetry-fallback-19b6
Open

Jasonsu22 wants to merge 486 commits into
mainfrom
cursor/x11-cursor-telemetry-fallback-19b6

Conversation

@Jasonsu22

@Jasonsu22 Jasonsu22 commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

Summary

On X11 + Xvfb hosts the ScreenCast portal often has no METADATA cursor mode, so editable-cursor takes used to write no sidecar. This PR samples the pointer automatically during record (Electron screen.getCursorScreenPoint(), then xdotool / xinput / xev / libinput) and writes version-2 <video>.cursor.json next to the take. openscreen export --auto-zoom then works with no extra import step.

Also adds openscreen cursor import for an external ffmpeg/x11grab CSV track.

Follow-up on this branch addresses CodeRabbit’s review of the first revision: discard stops the X11 sampler, fallback samples are compacted by pause ranges, the sampler clock starts at capture start, cursor import CSV/write guards are stricter, XI2 rest no longer accumulates, click watchers fail over on child exit, and the browser fallback keeps the source it just picked.

Related issue

Fixes getopenscreen#1415

Type of change

  • Bug fix
  • Feature
  • Enhancement
  • Documentation
  • Refactor / maintenance
  • Performance
  • Security

Release impact

  • Patch
  • Minor
  • Major / breaking change
  • No release note needed

Desktop impact

  • Windows
  • macOS
  • Linux
  • Installer / packaging
  • Not platform-specific

Repro host (from getopenscreen#1415)

Item Value
Host Grok Bot cloud Linux (grok-bot-vm-316768464)
OS Debian 13 (trixie), kernel 6.12.94+ x86_64
Session X11 DISPLAY=:2, Xvfb 1920×1200×24
Portal ScreenCast METADATA unavailable (AvailableSourceTypes=0)
GPU Mesa llvmpipe (CPU export fallback)
OpenScreen tested Linux AppImage 2.1.2

Behavior

  • Auto path: X11 (incl. Xvfb) — PipeWire fail → Electron/xdotool/xinput/xev/libinput; native Linux capture with empty cursor track fills sidecar via parallel X11 sampler
  • CLI: openscreen cursor import --csv mouse.csv --clicks clicks.txt --video take.mp4
  • Env: OPENSCREEN_DISABLE_X11_CURSOR=1 / OPENSCREEN_FORCE_X11_CURSOR=1

Testing

  • Unit tests for sampler / sidecar import / CLI parser / factory (vitest)
  • tsc --noEmit and tsc -p tsconfig.test.json --noEmit
  • Targeted vitest after the CodeRabbit follow-up
  • Maintainer smoke on a normal Linux desktop (should be no-op when METADATA works)
  • Optional: X11/Xvfb agent host record → sidecar present → export --auto-zoom

Notes

Upstream PR (same branch): getopenscreen#1416

Open in Web Open in Cursor 

On GNOME Wayland the HUD bar dropped ~240 px, under the dock or off
screen, whenever a popover opened. The Linux HUD hugs its visible stack,
so the window grew by the panel's height; a Wayland client can neither
set nor read its position, and mutter keeps a resized window's top-left
corner, so the bottom-anchored bar moved down by the growth.

computeHudLinuxStack keeps room for the tallest panel on Wayland and
fits toasts inside it, so opening a panel or showing a toast never
resizes the window. X11 still hugs the stack. The main process tells the
renderer it draws through Wayland with a hudWayland query parameter and
starts the window at the reserve's size there.
On Wayland a client cannot position its windows, so an unmapped camera
preview was placed anew by the compositor every time it came back: at the
top-left on GNOME, over the HUD's audio, microphone, camera and gear
buttons, whatever spot the user had dragged it to.

There the preview is now parked instead of hidden: shrunk to 1x1, where
its margins leave nothing to draw, and grown back on show, so it stays
mapped where the user put it. Resizing it lifts mutter's fixed size hints
first, as the HUD already does, or the resize is ignored.
A toast over the full-height Device settings panel still grew the
Wayland window, moving the bar while it showed. The toast now overlaps
the panel's top instead, so the window keeps its size.

A camera-preview resize while the preview was parked grew it back to
full size mid-capture. The new width is now stored and applied when the
preview comes back.
Chromium pages a large Blob to disk and refuses once the profile's volume
runs low on space, so fetch().blob() of the render rejected with
'TypeError: Failed to fetch' and every audio export longer than a few
seconds failed (v2.3.0-rc.1 Linux pass, 1.8 GB free on a 75 GB disk).
The render is now read with arrayBuffer() into a mediabunny BufferSource,
and its thrown-away picture is encoded at 250 kb/s so those bytes stay
close to the size of the audio.
Chromium pages a Blob the size of an export to disk, and blob() rejects
with "Failed to fetch" once the profile's volume runs low on space. The
CLI voiceover mix read the exported MP4 that way; it now reads it with
arrayBuffer() and hands mediabunny a BufferSource, and returns the mixed
MP4's bytes instead of wrapping them in a Blob.
The timeline walk clamped each clip's end to the camera's end in screen time.
The recorder stamps the webcam WebM with the HUD's wall-clock length, a few
hundred ms short of the native screen file, so every recorded take lost that
tail in MP4 and GIF exports and every later clip started early. The preview
already holds the last camera frame; the export now does the same, and only
the screen bounds the clip.
Radix's hoverable mode kept the tooltip open while the pointer sat in a
triangle towards it, and blocked every other trigger meanwhile. In a
toolbar that triangle covers the next control, so the old tooltip stuck
and the next showed none; on the click-through HUD no later pointer move
reached the page, so it never ended.
Tooltips sat at z 50, under the editor's modals (100) and the Radix
dialogs (10000): the Edit-clip dialog's 180° tip opened unseen.
A preset caps the source height and never upscales, so on a small
project Small/Medium/Large/Original wrote one identical file while the
labels and summary promised 480p/720p/1080p. Each preset now shows its
real size, presets that write the same file fold into the largest, and
the progress line says GIF instead of video.
Tailwind's preflight strips list-style, and ChatMarkdown only restored
the padding. The text of each model call in a turn was appended with
nothing between, so a sentence ran into the next call's first line or
list item; each later call now starts a new paragraph.
ModalShell moved the focus to the dialog itself after its children
mounted, so after Ctrl+O typing went nowhere and Enter opened the
current project. A field marked data-autofocus now takes it.
The speed pane reused the zoom pane's ZoomIn icon; the timeline's speed
pill and Add speed button both use Clock.
The tab was seeded once at mount, and the pane can mount before the
project's wallpaper arrives: a reopened project with a solid colour
showed Image. The tab now follows the wallpaper when it changes kind.
The HUD kept counting after the Linux capture helper died, and Stop then
failed with "The Linux capture helper is not running.", opened no editor
and left the decodable fragmented MP4 orphaned in the recordings folder.

The session now reports an exit it did not ask for, and main drives the
renderer's own stop at once, as on macOS. The stop recovers what the
helper wrote up to its last whole fragment (the macOS salvage walk reads
the Linux layout too), writes the sidecars, and the editor opens on it
with a plain warning. A file with nothing usable is deleted and the user
is told the capture stopped, without the helper's wording.
…ster

On GNOME Wayland the session grants no global shortcut, so Open App
(Ctrl+Shift+O) failed to register at every launch and every Save of the
Keyboard Shortcuts dialog failed on it: no binding could ever change.

When a registration fails, a probe of an unused key tells "this key is
taken" from "this session grants none". In the second case Open App is
reported unavailable, registration stops failing the save, and the
dialog hides the Open App row, which could not work there.
The low-disk check ran in startRecording, after the countdown. On Linux
that also came after the ScreenCast picker, so a HUD start asked what to
share and counted down 3-2-1 before refusing, where a voice-over refuses
at once. The countdown now checks first, on every platform; a start with
no countdown (Restart) still checks in startRecording.
…t take

A take started from Restart has no countdown between the ScreenCast
picker and the first frame, so on GNOME Wayland frame 0 showed the
dialog's closing animation. A new session is now spawned deferred, and
arm() waits until the picker has had 500 ms to leave the screen (mutter
animates a closing window for 150 ms). After a countdown that wait is
long over, and direct X11, which has no picker, arms at once.
…stop

An exited helper can still have the tail of its log in the pipes, so the
fast path read it too early and could miss "Recording stopped". It now
takes the fast path only once stdout and stderr have ended, and waits for
'close' otherwise.

Refs getopenscreen#1561
On the AMD RX 9070 XT the hardware H.264 encoder takes frames but never
hands one on, so IMFSinkWriter::Finalize waits for a drain that never
completes and the helper's 50 s watchdog throws the take away.

Finalize on a hardware encoder now runs on its own thread while the
sink writer's statistics are watched. An encoder that still owes frames
and has produced nothing for 5 s is abandoned: the helper names its
adapter and exits at once. The app remembers that adapter and the next
takes on it use the software encoder.

Refs getopenscreen#1544
An H.264 stream whose pixel format is still unknown after
find_stream_info opens on D3D11VA. When it turns out to be High 10,
4:2:2 or 4:4:4, FFmpeg offers no D3D11 surface, get_hw_format returned
NONE and send_packet failed with Invalid data.

get_hw_format now returns the software format in that case. Decoders
opened with an unknown format get CpuFrames up front, and frames are
routed by their format: D3D11 surfaces as before, software frames
through CpuFrames. Streams with a known format are unchanged.

Refs getopenscreen#1532
get_hw_format now falls back to software when D3D11VA has no surface.
decode_frame_n's callers hand its frame to Compositor::nv12_srvs, which
reads a D3D11 texture, so it returns an error on that path instead.

Refs getopenscreen#1532
Imported footage tagged AVCOL_RANGE_JPEG was drawn as limited range, so
its shadows and highlights clipped in preview and export.

- CpuFrames: set swscale's source range from the frame (full in, limited
  out) before init, so yuv420p/yuv420p10le full-range frames are
  normalised; yuvj* keeps working.
- D3D11VA: nv12_srvs records the frame's range per Y view, draw_video
  binds a tiny immutable cbuffer (b1), and sample_yuv expands full range
  to limited behind a uniform branch. Limited input keeps its exact math.

Refs getopenscreen#1531
…dows

The shader mapped full-range chroma with an offset of 16, so neutral 128
came out at 128.44 and full-range grey rendered tinted (129, 128, 129).
Scale chroma around 128 instead. The CPU path goes through swscale, which
already centres chroma; its test now asserts that too.

A render test draws a full-range (128, 128, 128) NV12 frame through the
D3D11 shader and checks it comes out neutral grey at 128.

Refs getopenscreen#1531
…ware mid-session

Shared preview frames were only checked against GPU compositing when a view
was created. Chromium can fall back to software compositing later (after GPU
process crashes), and importing a shared texture then crashes the main process
with no JS exception. Check before each shared frame and drop the view to
read-back.

Refs getopenscreen#1487
marcgabe15 and others added 10 commits November 28, 2026 22:28
- Allow unnecessary_transmutes on the bindgen-generated ffmpeg bindings,
  next to the lints already allowed there.
- Mark test-only helpers (Capture::is_paused, VideoEncoder::submit,
  sws_threads) #[cfg(test)].
- Drop fields and methods nothing reads: DmabufFrame width/height,
  Frame::pts_ns, FrameMailbox::received.
- Drop two unneeded `mut` bindings in capture tests.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Homebrew moved the macOS arm64 CI job from ffmpeg 9.0.2 to 9.1, whose
retuned AAC encoder leaves this fixture needing +0.95 dB instead of
+1.24 dB, under the old > 1 dB precondition. The rest of the test, the
crests over full scale and the export under -1 dBTP, passes on both.

Refs getopenscreen#1677
The fa locale landed without four keys that main added meanwhile:
common.actions.tryAgain, common.usagePing.notSaved,
dialogs.fileDialogs.selectVideoOrImage and
dialogs.fileDialogs.videoAndImageFiles. localeParity fails on main
without them.

Refs getopenscreen#1642

Co-Authored-By: Claude Opus 5.5 <[email protected]>
en renamed fileDialogs.selectVideo and fileDialogs.videoFiles to
selectVideoOrImage and videoAndImageFiles; i18n:check flags the old
names as extra in fa.

Refs getopenscreen#1642

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-left typewriter reveal

Signed-off-by: Dr. Mohammed Lubbad <[email protected]>
…, and share reveal_quad across backends

Signed-off-by: Dr. Mohammed Lubbad <[email protected]>
… after trailing punctuation

Signed-off-by: Dr. Mohammed Lubbad <[email protected]>
…TL plates, and add reveal render tests

Signed-off-by: Dr. Mohammed Lubbad <[email protected]>
@Jasonsu22
Jasonsu22 force-pushed the cursor/x11-cursor-telemetry-fallback-19b6 branch from 4ee57df to 519e198 Compare December 1, 2026 13:52
claude and others added 18 commits December 1, 2026 15:26
…tretch

ScreenCaptureKit writes no frame while the screen does not change, so a
macOS recording of a still screen has holes of seconds or minutes. A clip
starting inside one failed export with "the screen video has no readable
frame at the clip's start": the clip-start seek rounds forward onto the
next update, and the look-behind added in getopenscreen#1480 only reached 0.5 s back.

For a screen whose container covers the clip start, widen the look-behind
(doubling) until it finds the last update before the cut, then bisect to
the tail margin so a long recording is not decoded for minutes. A camera
keeps the 0.5 s bound: a larger hole there is missing footage.

Frame inspection (render_frames) no longer seeks a decoder forward onto a
future update when the next frame is not due yet.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_019SAKipJpSfMXYXVTd2jzgT
catch_up peeked the next frame to detect a still stretch, then seeked.
The seek cleared that lookahead, and when it reused the current frame
the due update was lost: with updates at 0, 1 and 8 s, frame 63 at
30 fps showed the 0 s frame instead of the 1 s one. Commit a due
lookahead before deciding whether to seek.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_019SAKipJpSfMXYXVTd2jzgT
Manage recordings, in the OpenScreen menu, lists each take in the
recordings folders with its size and the projects that use it. Takes can
be selected one by one, all at once or only the unused ones, then moved
to the Trash with their cursor, session and camera files; if the Trash
refuses, a permanent delete is offered. Deleting a take a project still
uses names that project first, and a project file that does not parse
puts up a warning that usage may be incomplete.

The main process only deletes ids that name a take in a recordings
folder.
A take the project open in the editor uses, in its saved file or only in
its unsaved edits, is listed but cannot be ticked, and the main process
refuses any delete that names one. The editor sends its live document
with both requests, so an agent edit that is not saved yet counts too.

Also drops the dialog's subtitle.
Delete in Manage recordings is disabled until a take is selected, but the
danger style had no disabled state and still lit up on hover, so it looked
clickable.
… dialog

A Trash refusal that lands after the user changed the selection or
cancelled no longer turns the newer confirmation into a permanent
delete. A listing requested before the dialog was reopened no longer
overwrites the newer one.

Refs getopenscreen#1382
… project per removal

A symlink or other alias of a recordings folder named the same take under
a second id, so the open project's take could be listed as deletable and
removed. Takes are now keyed by the folder's real path, for listed ids
and document media paths alike.

A delete also asks which project the editor holds right before each
take goes, so a project opened while the request runs keeps its takes.
Recording dates follow the app's language.

Refs getopenscreen#1376
…ndow

Unowned, the macOS save panel is a free-floating window that an app switch
leaves behind the editor, out of reach. Route it through showSaveDialogOver:
the IPC entry points pass the sender's window, the menu and tray pass the
focused visible window.

Refs getopenscreen#1667
…rsor track

A native Linux take in editable-overlay mode normally gets its cursor from
the capture helper: ScreenCast METADATA, or XFixes and XInput 2 under
direct X11 capture. If the helper still has sent no cursor sample a second
after capture starts, sample the pointer through X11 instead (fresh
read-only xdotool positions converted to DIP; clicks from xinput
test-xi2, with xev / libinput fallbacks) and write that track as the
`<video>.cursor.json` sidecar.

Both helper backends emit samples at the sampling rate once they have a
cursor, so the check does not misfire on an idle pointer. It waits while
the take is paused, never runs over an embedded cursor, and is cancelled
when the take stops. When the helper records the cursor, the sampler
never starts.

When it does run, each position query launches xdotool, so the sampler
takes at most 10 positions a second, and while its click watcher also
reports motion (xinput, libinput) it queries only after the pointer moved.
On motion after an idle stretch it first repeats the last position, so the
editor holds the cursor through the gap. Measured on Xvfb (% of one core,
sampler and its children): idle 14.8 -> 0.2, moving 15.5 -> 8.2.

The fallback track is compacted by the helper's pause ranges and bounded to
the video duration; it has no samples for the take's first second. Samples
are bound to the captured monitor; ambiguous or window geometry produces no
samples rather than a guess. OPENSCREEN_DISABLE_X11_CURSOR=1 turns the
sampler off.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Jasonsu22
Jasonsu22 force-pushed the cursor/x11-cursor-telemetry-fallback-19b6 branch from 519e198 to 767c7be Compare December 2, 2026 05:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Linux X11/Xvfb: auto-sample cursor telemetry when ScreenCast METADATA is unavailable

9 participants