Repository navigation
Description
What
A Rune web app always paints an opaque canvas, so a page-level background can't sit behind the UI. Dashboards that want a live backdrop (three.js scene, CSS gradient, video) have nowhere to put it: the canvas covers the viewport and clear_color() clears to the theme background.
On native this is already possible with WindowOptions { transparent: true, .. }. On wasm there is no equivalent, and RuntimeCore::transparent is never set, so the web clear is opaque even when the root element has no fill.
What works today
We pinned Rune at 8705dbea and carry a two-file patch. It makes the canvas transparent so a three.js canvas behind it shows through:
crates/rune/src/platform/web/gpu.rsΓÇö incanvas_config, pick the premultiplied alpha mode when the adapter offers it:
if caps
.alpha_modes
.contains(&wgpu::CompositeAlphaMode::PreMultiplied)
{
config.alpha_mode = wgpu::CompositeAlphaMode::PreMultiplied;
}crates/rune/src/runtime/paint/blend.rsΓÇö treat wasm like a transparent window, so the clear is[0, 0, 0, 0]when the app's root has no opaque fill:
if self.transparent || cfg!(target_arch = "wasm32") {Verification
- Chrome 158, WebGPU: the app canvas reports
rgba(0, 0, 0, 0); a<canvas>atz-index: 0with a three.js scene is visible behind the Rune UI. - Android Chrome, WebGL2: same (fallback path), with the WebGL2 glyph caveat below.
- Opaque root fills still paint over the background, so existing apps that fill their root are unchanged.
- No console errors; the a11y mirror, pointer and keyboard input are unaffected.
Proposal
Rather than always-transparent, expose it explicitly, the way native does:
- honor
WindowOptions { transparent: true }on wasm (setRuntimeCore::transparentwhen the window is created), or - add
App::transparent(bool)/ anAppSpecfield, documented as "the page behind must paint something".
The two-line behaviour above is the implementation we'd expect; the remaining work is turning it on deliberately and documenting the CPU-first handover (the CPU canvas still paints the theme background for the first frames).
Caveats
- We only tested WebGPU and WebGL2 on Chrome/Android; Safari and WebGL1 are untested.
- With a transparent canvas the browser composites every frame over the page, which may matter for battery on mobile; an opt-in flag lets apps choose.
- The WebGL2 path has an unrelated Android bug we hit: text inside cards renders with missing glyphs. Skipping image textures did not fix it, so it is not an atlas/texture interaction. Filed as Web (Android, WebGL2): text inside card elements renders with missing glyphs #3015.
Happy to open a PR with the alpha-mode change, the clear change and a doc note if this shape is acceptable.
Activity
opencodejr commentedon Dec 1, 2026
the web host ignored
WindowOptions::transparent, soRuntimeCore::transparentstayed false, webgpu stayed onCompositeAlphaMode::Opaque, and the cpu-first 2d canvas usedalpha: false.App::window_options(WindowOptions { transparent: true, ..Default::default() })now enables transparent clears ([0, 0, 0, 0]), picksCompositeAlphaMode::PreMultipliedon webgpu when offered (while keeping webgl2's premultiplied alpha canvas compatible withwgpu-hal), and enables alpha with straight-rgba unpremultiplication on the cpu 2d canvas across startup, handover, and fallback; opaque apps are unchanged. web code was only compiled and unit-tested on headless linux without a browser or real window, so please confirm on the new commit.Fixed in #3026.