Let media play in the Linux lightweight engine (Canvas 33) - #60
Merged
Merged
Conversation
HTML media never started in the lightweight engine: no loadstart, no error, from any source. WebKitGTK only lets a page start media once its view is "in a window" (WebPage::updateIsInWindow), and it never counts a view inside a GtkOffscreenWindow as one (widgetIsOnscreenToplevelWindow). The engine now hosts its WebKitWebView in a GTK_WINDOW_POPUP placed at (-32000, -32000): override-redirect on X11 (the only backend the pump allows), so it is mapped but off every monitor, undecorated, unfocusable and out of the taskbar. Pixel capture (gtk_widget_draw into our own surface), input synthesis, sizing and popup adoption are unchanged. WebViewMediaSmokeTest (run-linux-media-smoketest.sh) exits 0/1: a data: WebM and a blob: made by fetch()ing a custom-scheme WebM both reach loadedmetadata, and the page still paints. Under Xvfb it fails A and B before this change and passes all three after it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VG4PCm6BfvNxs9mKKa7Df8
shannah
marked this pull request as ready for review
September 30, 2026 14:35
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.
In the Linux lightweight engine (the default mode on Linux), HTML media never starts. No
<video>or<audio>firesloadstart,networkStatestaysNETWORK_NO_SOURCE, and noerrorfires, whatever the source (data:,http:,blob:). The same page plays in WebKitGTK's ownMiniBrowseron the same machine.Why
This is from WebKitGTK 2.52.6's source:
setCanStartMedia(false)and only turns it on once its view isIsInWindow(WebPage::updateIsInWindow).widgetIsOnscreenToplevelWindow(UIProcess/gtk/GtkUtilities.cpp) returns false for aGtkOffscreenWindow, and that is whatgtk_off_create_engineused.The change (Canvas 33)
gtk_off_create_enginenow creates aGTK_WINDOW_POPUPinstead ofgtk_offscreen_window_new(). Before showing it:gtk_window_move(-32000, -32000)accept_focusandfocus_on_mapoff)skip_taskbarandskip_pagerhintsgtk_widget_drawinto our own surface, which never used the offscreen surface), input synthesis throughgtk_main_do_event, the synthetic focus event,gtk_window_resize, destruction and popup adoption (Canvas 19). Only comments that named the window aGtkOffscreenWindowwere corrected.srcstay out of reach on Linux (D4). WebKitGTK's GStreamer player only acceptsblob,data,file,httpandhttpssources. SettingWEBKIT_GST_ALLOWED_URI_PROTOCOLSdoesn't help either, because its source element only claimshttp,httpsandblob. Pages shouldfetchthe scheme URL into ablob:and play that, which the smoke test checks.Testing
New
run-linux-media-smoketest.shrunsdemos/WebViewMediaSmokeTest. It prints one line per check and exits 0 or 1, so it can run unattended under Xvfb:<video>with adata:video/webmsource reachesloadedmetadata 16x16<video>playing ablob:made byfetch('mediatest://app/clip.webm')reachesloadedmetadata 16x16Both columns ran under Xvfb with WebKitGTK 2.52.6 on Ubuntu 24.04. The same fix, reproduced first in a small PyGObject WebKit2 4.1 view, also played an H.264 MP4 at 1280×720.
Not checked:
run-linux-demo.shby hand.agentic-app-framework.Found while
This came up while adding inline video playback to chat file cards in webliteca/agentic-app-framework#406. There, video cards stay plain on Linux until this lands.
Not in this PR: Windows
Canvas 32 deliberately allows
fetchand XHR to a custom scheme only from pages on that same scheme (SetAllowedOrigins(["<scheme>://*"]), AC3). An app whose page isfile://therefore probably can'tfetchits scheme media on Windows. Widening that is a security decision, and it can't be tested here, so it's left for a separate change.🤖 Generated with Claude Code
https://claude.ai/code/session_01VG4PCm6BfvNxs9mKKa7Df8
Generated by Claude Code