Skip to content

ALI-2358: Videos and songs play, in the jailed GPU helper - #7

Merged
michaelaguiar merged 10 commits into
mainfrom
ali-2358-player-video
Dec 2, 2026
Merged

michaelaguiar merged 10 commits into
mainfrom
ali-2358-player-video

Conversation

@michaelaguiar

Copy link
Copy Markdown
Member

Part of ALI-2358: Alias View plays video and music. This is the first of three stacked PRs: #6 (tokens) ← this ← the player UI ← MPRIS.

This PR makes videos and songs play. The control bar, the music view and the screen-reader work come in the next PR, following the design canvas.

What changes

  • Playback in the jailed GPU helper. A video or song in the list opens in alias-playback's GPU helper (src/player/gpu.rs): libmpv in a bubblewrap jail, started as alias-view --gpu-helper …, with lock_down_gpu_helper (Landlock and seccomp) applied before any other thread starts. Untrusted video never decodes in this process.
  • Frames as dmabufs. The helper draws on the card the compositor uses, which the compositor names through linux-dmabuf v4 feedback (main_device, matched to /dev/dri/renderD* through /sys), falling back to the first render node. Frames reach the app as dmabufs and show in a desynchronised subsurface above the window, positioned with wp_viewport and placed in the middle of the window. They never pass through this process. Buffers go back to the helper when the compositor releases them.
  • Sound goes through the session's PulseAudio socket, bound into the jail read-only, as alias-playback's CPU helper already does. PipeWire's own socket is never bound.
  • The folder list now includes videos and songs, so n, p, Page Up and Page Down move between them and pictures. Thumbnails and preloading skip them.
  • Keys in a video or song: Space plays and pauses (after the end, it plays again from the start); Left and Right seek 5 s (seek-step); f toggles full screen in a video; Escape leaves full screen. Pictures keep Left and Right for changing file (Mike's decision, 2026-12-02).
  • Opening and failing. While a file opens, the window says "Opening clip.mp4". A file that can't play says why, for example "Can't play broken.mp4: it's damaged or in a format that can't be played". The screen reader hears the state with the file name and its place in the folder.
  • Window size. A window opened on a video starts at 16:9, as large as the screen share allows, and keeps its size, as for pictures.
  • Shared volume. The volume and mute carry over from one file to the next.

Depends on alias-playback #2 and #3

alias-playback is a git dependency on the branch of aliasproject/alias-playback#3 (ali-2358-gpu-media, stacked on #2). #3 adds sound in the GPU jail and the file's tags.

After #2 and #3 merge: change the dependency in Cargo.toml to branch = "main" (or a tag) and run cargo update -p alias-playback.

Not in this PR

These come in the player UI PR:

  • the control bar, seek and volume sliders, hover and focus;
  • the 2 s hide;
  • the replay icon;
  • the music view (cover art, title, artist, album), and playing on to the next song;
  • AccessKit controls and announcements;
  • an overlay above the video. Until then, toasts, the key list and the info panel are drawn on the window's own surface, so a playing video covers them.

Checks

  • Tests: cargo clippy --all-targets -D warnings is clean. New tests cover:
    • telling file kinds apart, and that no name is both a picture and media;
    • the clock text;
    • centring a frame in its box;
    • the helper's command lines.
  • Headless weston, with a private weston (--backend=headless --renderer=gl, own runtime dir) on the desktop (RTX 4090, NVDEC path, so Landlock is on):
    • a 720p H.264 clip shows in the subsurface;
    • a cut-off MP4 shows the "Can't play" line.
  • Sound, against a private PipeWire with pipewire-pulse and only a null sink (own runtime dir, no D-Bus, /dev/snd hidden): the jailed helper's stream reached the null sink, and the monitor captured the test tone for both the video and a FLAC song.
  • Not yet run: a live run on Hyprland. It needs Mike's OK.

@michaelaguiar

Copy link
Copy Markdown
Member Author

Review round 1 (fresh-context reviewer, code-review high), against ali-2358-player-tokens. Fixes are in 8add445.

Fixed:

  1. P2: a paused, ended or cover-art frame didn't move when the window changed size. Media::replace now re-centres the frame on screen through Wl::video_place.

  2. P2: a buffer the compositor released while still on screen was never given back, so the helper could run out of slots. It's now remembered and returned once the next frame replaces it, with a test.

  3. P2: Session::failure waited on a helper that might still be running. It now kills it first, which has no effect if the helper has already exited.

  4. P3: Left and Right were swallowed on a file that can't play. They now change file.

  5. P3: every file change left full screen. Full screen now carries from video to video, and ends for a song or a picture.

  6. P3: a buffer from the untrusted helper went straight to create_immed, so a bad one was a protocol error that closed the window. Each buffer is now checked first:

    • its format and modifier must be in the compositor's list (dmabuf feedback's format table, read with pread because the crate forbids unsafe code, or v3's modifier events);
    • its planes must fit in the dmabuf, whose size is read with lseek.

    A bad buffer makes the file fail with a reason instead. Buffers replaced while on screen are now destroyed with the video layer. I kept create_immed rather than switching to create, because a dropped first frame would stall a still cover image for good.

  7. P3: a FIFO path blocked the window while it waited for a writer. Anything that isn't a regular file is now refused, with a test that hangs without the fix (checked).

Also fixed here, from #8's review because the code is in this PR: a helper that dies mid-play now takes its frozen last frame with it, so the reason shows.

Redirected to #8, which is stacked on this:

Checks:

  • cargo +1.100 clippy --all-targets -D warnings is clean, and 115 tests pass.
  • Video playback checked again in the private headless weston, with the format check on.

michaelaguiar added a commit that referenced this pull request Dec 2, 2026
…ay, Ctrl+C

Merges ali-2358-player-video (its review round: buffer checks, re-centring, failures, FIFOs,
full screen). Conflicts resolved to keep both: the player's keys stay in media_key, which
now lets Left and Right change file when the file can't play.

Review fixes for this PR:
- The keyboard focus in the bar stays on the same control from file to file (Next
  pressed again goes on); close_media had reset it before it was read.
- Announcements are said once: each goes in one of two alternating status nodes and is
  gone from the next tree, so the same words twice (t) are said again, and a stale one
  is never read back when a toast ends.
- A position or volume report redraws only the bar on the overlay, not all of it.
- Ctrl+C on a video or song offers the file only; it offered a PNG the picture
  decoders would have tried to make from the media file.
- The music view's fallback line height comes from the type tokens.
@michaelaguiar

Copy link
Copy Markdown
Member Author

Review round 2 (fresh-context reviewer, code-review high), focused on 8add445. Fixes are in 5648de2.

The reviewer confirmed these round-1 fixes hold: re-centring on resize, the early-release slot (no loss and no double release), Left and Right on a failed file, full screen, the buffer validation and retired buffers, the FIFO check, and the video ending on failure.

Fixed:

  1. P2: round 1's kill-before-wait lost the helper's exit code. The child is bubblewrap, which exits only after it reaps the helper, so a missing libmpv showed "the player stopped". A helper that closed its socket cleanly is now waited for, not killed. Only after a read error is it ended first.
  2. P2: a failed file's helper kept running, so audio played on under the reason, and Frames that kept arriving re-showed and ended the video. On an error the session now ends, which ends the helper, and late Frames are given back.
  3. P3: a stale comment on the format table.

Redirected to #8:

Declined:

Checks: clippy (1.100) is clean, and 115 tests pass.

@michaelaguiar

Copy link
Copy Markdown
Member Author

Review round 3 (final, narrow: 5648de2 and 756fbf4). There are no P1 or P2 findings. The reviewer confirmed:

  • a clean close can't block the window;
  • a failed file's session ends and late frames are given back;
  • send retries only on WouldBlock;
  • video requires viewporter.

Fixed (P3, in d4c5ab0): a helper that exits with commands unread can end in a reset rather than a clean close, and then the kill could still beat its exit code. It now gets 100 ms of try_wait first.

Declined (P3): send can wait up to 200 ms on a wedged helper. A wedged helper is already a failure; a queue isn't worth it before one is seen.

d4c5ab0 also moves alias-playback to e11d5f4. #2's non-waiting requests and #3's tags now read without waiting: a song's cover played 12 of 12 times in the private weston, with its tags each time.

Checks: clippy (1.100) is clean, 115 tests pass, and CI is green on the earlier heads.

@michaelaguiar
michaelaguiar added this pull request to stack #10 December 2, 2026 22:42
Base automatically changed from ali-2358-player-tokens to main December 2, 2026 22:43
- A video or song in the list opens in alias-playback's GPU helper: libmpv in a
  bubblewrap jail, drawing on the card the compositor uses (from linux-dmabuf feedback)
  and handing its frames over as dmabufs. They show in a subsurface above the window, so
  they never pass through this process. Sound goes through the session's PulseAudio
  socket, bound into the jail read-only.
- The folder list takes videos and songs, so n, p, Page Up and Page Down move between
  them and pictures.
- Space plays and pauses (after the end, plays from the start), Left and Right seek 5 s
  (seek-step), f toggles full screen and Escape leaves it.
- While a file opens, the window says so; a file that can't play says why.
- alias-playback is a git dependency on the branch of its PR #3 until #2 and #3 merge.
…IFOs, full screen

- A buffer the helper sends is checked before it reaches the compositor: its format and
  modifier must be one the compositor listed (dmabuf feedback's table, or v3's events) and
  its planes must fit in the dmabuf. A bad one was a protocol error that closed the window;
  now the file can't play and says why.
- A buffer replaced while on screen is destroyed with the video layer if it's never let go.
- A buffer the compositor lets go while still on screen goes back to the helper once the
  next frame replaces it; before, the slot was lost, and after three the video froze.
- The frame on screen moves to the middle of the window when it changes size, even with
  no new frame coming (paused, ended, a song's cover).
- A helper that dies mid-play takes its last frame with it, so the reason shows.
- Session::failure ends the helper before waiting for it: the socket can fail with the
  helper still running, and the wait froze the window.
- A path that isn't a regular file (a FIFO) is refused before it's opened, which waited
  for a writer.
- Full screen carries from one video to the next, and ends for a song or a picture.
- Left and Right change file when the file can't play, as for pictures.
…kept

- A file that can't play (a refused buffer, or the helper saying it can't) ends its
  helper, so no sound plays on under the reason, and frames that still arrive are
  given back, not shown.
- A helper that closed its socket cleanly is waited for, not killed, so its exit code
  says why (libmpv missing, the sandbox not set up). Only after a read error is it ended
  first.
- The format table comment says what the table is now used for.
- Session::send waited for nothing: the socket is non-blocking (for reading), so a full
  one dropped the command, and a lost release left the helper a buffer short for good. A
  full socket is now waited on briefly.
- Video is shown only where the compositor has viewporter, which places a frame at any
  window scale; without it the frame would be drawn at the wrong size.
…reset

- alias-playback e11d5f4: #2's requests and reads that never wait, and #3's tags read
  with them (a song's cover played 12 of 12 times in the private weston, tags each time).
- A helper whose socket ends in a reset rather than a clean close (it exited with
  commands unread) gets 100 ms to finish before it's ended, so its exit code still says
  why it stopped.
With no list (the table couldn't be read), any modifier was taken; now nothing is, so a
buffer from the helper is never one the compositor hasn't said it takes.
@michaelaguiar
michaelaguiar marked this pull request as ready for review December 2, 2026 22:43
@michaelaguiar
michaelaguiar merged commit 1cc3efb into main Dec 2, 2026
2 checks passed
michaelaguiar added a commit that referenced this pull request Dec 2, 2026
main's tree is the same as ali-2358-player-video's c4eeb7d, which this branch
already merged, so the branch's side is kept as it is.
@michaelaguiar
michaelaguiar deleted the ali-2358-player-video branch December 3, 2026 00:55
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.

1 participant