Repository navigation
Feature: Play media and render HTML in the preview pane on Wayland - #198
Merged
Merged
Conversation
Renders frames with the libmpv software render API into a XAML image, so playback works on the native Wayland host as well as X11 without native window embedding. libmpv is optional; without it the metadata preview stays. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: GPT-6.1-sol (OpenAI Codex) <noreply@openai.com>
A short-lived helper process (the app started with a hidden switch) renders the document with an offscreen WebKitGTK 4.1 view and returns a PNG, so HTML previews work on the native Wayland host and on X11 without embedding a native window. Scripts, navigation and network access are blocked; without WebKitGTK the source text fallback stays. Also documents the preview design and lists mpv and webkit2gtk-4.1 as optional AUR dependencies. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: GPT-6.1-sol (OpenAI Codex) <noreply@openai.com>
- Run the WebKit web process in its bubblewrap sandbox and refuse to render when bwrap or xdg-dbus-proxy is missing. - Snapshot only the bounded visible region instead of the full document, and trim trailing background rows. - Open media through PreviewFile and hand mpv the pinned descriptor. - Stop playback as soon as the preview pane moves to another selection. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Refuse HTML rendering where WebKit skips bubblewrap (Snap, Flatpak, WEBKIT_DISABLE_SANDBOX_THIS_IS_DANGEROUS). - Trim only trailing rows in the page background colour, so solid footers are kept. - Cancel the current preview as soon as the selection changes instead of after the debounce, so playback stops while navigating. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 15, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolved / Related Issues
What changed
Audio/video and HTML previews now render in the preview pane on the native Wayland host, and on X11 as well. Neither depends on native window embedding. Note that X11 never had these previews: LinuxFiles doesn't reference Uno's MediaPlayer or WebView X11 add-ins, so on X11 media showed only metadata and HTML showed its source.
WriteableBitmap, with play/pause, seek, and volume controls (volume is persisted). Ctrl+Space also toggles playback. Nothing is decoded until the user presses Play. The file is opened throughPreviewFile(regular files only, inode pinned) and passed to mpv as/proc/self/fd/N. mpv runs with config, scripts, ytdl, and auto-loading disabled, the lavf demuxer only,protocol_whitelist=[file], and a container whitelist. Playlist expansion and path changes are rejected. Playback stops as soon as the selection changes.--linuxfiles-html-snapshot). The helper renders the file in an offscreen WebKitGTK view and returns a PNG, which is shown in a scroll viewer. The web process runs in WebKit's bwrap sandbox. If bwrap or xdg-dbus-proxy is missing, or in Snap or Flatpak environments where WebKit would skip the sandbox, it refuses to render. JavaScript is off, and navigation, downloads, and network access are blocked: a CSP is injected, and the preconnect and prefetch features, which bypass CSP, are disabled. The snapshot covers only the bounded visible region. When rendering is unavailable, the existing source-text fallback is shown.docs/linux-port/wayland-previews.mdcovers the media and HTML design, why I didn't usewl_subsurfacenative hosting, and what interactive HTML would cost (WPE WebKit is the recommended follow-up).mpvandwebkit2gtk-4.1. The Nix flake doesn't include either library yet, so both previews fall back there (see the note).Steps used to test these changes
dotnet build src/Files.App -f net10.0-desktopanddotnet build tests/Files.Platform.Tests -warnaserrorboth build clean.kwin_wayland --virtual: mp4, webm, and mp3 play; a disguised.mp4playlist shows "could not be played"; a selection change stops the player threads; the HTML preview renders; the Markdown preview is unchanged. During rendering I sawWebKitWebProcessrunning under/usr/bin/bwrap.scripts/linux/headless-run.sh): mp4 plays and the HTML preview renders.Not verified: NativeAOT publish, a real desktop session with audio output, HiDPI in the full app (the helper's 2x output is covered by tests).
🤖 Generated with Claude Code
https://claude.ai/code/session_01BTZhMsNyJ6k4VC68CNb5WU