Products › lamco-dsi-tools › Docs › How long from a key press to the captured frame, on a Wayland desktop

How long from a key press to the captured frame, on a Wayland desktop

From an injected key to the frame a capture route delivers: What a remote desktop server sees.

You want to time one key press from the moment it's injected to the moment a capture route delivers a frame that shows its effect: What a remote desktop server sees. With lamco-dsi-tools (DSI: Desktop session interfaces) you'll open a witness window that answers each event with a marked frame, capture the screen while reading those markers, send a key, and pair the three captures with dsitell glass. It's measured in software, on the machine's clock. It isn't input latency and doesn't measure light leaving a monitor.

All three captures have to be taken on one machine since one boot. Measuring explains the markers and the clocks.

On a wlroots compositor

dsisee input witness --markers --duration 30 --out witness.json &
dsisee capture probe --read-markers --duration 20 --out capture.json &
dsido wlr inject key enter --out inject.json
wait
dsitell glass inject.json witness.json capture.json
  1. dsisee input witness --markers opens a window that records every event the compositor delivers to it and answers each with a frame that carries a screen marker.
  2. dsisee capture probe --read-markers captures the screen through the compositor's capture protocol and reads the marker in each buffer. It stores the counter it decoded, where, and a confidence, never a pixel.
  3. dsido wlr inject key enter presses and releases one key through the virtual keyboard and records each step. Give the witness window the keyboard focus first, since a key goes only to the focused window.
  4. dsitell glass pairs them: The three captures, in that order (the injection, the witness, the capture).

On GNOME or KDE

These capture through the ScreenCast portal and take input through libei. Both show a permission dialog, and reading the stream needs a build with the pipewire feature (the gnu tarball).

dsisee input witness --markers --duration 60 --out witness.json &
dsisee capture probe --route portal --read-markers --duration 45 --out capture.json &
dsido eis inject key enter --out inject.json
wait
dsitell glass inject.json witness.json capture.json

Answer the screen cast dialog first, then the input dialog. A dialog can leave the keyboard focus elsewhere, so click the witness window before the key is sent. dsitell loop inject.json witness.json says whether the witness had the focus while the key steps were sent. If buffers can't be read for markers (CAP-009), take the capture again with --modifiers linear or --memory-buffers.

What to look at

dsitell glass names the capture route and gives each figure with its clock:

FigureFrom and to
glass.requested_to_deliveredThe step being requested to its event being delivered to the window
glass.delivered_to_committedThe event to the marked frame the window committed in answer
glass.committed_to_presentedThe commit to the time the compositor says the frame was presented
glass.committed_to_presented_toldThe commit to the time the window was told of the presentation
glass.presented_to_capturedThe presentation time to the captured buffer that shows the frame arriving
glass.committed_to_capturedThe commit to the captured buffer arriving
glass.requested_to_capturedThe whole: The step being requested to the captured buffer arriving
  • No figure is a sum of others. Each is two stamps.
  • The two figures that touch the compositor's presentation time are computed only when the compositor named the same clock id the capture headers record, on one machine and boot. The line then says what it rests on. Otherwise they're under "Not computed", with both clocks and the reason, and committed_to_presented_told stands as an upper bound.
  • Exit code 0 means every step was seen, answered with a marked frame, and that frame was captured. Exit code 1 means a step didn't reach the pixels. Exit code 2 means the captures didn't name one machine and boot, or weren't given in the right order.
  • A single key is two steps (down and up), so each of its figures rests on a count of two at most. For a distribution, send a text (dsido wlr inject text "hello") or repeat the run.

Input to the captured frame has been run on Sway 1.9 (wlr-screencopy), cosmic-comp 1.0.0 (ext-image-copy-capture), Mutter 48.7 and KWin 6.8.2 (the portal's stream). See What has been run.

Related