From 93b67834a798f2201800428b4452ed95846a342a Mon Sep 17 00:00:00 2001 From: Marco Allegretti Date: Fri, 9 Oct 2026 00:13:08 +0000 Subject: [PATCH 1/3] build: select compiling Servo and Stylo fork revisions Both Servo hosts tracked the marcoallegretti/servo `servo-weft` branch, which the lockfile resolved to 8e7dc40. That revision's servo-layout does not compile (E0308 and E0716 in build_backdrop_filter). WEFT also resolved upstream Stylo dca3934, where backdrop-filter is gated behind layout.unimplemented, because the Servo fork's own [patch] for Stylo does not apply to dependents. Pin Servo by revision to f0bb1aa (8e7dc40 plus the build fix) and add a root [patch."https://github.com/servo/stylo"] selecting the marcoallegretti/stylo fork at f1ba496 for all eight Stylo crates Servo uses. Cargo.lock changes only the 66 source lines of those packages. Record both pins, their reachable branches, purpose and removal conditions in SERVO_PIN.md, and restate its limitations against executed evidence. Update the Nix outputHashes: the Stylo hash is recomputed for f1ba496 with the method that reproduces the previous dca3934 value; the Servo hash is not yet known for f0bb1aa and is left as lib.fakeHash, so Nix builds report the expected value instead of using a stale one. Validation: - cargo metadata --locked: ok; no servo/stylo sources remain in the lock - cargo check -p weft-servo-shell --features servo-embed --locked: all of Servo, including servo-layout, compiles; the remaining errors are in the shell's own embedder code - cargo fmt --check; portable workspace tests: 78 passed - Nix fetchgit could not run here (archive downloads and the sandbox's TLS to the proxy fail), so the Servo hash remains unverified --- Cargo.lock | 132 ++++++++++++------------- Cargo.toml | 14 +++ README.md | 6 +- crates/weft-app-shell/Cargo.toml | 2 +- crates/weft-servo-shell/Cargo.toml | 2 +- crates/weft-servo-shell/SERVO_PIN.md | 139 +++++++++++++-------------- docs/building.md | 4 +- infra/nixos/weft-packages.nix | 8 +- 8 files changed, 162 insertions(+), 145 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7b87b7e..278fcb4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6476,7 +6476,7 @@ dependencies = [ [[package]] name = "selectors" version = "0.36.0" -source = "git+https://github.com/servo/stylo?rev=dca3934667dae76c49bb579b268c5eb142d09c6a#dca3934667dae76c49bb579b268c5eb142d09c6a" +source = "git+https://github.com/marcoallegretti/stylo?rev=f1ba4969536d63f2e319a561e466c03e78b4a076#f1ba4969536d63f2e319a561e466c03e78b4a076" dependencies = [ "bitflags 2.11.0", "cssparser", @@ -6590,7 +6590,7 @@ dependencies = [ [[package]] name = "servo" version = "0.0.1" -source = "git+https://github.com/marcoallegretti/servo?branch=servo-weft#8e7dc40bff42448980b7249798f17e3131547138" +source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11" dependencies = [ "accesskit", "bitflags 2.11.0", @@ -6651,7 +6651,7 @@ dependencies = [ [[package]] name = "servo-allocator" version = "0.0.1" -source = "git+https://github.com/marcoallegretti/servo?branch=servo-weft#8e7dc40bff42448980b7249798f17e3131547138" +source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11" dependencies = [ "libc", "tikv-jemalloc-sys", @@ -6662,7 +6662,7 @@ dependencies = [ [[package]] name = "servo-background-hang-monitor" version = "0.0.1" -source = "git+https://github.com/marcoallegretti/servo?branch=servo-weft#8e7dc40bff42448980b7249798f17e3131547138" +source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11" dependencies = [ "backtrace", "crossbeam-channel", @@ -6677,7 +6677,7 @@ dependencies = [ [[package]] name = "servo-background-hang-monitor-api" version = "0.0.1" -source = "git+https://github.com/marcoallegretti/servo?branch=servo-weft#8e7dc40bff42448980b7249798f17e3131547138" +source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11" dependencies = [ "serde", "servo-base", @@ -6686,7 +6686,7 @@ dependencies = [ [[package]] name = "servo-base" version = "0.0.1" -source = "git+https://github.com/marcoallegretti/servo?branch=servo-weft#8e7dc40bff42448980b7249798f17e3131547138" +source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11" dependencies = [ "accesskit", "crossbeam-channel", @@ -6711,7 +6711,7 @@ dependencies = [ [[package]] name = "servo-canvas" version = "0.0.1" -source = "git+https://github.com/marcoallegretti/servo?branch=servo-weft#8e7dc40bff42448980b7249798f17e3131547138" +source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11" dependencies = [ "bytemuck", "crossbeam-channel", @@ -6736,7 +6736,7 @@ dependencies = [ [[package]] name = "servo-canvas-traits" version = "0.0.1" -source = "git+https://github.com/marcoallegretti/servo?branch=servo-weft#8e7dc40bff42448980b7249798f17e3131547138" +source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11" dependencies = [ "crossbeam-channel", "euclid", @@ -6758,7 +6758,7 @@ dependencies = [ [[package]] name = "servo-config" version = "0.0.1" -source = "git+https://github.com/marcoallegretti/servo?branch=servo-weft#8e7dc40bff42448980b7249798f17e3131547138" +source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11" dependencies = [ "serde", "serde_json", @@ -6770,7 +6770,7 @@ dependencies = [ [[package]] name = "servo-config-macro" version = "0.0.1" -source = "git+https://github.com/marcoallegretti/servo?branch=servo-weft#8e7dc40bff42448980b7249798f17e3131547138" +source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11" dependencies = [ "proc-macro2", "quote", @@ -6781,7 +6781,7 @@ dependencies = [ [[package]] name = "servo-constellation" version = "0.0.1" -source = "git+https://github.com/marcoallegretti/servo?branch=servo-weft#8e7dc40bff42448980b7249798f17e3131547138" +source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11" dependencies = [ "backtrace", "content-security-policy", @@ -6828,7 +6828,7 @@ dependencies = [ [[package]] name = "servo-constellation-traits" version = "0.0.1" -source = "git+https://github.com/marcoallegretti/servo?branch=servo-weft#8e7dc40bff42448980b7249798f17e3131547138" +source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11" dependencies = [ "content-security-policy", "encoding_rs", @@ -6863,7 +6863,7 @@ dependencies = [ [[package]] name = "servo-deny-public-fields" version = "0.0.1" -source = "git+https://github.com/marcoallegretti/servo?branch=servo-weft#8e7dc40bff42448980b7249798f17e3131547138" +source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11" dependencies = [ "syn", "synstructure", @@ -6872,7 +6872,7 @@ dependencies = [ [[package]] name = "servo-devtools" version = "0.0.1" -source = "git+https://github.com/marcoallegretti/servo?branch=servo-weft#8e7dc40bff42448980b7249798f17e3131547138" +source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11" dependencies = [ "atomic_refcell", "base64 0.22.1", @@ -6901,7 +6901,7 @@ dependencies = [ [[package]] name = "servo-devtools-traits" version = "0.0.1" -source = "git+https://github.com/marcoallegretti/servo?branch=servo-weft#8e7dc40bff42448980b7249798f17e3131547138" +source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11" dependencies = [ "bitflags 2.11.0", "http 1.4.0", @@ -6920,7 +6920,7 @@ dependencies = [ [[package]] name = "servo-dom-struct" version = "0.0.1" -source = "git+https://github.com/marcoallegretti/servo?branch=servo-weft#8e7dc40bff42448980b7249798f17e3131547138" +source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11" dependencies = [ "proc-macro2", "quote", @@ -6930,7 +6930,7 @@ dependencies = [ [[package]] name = "servo-embedder-traits" version = "0.0.1" -source = "git+https://github.com/marcoallegretti/servo?branch=servo-weft#8e7dc40bff42448980b7249798f17e3131547138" +source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11" dependencies = [ "accesskit", "bitflags 2.11.0", @@ -6963,7 +6963,7 @@ dependencies = [ [[package]] name = "servo-fonts" version = "0.0.1" -source = "git+https://github.com/marcoallegretti/servo?branch=servo-weft#8e7dc40bff42448980b7249798f17e3131547138" +source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11" dependencies = [ "app_units", "bitflags 2.11.0", @@ -7016,7 +7016,7 @@ dependencies = [ [[package]] name = "servo-fonts-traits" version = "0.0.1" -source = "git+https://github.com/marcoallegretti/servo?branch=servo-weft#8e7dc40bff42448980b7249798f17e3131547138" +source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11" dependencies = [ "atomic_refcell", "dwrote", @@ -7039,7 +7039,7 @@ dependencies = [ [[package]] name = "servo-geometry" version = "0.0.1" -source = "git+https://github.com/marcoallegretti/servo?branch=servo-weft#8e7dc40bff42448980b7249798f17e3131547138" +source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11" dependencies = [ "app_units", "euclid", @@ -7052,7 +7052,7 @@ dependencies = [ [[package]] name = "servo-hyper-serde" version = "0.13.2" -source = "git+https://github.com/marcoallegretti/servo?branch=servo-weft#8e7dc40bff42448980b7249798f17e3131547138" +source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11" dependencies = [ "cookie 0.18.1", "headers 0.4.1", @@ -7066,7 +7066,7 @@ dependencies = [ [[package]] name = "servo-jstraceable-derive" version = "0.0.1" -source = "git+https://github.com/marcoallegretti/servo?branch=servo-weft#8e7dc40bff42448980b7249798f17e3131547138" +source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11" dependencies = [ "proc-macro2", "syn", @@ -7076,7 +7076,7 @@ dependencies = [ [[package]] name = "servo-layout" version = "0.0.1" -source = "git+https://github.com/marcoallegretti/servo?branch=servo-weft#8e7dc40bff42448980b7249798f17e3131547138" +source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11" dependencies = [ "accesskit", "app_units", @@ -7130,7 +7130,7 @@ dependencies = [ [[package]] name = "servo-layout-api" version = "0.0.1" -source = "git+https://github.com/marcoallegretti/servo?branch=servo-weft#8e7dc40bff42448980b7249798f17e3131547138" +source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11" dependencies = [ "app_units", "atomic_refcell", @@ -7164,7 +7164,7 @@ dependencies = [ [[package]] name = "servo-malloc-size-of" version = "0.0.1" -source = "git+https://github.com/marcoallegretti/servo?branch=servo-weft#8e7dc40bff42448980b7249798f17e3131547138" +source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11" dependencies = [ "accountable-refcell", "app_units", @@ -7204,7 +7204,7 @@ dependencies = [ [[package]] name = "servo-media" version = "0.0.1" -source = "git+https://github.com/marcoallegretti/servo?branch=servo-weft#8e7dc40bff42448980b7249798f17e3131547138" +source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11" dependencies = [ "once_cell", "servo-media-audio", @@ -7217,7 +7217,7 @@ dependencies = [ [[package]] name = "servo-media-audio" version = "0.0.1" -source = "git+https://github.com/marcoallegretti/servo?branch=servo-weft#8e7dc40bff42448980b7249798f17e3131547138" +source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11" dependencies = [ "byte-slice-cast", "euclid", @@ -7240,7 +7240,7 @@ dependencies = [ [[package]] name = "servo-media-derive" version = "0.0.1" -source = "git+https://github.com/marcoallegretti/servo?branch=servo-weft#8e7dc40bff42448980b7249798f17e3131547138" +source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11" dependencies = [ "proc-macro2", "quote", @@ -7250,7 +7250,7 @@ dependencies = [ [[package]] name = "servo-media-dummy" version = "0.0.1" -source = "git+https://github.com/marcoallegretti/servo?branch=servo-weft#8e7dc40bff42448980b7249798f17e3131547138" +source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11" dependencies = [ "ipc-channel", "servo-media", @@ -7264,7 +7264,7 @@ dependencies = [ [[package]] name = "servo-media-player" version = "0.0.1" -source = "git+https://github.com/marcoallegretti/servo?branch=servo-weft#8e7dc40bff42448980b7249798f17e3131547138" +source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11" dependencies = [ "ipc-channel", "malloc_size_of_derive", @@ -7278,7 +7278,7 @@ dependencies = [ [[package]] name = "servo-media-streams" version = "0.0.1" -source = "git+https://github.com/marcoallegretti/servo?branch=servo-weft#8e7dc40bff42448980b7249798f17e3131547138" +source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11" dependencies = [ "malloc_size_of_derive", "servo-malloc-size-of", @@ -7288,7 +7288,7 @@ dependencies = [ [[package]] name = "servo-media-thread" version = "0.0.1" -source = "git+https://github.com/marcoallegretti/servo?branch=servo-weft#8e7dc40bff42448980b7249798f17e3131547138" +source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11" dependencies = [ "euclid", "ipc-channel", @@ -7306,7 +7306,7 @@ dependencies = [ [[package]] name = "servo-media-traits" version = "0.0.1" -source = "git+https://github.com/marcoallegretti/servo?branch=servo-weft#8e7dc40bff42448980b7249798f17e3131547138" +source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11" dependencies = [ "malloc_size_of_derive", "servo-malloc-size-of", @@ -7315,7 +7315,7 @@ dependencies = [ [[package]] name = "servo-media-webrtc" version = "0.0.1" -source = "git+https://github.com/marcoallegretti/servo?branch=servo-weft#8e7dc40bff42448980b7249798f17e3131547138" +source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11" dependencies = [ "log", "servo-media-streams", @@ -7325,7 +7325,7 @@ dependencies = [ [[package]] name = "servo-metrics" version = "0.0.1" -source = "git+https://github.com/marcoallegretti/servo?branch=servo-weft#8e7dc40bff42448980b7249798f17e3131547138" +source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11" dependencies = [ "malloc_size_of_derive", "servo-base", @@ -7340,7 +7340,7 @@ dependencies = [ [[package]] name = "servo-net" version = "0.0.1" -source = "git+https://github.com/marcoallegretti/servo?branch=servo-weft#8e7dc40bff42448980b7249798f17e3131547138" +source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11" dependencies = [ "async-compression", "async-recursion", @@ -7409,7 +7409,7 @@ dependencies = [ [[package]] name = "servo-net-traits" version = "0.0.1" -source = "git+https://github.com/marcoallegretti/servo?branch=servo-weft#8e7dc40bff42448980b7249798f17e3131547138" +source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11" dependencies = [ "content-security-policy", "cookie 0.18.1", @@ -7449,7 +7449,7 @@ dependencies = [ [[package]] name = "servo-paint" version = "0.0.1" -source = "git+https://github.com/marcoallegretti/servo?branch=servo-weft#8e7dc40bff42448980b7249798f17e3131547138" +source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11" dependencies = [ "bitflags 2.11.0", "crossbeam-channel", @@ -7486,7 +7486,7 @@ dependencies = [ [[package]] name = "servo-paint-api" version = "0.0.1" -source = "git+https://github.com/marcoallegretti/servo?branch=servo-weft#8e7dc40bff42448980b7249798f17e3131547138" +source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11" dependencies = [ "bitflags 2.11.0", "crossbeam-channel", @@ -7522,7 +7522,7 @@ dependencies = [ [[package]] name = "servo-pixels" version = "0.0.1" -source = "git+https://github.com/marcoallegretti/servo?branch=servo-weft#8e7dc40bff42448980b7249798f17e3131547138" +source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11" dependencies = [ "euclid", "image", @@ -7537,7 +7537,7 @@ dependencies = [ [[package]] name = "servo-profile" version = "0.0.1" -source = "git+https://github.com/marcoallegretti/servo?branch=servo-weft#8e7dc40bff42448980b7249798f17e3131547138" +source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11" dependencies = [ "libc", "log", @@ -7556,7 +7556,7 @@ dependencies = [ [[package]] name = "servo-profile-traits" version = "0.0.1" -source = "git+https://github.com/marcoallegretti/servo?branch=servo-weft#8e7dc40bff42448980b7249798f17e3131547138" +source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11" dependencies = [ "crossbeam-channel", "ipc-channel", @@ -7573,7 +7573,7 @@ dependencies = [ [[package]] name = "servo-script" version = "0.0.1" -source = "git+https://github.com/marcoallegretti/servo?branch=servo-weft#8e7dc40bff42448980b7249798f17e3131547138" +source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11" dependencies = [ "aes", "aes-gcm", @@ -7712,7 +7712,7 @@ dependencies = [ [[package]] name = "servo-script-bindings" version = "0.0.1" -source = "git+https://github.com/marcoallegretti/servo?branch=servo-weft#8e7dc40bff42448980b7249798f17e3131547138" +source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11" dependencies = [ "bitflags 2.11.0", "crossbeam-channel", @@ -7750,7 +7750,7 @@ dependencies = [ [[package]] name = "servo-script-traits" version = "0.0.1" -source = "git+https://github.com/marcoallegretti/servo?branch=servo-weft#8e7dc40bff42448980b7249798f17e3131547138" +source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11" dependencies = [ "accesskit", "content-security-policy", @@ -7787,7 +7787,7 @@ dependencies = [ [[package]] name = "servo-storage" version = "0.0.1" -source = "git+https://github.com/marcoallegretti/servo?branch=servo-weft#8e7dc40bff42448980b7249798f17e3131547138" +source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11" dependencies = [ "libc", "log", @@ -7817,7 +7817,7 @@ dependencies = [ [[package]] name = "servo-storage-traits" version = "0.0.1" -source = "git+https://github.com/marcoallegretti/servo?branch=servo-weft#8e7dc40bff42448980b7249798f17e3131547138" +source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11" dependencies = [ "malloc_size_of_derive", "serde", @@ -7831,7 +7831,7 @@ dependencies = [ [[package]] name = "servo-timers" version = "0.0.1" -source = "git+https://github.com/marcoallegretti/servo?branch=servo-weft#8e7dc40bff42448980b7249798f17e3131547138" +source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11" dependencies = [ "crossbeam-channel", "malloc_size_of_derive", @@ -7841,7 +7841,7 @@ dependencies = [ [[package]] name = "servo-tracing" version = "0.0.1" -source = "git+https://github.com/marcoallegretti/servo?branch=servo-weft#8e7dc40bff42448980b7249798f17e3131547138" +source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11" dependencies = [ "proc-macro2", "quote", @@ -7851,7 +7851,7 @@ dependencies = [ [[package]] name = "servo-url" version = "0.0.1" -source = "git+https://github.com/marcoallegretti/servo?branch=servo-weft#8e7dc40bff42448980b7249798f17e3131547138" +source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11" dependencies = [ "encoding_rs", "malloc_size_of_derive", @@ -7865,7 +7865,7 @@ dependencies = [ [[package]] name = "servo-webgl" version = "0.0.1" -source = "git+https://github.com/marcoallegretti/servo?branch=servo-weft#8e7dc40bff42448980b7249798f17e3131547138" +source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11" dependencies = [ "bitflags 2.11.0", "byteorder", @@ -7889,7 +7889,7 @@ dependencies = [ [[package]] name = "servo-webgpu" version = "0.0.1" -source = "git+https://github.com/marcoallegretti/servo?branch=servo-weft#8e7dc40bff42448980b7249798f17e3131547138" +source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11" dependencies = [ "arrayvec", "euclid", @@ -7908,7 +7908,7 @@ dependencies = [ [[package]] name = "servo-webgpu-traits" version = "0.0.1" -source = "git+https://github.com/marcoallegretti/servo?branch=servo-weft#8e7dc40bff42448980b7249798f17e3131547138" +source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11" dependencies = [ "arrayvec", "malloc_size_of_derive", @@ -7924,7 +7924,7 @@ dependencies = [ [[package]] name = "servo-webxr" version = "0.0.1" -source = "git+https://github.com/marcoallegretti/servo?branch=servo-weft#8e7dc40bff42448980b7249798f17e3131547138" +source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11" dependencies = [ "crossbeam-channel", "euclid", @@ -7943,7 +7943,7 @@ dependencies = [ [[package]] name = "servo-webxr-api" version = "0.0.1" -source = "git+https://github.com/marcoallegretti/servo?branch=servo-weft#8e7dc40bff42448980b7249798f17e3131547138" +source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11" dependencies = [ "euclid", "ipc-channel", @@ -7959,7 +7959,7 @@ dependencies = [ [[package]] name = "servo-xpath" version = "0.0.1" -source = "git+https://github.com/marcoallegretti/servo?branch=servo-weft#8e7dc40bff42448980b7249798f17e3131547138" +source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11" dependencies = [ "log", "malloc_size_of_derive", @@ -7970,7 +7970,7 @@ dependencies = [ [[package]] name = "servo_arc" version = "0.4.3" -source = "git+https://github.com/servo/stylo?rev=dca3934667dae76c49bb579b268c5eb142d09c6a#dca3934667dae76c49bb579b268c5eb142d09c6a" +source = "git+https://github.com/marcoallegretti/stylo?rev=f1ba4969536d63f2e319a561e466c03e78b4a076#f1ba4969536d63f2e319a561e466c03e78b4a076" dependencies = [ "serde", "stable_deref_trait", @@ -8396,7 +8396,7 @@ dependencies = [ [[package]] name = "stylo" version = "0.13.0" -source = "git+https://github.com/servo/stylo?rev=dca3934667dae76c49bb579b268c5eb142d09c6a#dca3934667dae76c49bb579b268c5eb142d09c6a" +source = "git+https://github.com/marcoallegretti/stylo?rev=f1ba4969536d63f2e319a561e466c03e78b4a076#f1ba4969536d63f2e319a561e466c03e78b4a076" dependencies = [ "app_units", "arrayvec", @@ -8452,7 +8452,7 @@ dependencies = [ [[package]] name = "stylo_atoms" version = "0.13.0" -source = "git+https://github.com/servo/stylo?rev=dca3934667dae76c49bb579b268c5eb142d09c6a#dca3934667dae76c49bb579b268c5eb142d09c6a" +source = "git+https://github.com/marcoallegretti/stylo?rev=f1ba4969536d63f2e319a561e466c03e78b4a076#f1ba4969536d63f2e319a561e466c03e78b4a076" dependencies = [ "string_cache", "string_cache_codegen", @@ -8461,7 +8461,7 @@ dependencies = [ [[package]] name = "stylo_derive" version = "0.13.0" -source = "git+https://github.com/servo/stylo?rev=dca3934667dae76c49bb579b268c5eb142d09c6a#dca3934667dae76c49bb579b268c5eb142d09c6a" +source = "git+https://github.com/marcoallegretti/stylo?rev=f1ba4969536d63f2e319a561e466c03e78b4a076#f1ba4969536d63f2e319a561e466c03e78b4a076" dependencies = [ "darling", "proc-macro2", @@ -8473,7 +8473,7 @@ dependencies = [ [[package]] name = "stylo_dom" version = "0.13.0" -source = "git+https://github.com/servo/stylo?rev=dca3934667dae76c49bb579b268c5eb142d09c6a#dca3934667dae76c49bb579b268c5eb142d09c6a" +source = "git+https://github.com/marcoallegretti/stylo?rev=f1ba4969536d63f2e319a561e466c03e78b4a076#f1ba4969536d63f2e319a561e466c03e78b4a076" dependencies = [ "bitflags 2.11.0", "stylo_malloc_size_of", @@ -8482,7 +8482,7 @@ dependencies = [ [[package]] name = "stylo_malloc_size_of" version = "0.13.0" -source = "git+https://github.com/servo/stylo?rev=dca3934667dae76c49bb579b268c5eb142d09c6a#dca3934667dae76c49bb579b268c5eb142d09c6a" +source = "git+https://github.com/marcoallegretti/stylo?rev=f1ba4969536d63f2e319a561e466c03e78b4a076#f1ba4969536d63f2e319a561e466c03e78b4a076" dependencies = [ "app_units", "cssparser", @@ -8499,12 +8499,12 @@ dependencies = [ [[package]] name = "stylo_static_prefs" version = "0.13.0" -source = "git+https://github.com/servo/stylo?rev=dca3934667dae76c49bb579b268c5eb142d09c6a#dca3934667dae76c49bb579b268c5eb142d09c6a" +source = "git+https://github.com/marcoallegretti/stylo?rev=f1ba4969536d63f2e319a561e466c03e78b4a076#f1ba4969536d63f2e319a561e466c03e78b4a076" [[package]] name = "stylo_traits" version = "0.13.0" -source = "git+https://github.com/servo/stylo?rev=dca3934667dae76c49bb579b268c5eb142d09c6a#dca3934667dae76c49bb579b268c5eb142d09c6a" +source = "git+https://github.com/marcoallegretti/stylo?rev=f1ba4969536d63f2e319a561e466c03e78b4a076#f1ba4969536d63f2e319a561e466c03e78b4a076" dependencies = [ "app_units", "bitflags 2.11.0", @@ -8904,7 +8904,7 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "to_shmem" version = "0.3.0" -source = "git+https://github.com/servo/stylo?rev=dca3934667dae76c49bb579b268c5eb142d09c6a#dca3934667dae76c49bb579b268c5eb142d09c6a" +source = "git+https://github.com/marcoallegretti/stylo?rev=f1ba4969536d63f2e319a561e466c03e78b4a076#f1ba4969536d63f2e319a561e466c03e78b4a076" dependencies = [ "cssparser", "servo_arc", @@ -8917,7 +8917,7 @@ dependencies = [ [[package]] name = "to_shmem_derive" version = "0.1.0" -source = "git+https://github.com/servo/stylo?rev=dca3934667dae76c49bb579b268c5eb142d09c6a#dca3934667dae76c49bb579b268c5eb142d09c6a" +source = "git+https://github.com/marcoallegretti/stylo?rev=f1ba4969536d63f2e319a561e466c03e78b4a076#f1ba4969536d63f2e319a561e466c03e78b4a076" dependencies = [ "darling", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index e8cfff7..d8573d6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,3 +24,17 @@ rust-version = "1.93" [workspace.lints.rust] unsafe_code = "forbid" + +# Servo's own [patch] tables do not apply to dependents. The servo fork's +# backdrop-filter support needs the stylo fork that removes the property's +# `layout.unimplemented` gate, so the override lives here. Remove it once the +# change is available from upstream stylo at the revision Servo selects. +[patch."https://github.com/servo/stylo"] +selectors = { git = "https://github.com/marcoallegretti/stylo", rev = "f1ba4969536d63f2e319a561e466c03e78b4a076" } +servo_arc = { git = "https://github.com/marcoallegretti/stylo", rev = "f1ba4969536d63f2e319a561e466c03e78b4a076" } +stylo = { git = "https://github.com/marcoallegretti/stylo", rev = "f1ba4969536d63f2e319a561e466c03e78b4a076" } +stylo_atoms = { git = "https://github.com/marcoallegretti/stylo", rev = "f1ba4969536d63f2e319a561e466c03e78b4a076" } +stylo_dom = { git = "https://github.com/marcoallegretti/stylo", rev = "f1ba4969536d63f2e319a561e466c03e78b4a076" } +stylo_malloc_size_of = { git = "https://github.com/marcoallegretti/stylo", rev = "f1ba4969536d63f2e319a561e466c03e78b4a076" } +stylo_static_prefs = { git = "https://github.com/marcoallegretti/stylo", rev = "f1ba4969536d63f2e319a561e466c03e78b4a076" } +stylo_traits = { git = "https://github.com/marcoallegretti/stylo", rev = "f1ba4969536d63f2e319a561e466c03e78b4a076" } diff --git a/README.md b/README.md index ae036f9..0abad34 100644 --- a/README.md +++ b/README.md @@ -94,7 +94,7 @@ See `docs/security.md`. Key points: ## Servo fork -- Repository: `https://github.com/marcoallegretti/servo`, branch `servo-weft` -- Base revision: `04ca254f` -- Patches: keyboard input, backdrop-filter in stylo +- Servo: `https://github.com/marcoallegretti/servo` at `f0bb1aaf`, pinned by revision +- Stylo: `https://github.com/marcoallegretti/stylo` at `f1ba4969`, through the root `[patch]` +- Patches: `backdrop-filter` parsing (Stylo) and rendering (Servo) - See `crates/weft-servo-shell/SERVO_PIN.md` for Servo integration status and known limitations diff --git a/crates/weft-app-shell/Cargo.toml b/crates/weft-app-shell/Cargo.toml index 68bbeac..1fd1448 100644 --- a/crates/weft-app-shell/Cargo.toml +++ b/crates/weft-app-shell/Cargo.toml @@ -27,7 +27,7 @@ toml = { version = "0.8", optional = true } [dependencies.servo] git = "https://github.com/marcoallegretti/servo" -branch = "servo-weft" +rev = "f0bb1aaf981b65c8dddc848bb647045d4c777d11" optional = true default-features = false diff --git a/crates/weft-servo-shell/Cargo.toml b/crates/weft-servo-shell/Cargo.toml index 42e34db..ef8cf89 100644 --- a/crates/weft-servo-shell/Cargo.toml +++ b/crates/weft-servo-shell/Cargo.toml @@ -27,7 +27,7 @@ tungstenite = "0.24" [dependencies.servo] git = "https://github.com/marcoallegretti/servo" -branch = "servo-weft" +rev = "f0bb1aaf981b65c8dddc848bb647045d4c777d11" optional = true default-features = false diff --git a/crates/weft-servo-shell/SERVO_PIN.md b/crates/weft-servo-shell/SERVO_PIN.md index 82b7c3d..a2b7100 100644 --- a/crates/weft-servo-shell/SERVO_PIN.md +++ b/crates/weft-servo-shell/SERVO_PIN.md @@ -2,13 +2,25 @@ ## Current pin -| Field | Value | -|---------|------------------------------------------------------------------------------------| -| Source | (fork of servo/servo) | -| Branch | `servo-weft` | -| Rev | `04ca254f843ed650d3e5b14e5693ad51a60cc84b` (servo-weft tip, 2026-03-11) | -| Crate | `servo` (package name as of 2026-03-11; previously `libservo`) | -| Feature | `servo-embed` (optional; off by default) | +The selected revisions are the ones recorded in the workspace `Cargo.lock`. + +| Dependency | Source | Revision | Selected by | +|------------|--------|----------|-------------| +| Servo (`servo` crate) | | `f0bb1aaf981b65c8dddc848bb647045d4c777d11` | `rev` in both shell crates' `Cargo.toml` | +| Stylo (`stylo`, `selectors`, `servo_arc`, ...) | | `f1ba4969536d63f2e319a561e466c03e78b4a076` | `[patch."https://github.com/servo/stylo"]` in the root `Cargo.toml` | + +The Servo revision is `servo-weft` commit `8e7dc40` (backdrop-filter rendering) +plus `f0bb1aa`, which fixes that commit's `servo-layout` build errors. It lives +on the fork branch `fix/backdrop-filter-build-errors` until it is merged into +`servo-weft`; keep that branch until then so the revision stays fetchable. + +Servo's own `[patch]` table for Stylo does not apply to WEFT, because Cargo +only honours patches in the root workspace. Without the root override, WEFT +resolves upstream Stylo `dca3934`, where `backdrop-filter` is still gated +behind `layout.unimplemented`. Remove the override once the selected Servo +revision depends on a Stylo that parses the property for Servo. + +The feature is `servo-embed` (optional; off by default). ## Cargo dependencies @@ -25,7 +37,7 @@ servo-embed = ["dep:servo", "dep:winit", "dep:softbuffer"] [dependencies.servo] git = "https://github.com/marcoallegretti/servo" -branch = "servo-weft" +rev = "f0bb1aaf981b65c8dddc848bb647045d4c777d11" optional = true default-features = false @@ -75,72 +87,59 @@ DMA-BUF buffer sharing with the compositor transparently. ## Known limitations at this pin -- **Wayland input events**: ~~not forwarded to Servo~~ **Resolved** — keyboard and - mouse events forwarded via `webview.notify_input_event`; key mapping in `keyutils.rs`. -- **Wayland surface sharing**: ~~`ZweftShellWindowV1` created with `surface = null`~~ **Resolved** — - `ShellClient::connect_with_display(display_ptr, surface_ptr)` uses - `Backend::from_foreign_display` to share winit's `wl_display` connection; the winit - `wl_surface` pointer is passed directly to `create_window`, associating the compositor - shell slot with the actual rendered surface. `ShellClient` is now constructed inside - `resumed()` after the winit window exists, not before the event loop. EGL path and - per-frame event dispatch are unchanged. - Protocol note: `wayland-scanner 0.31` generates `_type` (not `r#type`) for the - `navigation_gesture` event arg named `type`. -- **WebGPU on Mesa**: adapter may fail CTS — validation task, requires Mesa GPU hardware. -- **CSS layout features**: ~~CSS Grid~~ **Grid resolved** (Taffy-backed, fully wired). - ~~CSS `backdrop-filter` unimplemented~~ **`backdrop-filter` resolved** (servo/servo issue - [#41567](https://github.com/servo/servo/issues/41567)). Implemented across two commits: - - `marcoallegretti/stylo` `servo-weft` `f1ba496`: removed `servo_pref = "layout.unimplemented"` - from `backdrop-filter` in `style/properties/longhands.toml` (enables parsing). - - `marcoallegretti/servo` `servo-weft` `8e7dc40`: `Cargo.toml` patched to use the stylo fork; - `style_ext.rs` adds `backdrop-filter` to `establishes_stacking_context` and - `establishes_containing_block_for_all_descendants`; `stacking_context.rs` guards the - WebRender stacking-context early-return on `backdrop_filter.0.is_empty()`; `display_list/mod.rs` - adds `BuilderForBoxFragment::build_backdrop_filter` calling `push_backdrop_filter` before - background paint. -- **Per-app process isolation**: ~~not implemented~~ **Resolved** — each app runs in a separate - `weft-app-shell` and `weft-runtime` OS process pair supervised by `weft-appd`. OS-level - isolation does not require Servo's multi-process constellation architecture. -- **SpiderMonkey sandbox**: SpiderMonkey is not sandbox-isolated beyond process-level isolation. - JIT-compiled JS runs with the same memory permissions as the Servo process. WEFT relies on - SpiderMonkey's own security properties for the JavaScript execution boundary. See - `docs/security.md` for the full bounded statement. Not addressed. +Status is stated against executed evidence; code that exists but has not been +exercised is listed as unverified. + +- **Embedder API**: both `weft-servo-shell` and `weft-app-shell` fail to compile + with `servo-embed` against this revision (keyboard events, mouse actions, + rendering readback, shutdown and window-handle APIs changed). Until they + build and present a frame, input forwarding, surface sharing and rendering + in the shells are unverified. +- **`backdrop-filter`**: the parsing (Stylo `f1ba496`) and rendering (Servo + `8e7dc40`, `f0bb1aa`) patches are selected by the lockfile. Rendering is + unverified until a pixel check passes on the shells. +- **Shell surface association**: the shells pass winit's `wl_display` and + `wl_surface` to `zweft_shell_manager_v1.create_window` through a shared + connection; unverified at this revision. +- **WebGPU on Mesa**: not evaluated. +- **Process separation**: each app runs as separate `weft-app-shell` and + `weft-runtime` processes supervised by `weft-appd`. Separate processes alone + do not confine the renderer; see `docs/security.md`. +- **SpiderMonkey**: JIT-compiled JavaScript runs with the Servo process's + permissions; WEFT relies on SpiderMonkey's own security properties for the + JavaScript boundary. See `docs/security.md`. ## Update policy -The `servo-weft` branch is the working branch for WEFT-specific Servo patches. -Upstream servo/servo changes are merged into it periodically. +`servo-weft` in `marcoallegretti/servo` and `servo-weft` in +`marcoallegretti/stylo` carry WEFT-specific patches. WEFT pins exact revisions +rather than tracking a branch, so a rebuild selects the same code. A pinned +revision must stay reachable from a published branch: never force-push, +rebase or delete a branch that contains a revision a WEFT lockfile selects. +Today Servo `f0bb1aa` is reachable only from `fix/backdrop-filter-build-errors` +and Stylo `f1ba496` only from Stylo's `servo-weft`. -To rebase onto a new upstream commit: +To move to new revisions: -1. In the `marcoallegretti/servo` repo: `git fetch upstream && git rebase upstream/main` on `servo-weft`. -2. Force-push `servo-weft`. -3. Update `Rev` in this file to the new tip SHA. -4. Run `cargo update -p servo` in the WEFT OS workspace. -5. Confirm the compositor and shell tests still pass. +1. Land the Servo or Stylo change on the fork and note its commit. +2. Update the `rev` values in `crates/weft-servo-shell/Cargo.toml`, + `crates/weft-app-shell/Cargo.toml` and, for Stylo, the root `[patch]`. +3. Run `cargo update -p servo` (and `cargo update -p stylo` for a Stylo-only change). +4. Confirm with `grep -A2 'name = "servo"' Cargo.lock` and + `grep -A2 'name = "stylo"' Cargo.lock` that the lockfile selects them, that + `cargo metadata --locked` succeeds, and that `grep -c servo/stylo Cargo.lock` + prints `0`, which shows the override applies to every Stylo crate. +5. Recompute the `outputHashes` in `infra/nixos/weft-packages.nix` for each + changed git source. +6. Run `cargo check -p weft-servo-shell --features servo-embed --locked` and + `cargo check -p weft-app-shell --features servo-embed --locked`, plus the + rendering checks for any behavior the change claims, and update the tables + in this file. -To submit patches upstream: open a PR from `servo-weft` (or a topic branch) to `servo/servo`. +Each fork patch keeps its purpose, upstream status and removal condition here. -## Stylo fork - -The Stylo CSS engine is a separate repo (`servo/stylo`) pinned at rev `dca3934667dae76c49bb579b268c5eb142d09c6a` -in `Cargo.toml`. To patch it for WEFT-specific changes (e.g. enabling `backdrop-filter`): - -1. Fork `servo/stylo` to `marcoallegretti/stylo`, create branch `servo-weft`. -2. Make changes on that branch. -3. Add to this fork's `Cargo.toml` workspace `[patch]` section: - -```toml -[patch."https://github.com/servo/stylo"] -stylo = { git = "https://github.com/marcoallegretti/stylo", branch = "servo-weft" } -stylo_atoms = { git = "https://github.com/marcoallegretti/stylo", branch = "servo-weft" } -stylo_dom = { git = "https://github.com/marcoallegretti/stylo", branch = "servo-weft" } -stylo_malloc_size_of = { git = "https://github.com/marcoallegretti/stylo", branch = "servo-weft" } -stylo_static_prefs = { git = "https://github.com/marcoallegretti/stylo", branch = "servo-weft" } -stylo_traits = { git = "https://github.com/marcoallegretti/stylo", branch = "servo-weft" } -selectors = { git = "https://github.com/marcoallegretti/stylo", branch = "servo-weft" } -servo_arc = { git = "https://github.com/marcoallegretti/stylo", branch = "servo-weft" } -``` - -1. Run `cargo update` to resolve the new stylo deps. -2. Commit both the `Cargo.toml` and `Cargo.lock` changes to `servo-weft`. +| Patch | Fork commit | Purpose | Upstream status | Remove when | +|-------|-------------|---------|-----------------|-------------| +| Stylo: parse `backdrop-filter` for Servo | stylo `f1ba496` | Remove the `layout.unimplemented` gate | Not submitted | Upstream Stylo parses it for Servo | +| Servo: render `backdrop-filter` | servo `8e7dc40` | Stacking context and display list support | servo/servo issue [#41567](https://github.com/servo/servo/issues/41567) | Equivalent upstream support | +| Servo: fix `build_backdrop_filter` types | servo `f0bb1aa` | Make `servo-layout` compile | Part of the patch above | Same as above | diff --git a/docs/building.md b/docs/building.md index 96f1359..c282c5e 100644 --- a/docs/building.md +++ b/docs/building.md @@ -43,7 +43,7 @@ cargo build -p weft-servo-shell --features servo-embed cargo build -p weft-app-shell --features servo-embed ``` -This fetches and compiles the Servo fork (`github.com/marcoallegretti/servo`, branch `servo-weft`). Expect 30–60 minutes on a clean build. Servo's dependencies include SpiderMonkey (C++), which requires `clang` and `python3`. +This fetches and compiles the Servo and Stylo forks at the revisions recorded in `Cargo.lock` (see `crates/weft-servo-shell/SERVO_PIN.md`). Expect 30–60 minutes on a clean build. Servo's dependencies include SpiderMonkey (C++), which requires `clang` and `python3`. ## Demo apps (wasm32-wasip2) @@ -86,7 +86,7 @@ Run with QEMU: bash infra/vm/run.sh ``` -See `infra/nixos/weft-packages.nix` for the package derivations. The `outputHashes` entry for the Servo git dependency must be filled in before the `servo-embed` packages will build under Nix. +See `infra/nixos/weft-packages.nix` for the package derivations. Its `outputHashes` hold one hash per git source in `Cargo.lock` (the Servo and Stylo forks); every package vendors them, so they must match the pinned revisions for any Nix package to build. The Nix shell packages do not yet enable `servo-embed`. ## CI diff --git a/infra/nixos/weft-packages.nix b/infra/nixos/weft-packages.nix index 8ca8e42..2d9ba82 100644 --- a/infra/nixos/weft-packages.nix +++ b/infra/nixos/weft-packages.nix @@ -10,9 +10,13 @@ let cargoLock = { lockFile = ../../Cargo.lock; + # One hash per git source in Cargo.lock: the Servo fork and the Stylo fork + # (keyed by its `selectors` crate). Every package vendors both, so both must + # match the pinned revisions. Recompute them whenever a revision changes. + # The Servo hash is not yet known for f0bb1aa; a Nix build reports it. outputHashes = { - "servo-0.0.1" = "0b803qankr0rs4hi0md26dydf2cvpd6v5x2bxxypzsga0jwfdd26"; - "selectors-0.36.0" = "1x5g61cadq700yhl1wwrjd043grlpdviqqn4n9cm5k68gbx0if81"; + "servo-0.0.1" = pkgs.lib.fakeHash; + "selectors-0.36.0" = "13y6pa19j4w2zsxfhv6mrl03wsa0frazlsssbqkzpwci8k9gzl4i"; }; }; From 64f8cff6fd5668be69824a89e1660b2ab3c6e335 Mon Sep 17 00:00:00 2001 From: Marco Allegretti Date: Fri, 9 Oct 2026 01:02:26 +0000 Subject: [PATCH 2/3] fix(shells): paint and present Servo frames and report readiness truthfully With servo-embed, weft-servo-shell and weft-app-shell did not compile against the selected Servo revision: the keyboard event shape, key and mouse action variants, frame readback, shutdown, URL type and window handle APIs had changed. The frame path never called WebView::paint; the software path rebuilt its softbuffer surface every frame and read pixels without painting, and the EGL path presented nothing. weft-app-shell printed READY right after creating its WebView, before any frame, and its feature-disabled build printed READY and parked. Servo also disables CSS Grid by default, which the system UI uses. Both hosts now build against the selected API. Each frame is painted with WebView::paint and presented: the software path reads the painted frame back, presents the context and copies it into a persistent softbuffer surface; the EGL path presents its window context. Nothing is presented before Servo's first repaint request. Shutdown drops the WebView and Servo, whose drop completes the shutdown, and exits the event loop. Both hosts enable layout_grid_enabled. weft-app-shell prints READY on the first frame presented after the document has loaded and Servo reports its rendering settled: on load completion it requests WebView::take_screenshot, which completes only once every frame has fired load, render-blocking resources, images and web fonts are done and the rendering is up to date. Feature-disabled builds of both hosts exit with an error instead of reporting readiness. weft-appd does not consume the app shell's READY yet. tests/frame/check_frame.py runs weft-compositor nested on Xvfb with the winit backend, starts a host showing tests/frame/reference.html and checks the presented pixels (four colour quadrants and text). For the app host the page must be on screen within two seconds of READY; --slow-style delays a render-blocking stylesheet that reveals the page, so premature readiness fails. Validation (Ubuntu 24.04, Mesa 25.2.8 llvmpipe, software path): - check_frame.py --host system, --host app and --host app --slow-style 3: 5 of 5 runs pass each - negative fixtures fail: page with red and green swapped; a fake host printing READY without rendering; a local build printing READY on its first presented frame (--slow-style 4, 3 of 3) - cargo clippy -D warnings with and without servo-embed; cargo fmt --check - unverified: EGL path, DRM, resize, output scale, idle wakeup, input --- README.md | 2 +- crates/weft-app-shell/src/embedder.rs | 302 ++++++++++------ crates/weft-app-shell/src/keyutils.rs | 20 +- crates/weft-app-shell/src/main.rs | 6 +- crates/weft-app-shell/src/shell_client.rs | 4 - crates/weft-servo-shell/SERVO_PIN.md | 64 +++- crates/weft-servo-shell/src/embedder.rs | 257 +++++++++----- crates/weft-servo-shell/src/keyutils.rs | 20 +- crates/weft-servo-shell/src/shell_client.rs | 4 - docs/building.md | 24 +- tests/frame/check_frame.py | 370 ++++++++++++++++++++ tests/frame/reference.html | 21 ++ 12 files changed, 840 insertions(+), 254 deletions(-) create mode 100644 tests/frame/check_frame.py create mode 100644 tests/frame/reference.html diff --git a/README.md b/README.md index 0abad34..a43db81 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ WEFT OS is a Wayland compositor and application runtime where every app is a Web **Compositor** — `weft-compositor` is a Smithay-based Wayland compositor with DRM/KMS and winit backends. It implements the `zweft-shell-unstable-v1` protocol extension, which typed shell slots (panel, application) register against. -**System shell** — `weft-servo-shell` embeds Servo (feature-gated, `--features servo-embed`) and renders `system-ui.html` as a Wayland panel. Without `servo-embed`, the binary builds as a no-op stub. Navigation gestures from the compositor are forwarded to `weft-appd` over WebSocket. +**System shell** — `weft-servo-shell` embeds Servo (feature-gated, `--features servo-embed`) and renders `system-ui.html` as a Wayland panel. Without `servo-embed`, the binary exits with an error instead of rendering. Navigation gestures from the compositor are forwarded to `weft-appd` over WebSocket. **App shell** — `weft-app-shell` is a per-process Servo host for application WebViews. It resolves `weft-app:///ui/index.html`, injects a `weftIpc` WebSocket bridge into the page, and registers with the compositor as an application surface. Also feature-gated behind `servo-embed`. diff --git a/crates/weft-app-shell/src/embedder.rs b/crates/weft-app-shell/src/embedder.rs index 6fae473..f9551ca 100644 --- a/crates/weft-app-shell/src/embedder.rs +++ b/crates/weft-app-shell/src/embedder.rs @@ -1,20 +1,22 @@ -#![cfg(feature = "servo-embed")] - +use std::num::NonZeroU32; use std::path::PathBuf; use std::rc::Rc; +use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::{Arc, Mutex}; use servo::{ - EventLoopWaker, InputEvent, MouseButton as ServoMouseButton, MouseButtonAction, - MouseButtonEvent, MouseMoveEvent, ServoBuilder, ServoDelegate, ServoUrl, UserContentManager, + DeviceIntRect, DeviceIntSize, DevicePoint, EventLoopWaker, InputEvent, LoadStatus, + MouseButton as ServoMouseButton, MouseButtonAction, MouseButtonEvent, MouseMoveEvent, + RenderingContext, RgbaImage, ServoBuilder, ServoDelegate, ServoUrl, UserContentManager, UserScript, WebViewBuilder, WebViewDelegate, }; use winit::{ application::ApplicationHandler, + dpi::PhysicalSize, event::{ElementState, MouseButton, WindowEvent}, event_loop::{ActiveEventLoop, EventLoop, EventLoopProxy}, keyboard::ModifiersState, - platform::wayland::{ActiveEventLoopExtWayland, WindowExtWayland}, + raw_window_handle::{HasDisplayHandle, HasWindowHandle, RawDisplayHandle, RawWindowHandle}, window::{Window, WindowAttributes, WindowId}, }; @@ -48,29 +50,133 @@ impl ServoDelegate for WeftServoDelegate { } } +/// Frame and load progress reported by Servo, shared with the event loop. +#[derive(Default)] +struct FrameSignals { + /// A new frame is waiting to be painted. + redraw: AtomicBool, + /// Servo has requested at least one repaint. + content: AtomicBool, + /// The document has loaded and Servo reports its rendering is up to date. + settled: AtomicBool, +} + struct WeftWebViewDelegate { - redraw_requested: Arc, + signals: Arc, } impl WebViewDelegate for WeftWebViewDelegate { fn notify_new_frame_ready(&self, _webview: servo::WebView) { - self.redraw_requested - .store(true, std::sync::atomic::Ordering::Relaxed); + self.signals.content.store(true, Ordering::Relaxed); + self.signals.redraw.store(true, Ordering::Relaxed); + } + + fn notify_load_status_changed(&self, webview: servo::WebView, status: LoadStatus) { + if status != LoadStatus::Complete { + return; + } + // Servo completes a screenshot request only once every frame has fired + // `load`, render-blocking resources, images and web fonts are done and + // the rendering is up to date, which is the readiness this host reports. + let signals = Arc::clone(&self.signals); + webview.take_screenshot(None, move |result| match result { + Ok(_) => { + signals.settled.store(true, Ordering::Relaxed); + signals.redraw.store(true, Ordering::Relaxed); + } + Err(e) => tracing::error!(?e, "document rendering did not settle; not ready"), + }); } } +/// Servo preferences shared by the WEFT hosts. +fn host_preferences() -> servo::Preferences { + servo::Preferences { + // The system UI and application pages lay out with CSS Grid, which + // Servo disables by default. + layout_grid_enabled: true, + ..Default::default() + } +} + +// ── Rendering ─────────────────────────────────────────────────────────────── + +type BlitSurface = softbuffer::Surface, Arc>; + enum RenderingCtx { - Software(Rc), + /// Servo renders offscreen; each frame is read back and copied to the window. + Software { + context: Rc, + surface: BlitSurface, + }, + /// Servo renders directly to the window's EGL surface. Egl(Rc), } impl RenderingCtx { - fn as_dyn(&self) -> Rc { + fn as_dyn(&self) -> Rc { match self { - Self::Software(rc) => Rc::clone(rc) as Rc, - Self::Egl(rc) => Rc::clone(rc) as Rc, + Self::Software { context, .. } => Rc::clone(context) as Rc, + Self::Egl(context) => Rc::clone(context) as Rc, } } + + /// Paints the webview into this context and presents the frame on the window. + fn paint_and_present(&mut self, webview: &servo::WebView) -> Result<(), String> { + match self { + Self::Software { context, surface } => { + context + .make_current() + .map_err(|e| format!("make_current: {e:?}"))?; + webview.paint(); + let size = context.size(); + let rect = DeviceIntRect::from_size(DeviceIntSize::new( + size.width as i32, + size.height as i32, + )); + let image = context.read_to_image(rect); + context.present(); + let image = image.ok_or("frame readback failed")?; + blit(surface, &image) + } + Self::Egl(context) => { + context + .make_current() + .map_err(|e| format!("make_current: {e:?}"))?; + webview.paint(); + context.present(); + Ok(()) + } + } + } +} + +/// Copies an RGBA frame into the window's software surface and presents it. +fn blit(surface: &mut BlitSurface, image: &RgbaImage) -> Result<(), String> { + let (width, height) = image.dimensions(); + let (Some(w), Some(h)) = (NonZeroU32::new(width), NonZeroU32::new(height)) else { + return Ok(()); + }; + surface.resize(w, h).map_err(|e| format!("resize: {e}"))?; + let mut buffer = surface.buffer_mut().map_err(|e| format!("buffer: {e}"))?; + for (dst, src) in buffer.iter_mut().zip(image.as_raw().chunks_exact(4)) { + *dst = u32::from(src[0]) << 16 | u32::from(src[1]) << 8 | u32::from(src[2]); + } + buffer.present().map_err(|e| format!("present: {e}")) +} + +/// Returns winit's `wl_display` and `wl_surface` pointers when running on Wayland. +fn wayland_handles( + event_loop: &ActiveEventLoop, + window: &Window, +) -> Option<(*mut std::ffi::c_void, *mut std::ffi::c_void)> { + let RawDisplayHandle::Wayland(display) = event_loop.display_handle().ok()?.as_raw() else { + return None; + }; + let RawWindowHandle::Wayland(surface) = window.window_handle().ok()?.as_raw() else { + return None; + }; + Some((display.display.as_ptr(), surface.surface.as_ptr())) } struct App { @@ -82,12 +188,12 @@ struct App { servo: Option, webview: Option, rendering_context: Option, - redraw_requested: Arc, + signals: Arc, waker: WeftEventLoopWaker, shutting_down: bool, ready_signalled: bool, modifiers: ModifiersState, - cursor_pos: servo::euclid::default::Point2D, + cursor_pos: DevicePoint, shell_client: Option, } @@ -108,47 +214,46 @@ impl App { servo: None, webview: None, rendering_context: None, - redraw_requested: Arc::new(std::sync::atomic::AtomicBool::new(false)), + signals: Arc::default(), waker, shutting_down: false, ready_signalled: false, modifiers: ModifiersState::default(), - cursor_pos: servo::euclid::default::Point2D::zero(), + cursor_pos: DevicePoint::origin(), shell_client: None, } } - fn render_frame(window: &Arc, ctx: &RenderingCtx) { - match ctx { - RenderingCtx::Software(rc) => Self::blit_software(window, rc), - RenderingCtx::Egl(_) => {} + /// Paints and presents once Servo has requested its first repaint. + /// + /// Nothing is presented before that request; the first frames can still be + /// blank or unstyled while the document loads. READY is printed after a + /// frame is presented once the document has loaded and its rendering has + /// settled. + fn render_frame(&mut self) { + if !self.signals.content.load(Ordering::Relaxed) { + return; + } + let (Some(webview), Some(context)) = (&self.webview, &mut self.rendering_context) else { + return; + }; + if let Err(e) = context.paint_and_present(webview) { + tracing::warn!("frame not presented: {e}"); + return; + } + if !self.ready_signalled && self.signals.settled.load(Ordering::Relaxed) { + self.ready_signalled = true; + println!("READY"); + use std::io::Write; + let _ = std::io::stdout().flush(); } } - fn blit_software(window: &Arc, rendering_context: &servo::SoftwareRenderingContext) { - let size = window.inner_size(); - let Some(pixels) = rendering_context.read_pixels() else { - return; - }; - let Ok(ctx) = softbuffer::Context::new(Arc::clone(window)) else { - tracing::warn!("softbuffer context creation failed; skipping frame"); - return; - }; - let Ok(mut surface) = softbuffer::Surface::new(&ctx, Arc::clone(window)) else { - tracing::warn!("softbuffer surface creation failed; skipping frame"); - return; - }; - let _ = surface.resize( - std::num::NonZeroU32::new(size.width).unwrap_or(std::num::NonZeroU32::MIN), - std::num::NonZeroU32::new(size.height).unwrap_or(std::num::NonZeroU32::MIN), - ); - let Ok(mut buf) = surface.buffer_mut() else { - return; - }; - for (dst, src) in buf.iter_mut().zip(pixels.chunks(4)) { - *dst = u32::from_be_bytes([0, src[0], src[1], src[2]]); - } - let _ = buf.present(); + /// Drops the webview and Servo; dropping the last `Servo` handle shuts it down. + fn shut_down(&mut self) { + self.shutting_down = true; + self.webview = None; + self.servo = None; } } @@ -171,23 +276,22 @@ impl ApplicationHandler for App { let size = window.inner_size(); self.window = Some(Arc::clone(&window)); - if self.shell_client.is_none() { - if let (Some(disp), Some(surf)) = - (event_loop.wayland_display(), window.wayland_surface()) - { - match crate::shell_client::ShellClient::connect_as_app_with_display( - &self.app_id, - self.session_id, - disp, - surf, - ) { - Ok(sc) => self.shell_client = Some(sc), - Err(e) => tracing::warn!(error = %e, "shell protocol unavailable"), - } + if self.shell_client.is_none() + && let Some((disp, surf)) = wayland_handles(event_loop, &window) + { + match crate::shell_client::ShellClient::connect_as_app_with_display( + &self.app_id, + self.session_id, + disp, + surf, + ) { + Ok(sc) => self.shell_client = Some(sc), + Err(e) => tracing::warn!(error = %e, "shell protocol unavailable"), } } let servo = ServoBuilder::default() + .preferences(host_preferences()) .event_loop_waker(Box::new(self.waker.clone())) .build(); @@ -212,22 +316,15 @@ impl ApplicationHandler for App { let webview = WebViewBuilder::new(&servo, rendering_context.as_dyn()) .delegate(Rc::new(WeftWebViewDelegate { - redraw_requested: Arc::clone(&self.redraw_requested), + signals: Arc::clone(&self.signals), })) .user_content_manager(ucm) - .url(self.url.clone()) + .url(self.url.clone().into_url()) .build(); self.servo = Some(servo); self.webview = Some(webview); self.rendering_context = Some(rendering_context); - - if !self.ready_signalled { - self.ready_signalled = true; - println!("READY"); - use std::io::Write; - let _ = std::io::stdout().flush(); - } } fn user_event(&mut self, _event_loop: &ActiveEventLoop, _event: ServoWake) { @@ -241,28 +338,26 @@ impl ApplicationHandler for App { event_loop.exit(); return; } + let mut compositor_closed = false; if let Some(sc) = &mut self.shell_client { match sc.dispatch_pending() { - Ok(false) => { - self.shutting_down = true; - if let Some(servo) = &self.servo { - servo.start_shutting_down(); - } - } + Ok(false) => compositor_closed = true, Err(e) => tracing::warn!("shell client dispatch error: {e}"), Ok(true) => {} } } + if compositor_closed { + self.shut_down(); + event_loop.exit(); + return; + } if let Some(servo) = &self.servo { servo.spin_event_loop(); } - if self - .redraw_requested - .swap(false, std::sync::atomic::Ordering::Relaxed) + if self.signals.redraw.swap(false, Ordering::Relaxed) + && let Some(w) = &self.window { - if let Some(w) = &self.window { - w.request_redraw(); - } + w.request_redraw(); } } @@ -273,18 +368,13 @@ impl ApplicationHandler for App { event: WindowEvent, ) { match event { - WindowEvent::RedrawRequested => { - if let (Some(window), Some(servo)) = (&self.window, &self.servo) { - if let Some(rc) = &self.rendering_context { - Self::render_frame(window, rc); - } - servo.spin_event_loop(); - } - } + WindowEvent::RedrawRequested => self.render_frame(), WindowEvent::Resized(new_size) => { - let sz = servo::euclid::Size2D::new(new_size.width, new_size.height); + if new_size.width == 0 || new_size.height == 0 { + return; + } if let Some(wv) = &self.webview { - wv.resize(sz); + wv.resize(new_size); } } WindowEvent::ModifiersChanged(mods) => { @@ -297,10 +387,11 @@ impl ApplicationHandler for App { } } WindowEvent::CursorMoved { position, .. } => { - let pt = servo::euclid::default::Point2D::new(position.x as f32, position.y as f32); + let pt = DevicePoint::new(position.x as f32, position.y as f32); self.cursor_pos = pt; if let Some(wv) = &self.webview { - let _ = wv.notify_input_event(InputEvent::MouseMove(MouseMoveEvent::new(pt))); + let _ = wv + .notify_input_event(InputEvent::MouseMove(MouseMoveEvent::new(pt.into()))); } } WindowEvent::MouseInput { state, button, .. } => { @@ -311,22 +402,19 @@ impl ApplicationHandler for App { _ => return, }; let action = match state { - ElementState::Pressed => MouseButtonAction::Click, + ElementState::Pressed => MouseButtonAction::Down, ElementState::Released => MouseButtonAction::Up, }; if let Some(wv) = &self.webview { let _ = wv.notify_input_event(InputEvent::MouseButton(MouseButtonEvent::new( action, btn, - self.cursor_pos.cast_unit(), + self.cursor_pos.into(), ))); } } WindowEvent::CloseRequested => { - self.shutting_down = true; - if let Some(servo) = &self.servo { - servo.start_shutting_down(); - } + self.shut_down(); event_loop.exit(); } _ => {} @@ -337,7 +425,7 @@ impl ApplicationHandler for App { fn build_rendering_ctx( event_loop: &ActiveEventLoop, window: &Arc, - size: winit::dpi::PhysicalSize, + size: PhysicalSize, ) -> Option { if std::env::var_os("WEFT_EGL_RENDERING").is_some() { let display_handle = event_loop.display_handle(); @@ -349,16 +437,26 @@ fn build_rendering_ctx( return Some(RenderingCtx::Egl(Rc::new(rc))); } Err(e) => { - tracing::warn!("EGL rendering context failed ({e}), falling back to software"); + tracing::warn!( + "EGL rendering context failed ({e:?}), falling back to software" + ); } } } } - match servo::SoftwareRenderingContext::new(servo::euclid::Size2D::new(size.width, size.height)) - { - Ok(rc) => Some(RenderingCtx::Software(Rc::new(rc))), + let context = match servo::SoftwareRenderingContext::new(size) { + Ok(rc) => Rc::new(rc), Err(e) => { - tracing::error!("SoftwareRenderingContext failed: {e}"); + tracing::error!("SoftwareRenderingContext failed: {e:?}"); + return None; + } + }; + let surface = softbuffer::Context::new(Arc::clone(window)) + .and_then(|display| softbuffer::Surface::new(&display, Arc::clone(window))); + match surface { + Ok(surface) => Some(RenderingCtx::Software { context, surface }), + Err(e) => { + tracing::error!("software presentation surface failed: {e}"); None } } diff --git a/crates/weft-app-shell/src/keyutils.rs b/crates/weft-app-shell/src/keyutils.rs index c4fd87b..1665cb5 100644 --- a/crates/weft-app-shell/src/keyutils.rs +++ b/crates/weft-app-shell/src/keyutils.rs @@ -1,5 +1,3 @@ -#![cfg(feature = "servo-embed")] - use servo::{Code, Key, KeyState, KeyboardEvent, Location, Modifiers}; use winit::event::ElementState; use winit::keyboard::{Key as WinitKey, KeyLocation, ModifiersState, NamedKey, PhysicalKey}; @@ -14,10 +12,11 @@ pub fn keyboard_event_from_winit( }; let key = match &event.logical_key { + WinitKey::Named(NamedKey::Space) => Key::Character(" ".to_string()), WinitKey::Named(n) => Key::Named(named_key(*n)), - WinitKey::Character(c) => Key::Character(c.to_string().into()), - WinitKey::Unidentified(_) => Key::Unidentified, - WinitKey::Dead(c) => Key::Dead(*c), + WinitKey::Character(c) => Key::Character(c.to_string()), + WinitKey::Unidentified(_) => Key::Named(servo::NamedKey::Unidentified), + WinitKey::Dead(_) => Key::Named(servo::NamedKey::Dead), }; let code = match event.physical_key { @@ -46,15 +45,7 @@ pub fn keyboard_event_from_winit( mods |= Modifiers::META; } - KeyboardEvent { - state, - key, - code, - location, - modifiers: mods, - repeat: event.repeat, - is_composing: false, - } + KeyboardEvent::new_without_event(state, key, code, location, mods, event.repeat, false) } fn named_key(n: NamedKey) -> servo::NamedKey { @@ -74,7 +65,6 @@ fn named_key(n: NamedKey) -> servo::NamedKey { NamedKey::SymbolLock => S::SymbolLock, NamedKey::Enter => S::Enter, NamedKey::Tab => S::Tab, - NamedKey::Space => S::Space, NamedKey::ArrowDown => S::ArrowDown, NamedKey::ArrowLeft => S::ArrowLeft, NamedKey::ArrowRight => S::ArrowRight, diff --git a/crates/weft-app-shell/src/main.rs b/crates/weft-app-shell/src/main.rs index df6c191..36d308c 100644 --- a/crates/weft-app-shell/src/main.rs +++ b/crates/weft-app-shell/src/main.rs @@ -57,10 +57,6 @@ fn embed_app(app_id: &str, session_id: u64, ws_port: u16) -> anyhow::Result<()> #[cfg(not(feature = "servo-embed"))] { let _ = (app_id, session_id, ws_port); - println!("READY"); - use std::io::Write; - let _ = std::io::stdout().flush(); - std::thread::park(); - Ok(()) + anyhow::bail!("weft-app-shell was built without the servo-embed feature and cannot render") } } diff --git a/crates/weft-app-shell/src/shell_client.rs b/crates/weft-app-shell/src/shell_client.rs index 58d8918..3a66eb9 100644 --- a/crates/weft-app-shell/src/shell_client.rs +++ b/crates/weft-app-shell/src/shell_client.rs @@ -215,8 +215,4 @@ impl ShellClient { self.event_queue.flush().context("Wayland flush")?; Ok(!self.data.window_state.closed) } - - pub fn window_state(&self) -> &ShellWindowState { - &self.data.window_state - } } diff --git a/crates/weft-servo-shell/SERVO_PIN.md b/crates/weft-servo-shell/SERVO_PIN.md index a2b7100..928d56f 100644 --- a/crates/weft-servo-shell/SERVO_PIN.md +++ b/crates/weft-servo-shell/SERVO_PIN.md @@ -75,32 +75,64 @@ Install with: `sudo zypper install -y libglvnd-devel libopenssl-devel dbus-1-dev ## Rendering approach -Default: `SoftwareRenderingContext` (CPU rasterisation) blitted to a -`softbuffer`-backed winit window. +Each frame is painted with `WebView::paint` and then presented: -EGL path: set `WEFT_EGL_RENDERING=1` at runtime. The embedder attempts -`WindowRenderingContext::new` using the winit display and window handles. -If construction fails it falls back to software automatically. -When the EGL path is active Servo presents directly to the EGL surface via -surfman's `eglSwapBuffers`; the softbuffer blit is skipped. Mesa handles -DMA-BUF buffer sharing with the compositor transparently. +- **Software (default):** Servo renders into a `SoftwareRenderingContext`. + The host reads the painted frame back with `read_to_image`, presents the + context and copies the pixels into a persistent `softbuffer` surface on the + winit window. +- **EGL:** with `WEFT_EGL_RENDERING=1` the host creates a + `WindowRenderingContext` from winit's display and window handles and + presents it directly. If that fails it falls back to software. + +Neither host presents anything before Servo's first repaint request; the +first frames can still be blank or unstyled while the document loads. Both +enable Servo's `layout_grid_enabled` preference, because the system UI and +application pages use CSS Grid, which Servo disables by default. + +`weft-app-shell` prints `READY` after it presents a frame once the document +has loaded and Servo reports its rendering settled: on load completion it +requests `WebView::take_screenshot`, whose callback runs only after `load` has +fired in every frame, render-blocking resources, images and web fonts are done +and the rendering is up to date. `weft-appd` does not read this signal yet; it +treats the runtime's `READY` as session readiness. Neither host prints `READY` +when built without `servo-embed`; both exit with an error instead. + +`tests/frame/check_frame.py` checks this on a real display path: it runs +`weft-compositor` nested on Xvfb and checks the pixels each host presents for +`tests/frame/reference.html`. For the app host it requires the page on screen +within two seconds of `READY`; `--slow-style` delays a render-blocking +stylesheet that reveals the page, which makes premature readiness visible. A +build that printed `READY` on its first presented frame failed every +`--slow-style 4` run; that build was a local experiment, not part of history. ## Known limitations at this pin Status is stated against executed evidence; code that exists but has not been exercised is listed as unverified. -- **Embedder API**: both `weft-servo-shell` and `weft-app-shell` fail to compile - with `servo-embed` against this revision (keyboard events, mouse actions, - rendering readback, shutdown and window-handle APIs changed). Until they - build and present a frame, input forwarding, surface sharing and rendering - in the shells are unverified. +- **Verified rendering path:** both hosts present the reference page through + `weft-compositor`'s winit backend on Xvfb with Mesa 25.2.8 llvmpipe, using + the software path (Ubuntu 24.04, x86_64; `check_frame.py --host system`, + `--host app` and `--host app --slow-style 3`, five runs each). The EGL path, + DRM sessions, resize, output scale and idle wakeup are unverified. +- **Input:** keyboard and pointer events are forwarded through + `WebView::notify_input_event`; delivery through the compositor is + unverified. - **`backdrop-filter`**: the parsing (Stylo `f1ba496`) and rendering (Servo - `8e7dc40`, `f0bb1aa`) patches are selected by the lockfile. Rendering is - unverified until a pixel check passes on the shells. + `8e7dc40`, `f0bb1aa`) patches are selected by the lockfile; rendering is + unverified. +- **Resources:** the hosts install no Servo resource reader, so Servo logs + `Resource reader not set` and uses empty resources: the public suffix list, + HSTS preload list, Bluetooth blocklist, certificate and network error pages, + crash and directory-listing pages and media controls. Servo falls back to its + built-in placeholder image. +- **Window decorations:** `weft-compositor` offers no server-side decorations, + so winit draws a client-side title bar on both hosts' windows, including the + system panel. - **Shell surface association**: the shells pass winit's `wl_display` and `wl_surface` to `zweft_shell_manager_v1.create_window` through a shared - connection; unverified at this revision. + connection; unverified. - **WebGPU on Mesa**: not evaluated. - **Process separation**: each app runs as separate `weft-app-shell` and `weft-runtime` processes supervised by `weft-appd`. Separate processes alone diff --git a/crates/weft-servo-shell/src/embedder.rs b/crates/weft-servo-shell/src/embedder.rs index 6d7e875..e8c9a8c 100644 --- a/crates/weft-servo-shell/src/embedder.rs +++ b/crates/weft-servo-shell/src/embedder.rs @@ -1,20 +1,22 @@ -#![cfg(feature = "servo-embed")] - +use std::num::NonZeroU32; use std::path::{Path, PathBuf}; use std::rc::Rc; +use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::{Arc, Mutex}; use servo::{ - EventLoopWaker, InputEvent, MouseButton as ServoMouseButton, MouseButtonAction, - MouseButtonEvent, MouseMoveEvent, ServoBuilder, ServoDelegate, ServoUrl, UserContentManager, + DeviceIntRect, DeviceIntSize, DevicePoint, EventLoopWaker, InputEvent, + MouseButton as ServoMouseButton, MouseButtonAction, MouseButtonEvent, MouseMoveEvent, + RenderingContext, RgbaImage, ServoBuilder, ServoDelegate, ServoUrl, UserContentManager, UserScript, WebViewBuilder, WebViewDelegate, }; use winit::{ application::ApplicationHandler, + dpi::PhysicalSize, event::{ElementState, MouseButton, WindowEvent}, event_loop::{ActiveEventLoop, EventLoop, EventLoopProxy}, keyboard::ModifiersState, - platform::wayland::{ActiveEventLoopExtWayland, WindowExtWayland}, + raw_window_handle::{HasDisplayHandle, HasWindowHandle, RawDisplayHandle, RawWindowHandle}, window::{Window, WindowAttributes, WindowId}, }; @@ -54,31 +56,114 @@ impl ServoDelegate for WeftServoDelegate { // ── WebView delegate ────────────────────────────────────────────────────────── +/// Frame and load progress reported by Servo, shared with the event loop. +#[derive(Default)] +struct FrameSignals { + /// A new frame is waiting to be painted. + redraw: AtomicBool, + /// Servo has requested at least one repaint. + content: AtomicBool, +} + struct WeftWebViewDelegate { - redraw_requested: Arc, + signals: Arc, } impl WebViewDelegate for WeftWebViewDelegate { fn notify_new_frame_ready(&self, _webview: servo::WebView) { - self.redraw_requested - .store(true, std::sync::atomic::Ordering::Relaxed); + self.signals.content.store(true, Ordering::Relaxed); + self.signals.redraw.store(true, Ordering::Relaxed); } } -// ── Rendering context abstraction (GAP-2) ─────────────────────────────────── +/// Servo preferences shared by the WEFT hosts. +fn host_preferences() -> servo::Preferences { + servo::Preferences { + // The system UI and application pages lay out with CSS Grid, which + // Servo disables by default. + layout_grid_enabled: true, + ..Default::default() + } +} + +// ── Rendering ─────────────────────────────────────────────────────────────── + +type BlitSurface = softbuffer::Surface, Arc>; enum RenderingCtx { - Software(Rc), + /// Servo renders offscreen; each frame is read back and copied to the window. + Software { + context: Rc, + surface: BlitSurface, + }, + /// Servo renders directly to the window's EGL surface. Egl(Rc), } impl RenderingCtx { - fn as_dyn(&self) -> Rc { + fn as_dyn(&self) -> Rc { match self { - Self::Software(rc) => Rc::clone(rc) as Rc, - Self::Egl(rc) => Rc::clone(rc) as Rc, + Self::Software { context, .. } => Rc::clone(context) as Rc, + Self::Egl(context) => Rc::clone(context) as Rc, } } + + /// Paints the webview into this context and presents the frame on the window. + fn paint_and_present(&mut self, webview: &servo::WebView) -> Result<(), String> { + match self { + Self::Software { context, surface } => { + context + .make_current() + .map_err(|e| format!("make_current: {e:?}"))?; + webview.paint(); + let size = context.size(); + let rect = DeviceIntRect::from_size(DeviceIntSize::new( + size.width as i32, + size.height as i32, + )); + let image = context.read_to_image(rect); + context.present(); + let image = image.ok_or("frame readback failed")?; + blit(surface, &image) + } + Self::Egl(context) => { + context + .make_current() + .map_err(|e| format!("make_current: {e:?}"))?; + webview.paint(); + context.present(); + Ok(()) + } + } + } +} + +/// Copies an RGBA frame into the window's software surface and presents it. +fn blit(surface: &mut BlitSurface, image: &RgbaImage) -> Result<(), String> { + let (width, height) = image.dimensions(); + let (Some(w), Some(h)) = (NonZeroU32::new(width), NonZeroU32::new(height)) else { + return Ok(()); + }; + surface.resize(w, h).map_err(|e| format!("resize: {e}"))?; + let mut buffer = surface.buffer_mut().map_err(|e| format!("buffer: {e}"))?; + for (dst, src) in buffer.iter_mut().zip(image.as_raw().chunks_exact(4)) { + *dst = u32::from(src[0]) << 16 | u32::from(src[1]) << 8 | u32::from(src[2]); + } + buffer.present().map_err(|e| format!("present: {e}")) +} + +/// Returns winit's `wl_display` and `wl_surface` pointers when running on Wayland. +fn wayland_handles( + event_loop: &ActiveEventLoop, + window: &Window, +) -> Option<(*mut std::ffi::c_void, *mut std::ffi::c_void)> { + let RawDisplayHandle::Wayland(display) = event_loop.display_handle().ok()?.as_raw() else { + return None; + }; + let RawWindowHandle::Wayland(surface) = window.window_handle().ok()?.as_raw() else { + return None; + }; + Some((display.display.as_ptr(), surface.surface.as_ptr())) } // ── Application state ───────────────────────────────────────────────────────── @@ -90,11 +175,11 @@ struct App { servo: Option, webview: Option, rendering_context: Option, - redraw_requested: Arc, + signals: Arc, waker: WeftEventLoopWaker, shutting_down: bool, modifiers: ModifiersState, - cursor_pos: servo::euclid::default::Point2D, + cursor_pos: DevicePoint, shell_client: Option, gesture_thread: Option>, } @@ -108,47 +193,37 @@ impl App { servo: None, webview: None, rendering_context: None, - redraw_requested: Arc::new(std::sync::atomic::AtomicBool::new(false)), + signals: Arc::default(), waker, shutting_down: false, modifiers: ModifiersState::default(), - cursor_pos: servo::euclid::default::Point2D::zero(), + cursor_pos: DevicePoint::origin(), shell_client: None, gesture_thread: None, } } - fn render_frame(window: &Arc, ctx: &RenderingCtx) { - match ctx { - RenderingCtx::Software(rc) => Self::blit_software(window, rc), - RenderingCtx::Egl(_) => {} + /// Paints and presents once Servo has requested its first repaint. + /// + /// Nothing is presented before that request; the first frames can still be + /// blank or unstyled while the document loads. + fn render_frame(&mut self) { + if !self.signals.content.load(Ordering::Relaxed) { + return; + } + let (Some(webview), Some(context)) = (&self.webview, &mut self.rendering_context) else { + return; + }; + if let Err(e) = context.paint_and_present(webview) { + tracing::warn!("frame not presented: {e}"); } } - fn blit_software(window: &Arc, rendering_context: &servo::SoftwareRenderingContext) { - let size = window.inner_size(); - let Some(pixels) = rendering_context.read_pixels() else { - return; - }; - let Ok(ctx) = softbuffer::Context::new(Arc::clone(window)) else { - tracing::warn!("softbuffer context creation failed; skipping frame"); - return; - }; - let Ok(mut surface) = softbuffer::Surface::new(&ctx, Arc::clone(window)) else { - tracing::warn!("softbuffer surface creation failed; skipping frame"); - return; - }; - let _ = surface.resize( - std::num::NonZeroU32::new(size.width).unwrap_or(std::num::NonZeroU32::MIN), - std::num::NonZeroU32::new(size.height).unwrap_or(std::num::NonZeroU32::MIN), - ); - let Ok(mut buf) = surface.buffer_mut() else { - return; - }; - for (dst, src) in buf.iter_mut().zip(pixels.chunks(4)) { - *dst = u32::from_be_bytes([0, src[0], src[1], src[2]]); - } - let _ = buf.present(); + /// Drops the webview and Servo; dropping the last `Servo` handle shuts it down. + fn shut_down(&mut self) { + self.shutting_down = true; + self.webview = None; + self.servo = None; } } @@ -170,18 +245,17 @@ impl ApplicationHandler for App { let size = window.inner_size(); self.window = Some(Arc::clone(&window)); - if self.shell_client.is_none() { - if let (Some(disp), Some(surf)) = - (event_loop.wayland_display(), window.wayland_surface()) - { - match crate::shell_client::ShellClient::connect_with_display(disp, surf) { - Ok(sc) => self.shell_client = Some(sc), - Err(e) => tracing::warn!(error = %e, "shell protocol unavailable"), - } + if self.shell_client.is_none() + && let Some((disp, surf)) = wayland_handles(event_loop, &window) + { + match crate::shell_client::ShellClient::connect_with_display(disp, surf) { + Ok(sc) => self.shell_client = Some(sc), + Err(e) => tracing::warn!(error = %e, "shell protocol unavailable"), } } let servo = ServoBuilder::default() + .preferences(host_preferences()) .event_loop_waker(Box::new(self.waker.clone())) .build(); @@ -205,10 +279,10 @@ impl ApplicationHandler for App { let webview = WebViewBuilder::new(&servo, rendering_context.as_dyn()) .delegate(Rc::new(WeftWebViewDelegate { - redraw_requested: Arc::clone(&self.redraw_requested), + signals: Arc::clone(&self.signals), })) .user_content_manager(Rc::clone(&user_content_manager)) - .url(self.url.clone()) + .url(self.url.clone().into_url()) .build(); self.servo = Some(servo); @@ -227,14 +301,10 @@ impl ApplicationHandler for App { event_loop.exit(); return; } + let mut compositor_closed = false; if let Some(sc) = &mut self.shell_client { match sc.dispatch_pending() { - Ok(false) => { - self.shutting_down = true; - if let Some(servo) = &self.servo { - servo.start_shutting_down(); - } - } + Ok(false) => compositor_closed = true, Err(e) => tracing::warn!("shell client dispatch error: {e}"), Ok(true) => {} } @@ -258,16 +328,18 @@ impl ApplicationHandler for App { } } } + if compositor_closed { + self.shut_down(); + event_loop.exit(); + return; + } if let Some(servo) = &self.servo { servo.spin_event_loop(); } - if self - .redraw_requested - .swap(false, std::sync::atomic::Ordering::Relaxed) + if self.signals.redraw.swap(false, Ordering::Relaxed) + && let Some(w) = &self.window { - if let Some(w) = &self.window { - w.request_redraw(); - } + w.request_redraw(); } } @@ -278,18 +350,13 @@ impl ApplicationHandler for App { event: WindowEvent, ) { match event { - WindowEvent::RedrawRequested => { - if let (Some(window), Some(servo)) = (&self.window, &self.servo) { - if let Some(rc) = &self.rendering_context { - Self::render_frame(window, rc); - } - servo.spin_event_loop(); - } - } + WindowEvent::RedrawRequested => self.render_frame(), WindowEvent::Resized(new_size) => { - let sz = servo::euclid::Size2D::new(new_size.width, new_size.height); + if new_size.width == 0 || new_size.height == 0 { + return; + } if let Some(wv) = &self.webview { - wv.resize(sz); + wv.resize(new_size); } } WindowEvent::ModifiersChanged(mods) => { @@ -302,10 +369,11 @@ impl ApplicationHandler for App { } } WindowEvent::CursorMoved { position, .. } => { - let pt = servo::euclid::default::Point2D::new(position.x as f32, position.y as f32); + let pt = DevicePoint::new(position.x as f32, position.y as f32); self.cursor_pos = pt; if let Some(wv) = &self.webview { - let _ = wv.notify_input_event(InputEvent::MouseMove(MouseMoveEvent::new(pt))); + let _ = wv + .notify_input_event(InputEvent::MouseMove(MouseMoveEvent::new(pt.into()))); } } WindowEvent::MouseInput { state, button, .. } => { @@ -316,22 +384,19 @@ impl ApplicationHandler for App { _ => return, }; let action = match state { - ElementState::Pressed => MouseButtonAction::Click, + ElementState::Pressed => MouseButtonAction::Down, ElementState::Released => MouseButtonAction::Up, }; if let Some(wv) = &self.webview { let _ = wv.notify_input_event(InputEvent::MouseButton(MouseButtonEvent::new( action, btn, - self.cursor_pos.cast_unit(), + self.cursor_pos.into(), ))); } } WindowEvent::CloseRequested => { - self.shutting_down = true; - if let Some(servo) = &self.servo { - servo.start_shutting_down(); - } + self.shut_down(); event_loop.exit(); } _ => {} @@ -344,7 +409,7 @@ impl ApplicationHandler for App { fn build_rendering_ctx( event_loop: &ActiveEventLoop, window: &Arc, - size: winit::dpi::PhysicalSize, + size: PhysicalSize, ) -> Option { if std::env::var_os("WEFT_EGL_RENDERING").is_some() { let display_handle = event_loop.display_handle(); @@ -356,16 +421,26 @@ fn build_rendering_ctx( return Some(RenderingCtx::Egl(Rc::new(rc))); } Err(e) => { - tracing::warn!("EGL rendering context failed ({e}), falling back to software"); + tracing::warn!( + "EGL rendering context failed ({e:?}), falling back to software" + ); } } } } - match servo::SoftwareRenderingContext::new(servo::euclid::Size2D::new(size.width, size.height)) - { - Ok(rc) => Some(RenderingCtx::Software(Rc::new(rc))), + let context = match servo::SoftwareRenderingContext::new(size) { + Ok(rc) => Rc::new(rc), Err(e) => { - tracing::error!("SoftwareRenderingContext failed: {e}"); + tracing::error!("SoftwareRenderingContext failed: {e:?}"); + return None; + } + }; + let surface = softbuffer::Context::new(Arc::clone(window)) + .and_then(|display| softbuffer::Surface::new(&display, Arc::clone(window))); + match surface { + Ok(surface) => Some(RenderingCtx::Software { context, surface }), + Err(e) => { + tracing::error!("software presentation surface failed: {e}"); None } } diff --git a/crates/weft-servo-shell/src/keyutils.rs b/crates/weft-servo-shell/src/keyutils.rs index c4fd87b..1665cb5 100644 --- a/crates/weft-servo-shell/src/keyutils.rs +++ b/crates/weft-servo-shell/src/keyutils.rs @@ -1,5 +1,3 @@ -#![cfg(feature = "servo-embed")] - use servo::{Code, Key, KeyState, KeyboardEvent, Location, Modifiers}; use winit::event::ElementState; use winit::keyboard::{Key as WinitKey, KeyLocation, ModifiersState, NamedKey, PhysicalKey}; @@ -14,10 +12,11 @@ pub fn keyboard_event_from_winit( }; let key = match &event.logical_key { + WinitKey::Named(NamedKey::Space) => Key::Character(" ".to_string()), WinitKey::Named(n) => Key::Named(named_key(*n)), - WinitKey::Character(c) => Key::Character(c.to_string().into()), - WinitKey::Unidentified(_) => Key::Unidentified, - WinitKey::Dead(c) => Key::Dead(*c), + WinitKey::Character(c) => Key::Character(c.to_string()), + WinitKey::Unidentified(_) => Key::Named(servo::NamedKey::Unidentified), + WinitKey::Dead(_) => Key::Named(servo::NamedKey::Dead), }; let code = match event.physical_key { @@ -46,15 +45,7 @@ pub fn keyboard_event_from_winit( mods |= Modifiers::META; } - KeyboardEvent { - state, - key, - code, - location, - modifiers: mods, - repeat: event.repeat, - is_composing: false, - } + KeyboardEvent::new_without_event(state, key, code, location, mods, event.repeat, false) } fn named_key(n: NamedKey) -> servo::NamedKey { @@ -74,7 +65,6 @@ fn named_key(n: NamedKey) -> servo::NamedKey { NamedKey::SymbolLock => S::SymbolLock, NamedKey::Enter => S::Enter, NamedKey::Tab => S::Tab, - NamedKey::Space => S::Space, NamedKey::ArrowDown => S::ArrowDown, NamedKey::ArrowLeft => S::ArrowLeft, NamedKey::ArrowRight => S::ArrowRight, diff --git a/crates/weft-servo-shell/src/shell_client.rs b/crates/weft-servo-shell/src/shell_client.rs index b57ab85..7af2270 100644 --- a/crates/weft-servo-shell/src/shell_client.rs +++ b/crates/weft-servo-shell/src/shell_client.rs @@ -239,10 +239,6 @@ impl ShellClient { Ok(!self.data.window_state.closed) } - pub fn window_state(&self) -> &ShellWindowState { - &self.data.window_state - } - pub fn take_pending_gestures(&mut self) -> Vec { std::mem::take(&mut self.data.pending_gestures) } diff --git a/docs/building.md b/docs/building.md index c282c5e..a6b8af0 100644 --- a/docs/building.md +++ b/docs/building.md @@ -34,7 +34,7 @@ cargo build -p weft-servo-shell cargo build -p weft-app-shell ``` -Without `--features servo-embed`, the servo-shell and app-shell stubs compile and print READY without running an actual WebView. This is the default and the CI baseline. +Without `--features servo-embed`, the servo-shell and app-shell binaries compile for type and lint checks but exit with an error at startup; they never report readiness. This is the default and the CI baseline. ## Servo embedding (optional, slow) @@ -45,6 +45,28 @@ cargo build -p weft-app-shell --features servo-embed This fetches and compiles the Servo and Stylo forks at the revisions recorded in `Cargo.lock` (see `crates/weft-servo-shell/SERVO_PIN.md`). Expect 30–60 minutes on a clean build. Servo's dependencies include SpiderMonkey (C++), which requires `clang` and `python3`. +## Frame check + +`tests/frame/check_frame.py` runs `weft-compositor` nested on Xvfb with the +winit backend, starts a Servo host showing `tests/frame/reference.html`, and +checks the presented pixels. It needs `Xvfb`, `xwd`, ImageMagick's `convert` +and a Mesa OpenGL driver (llvmpipe is sufficient). + +```sh +cargo build -p weft-compositor +cargo build -p weft-servo-shell -p weft-app-shell \ + --features weft-servo-shell/servo-embed,weft-app-shell/servo-embed +python3 tests/frame/check_frame.py --host system +python3 tests/frame/check_frame.py --host app +python3 tests/frame/check_frame.py --host app --slow-style 3 +``` + +`--host app` also requires the page on screen within two seconds of +`weft-app-shell` printing `READY`; `--slow-style` delays a stylesheet that +reveals the page so premature readiness becomes visible. + +Logs and the last capture are written to `target/frame-check`. + ## Demo apps (wasm32-wasip2) Each demo is a standalone crate in `examples/`. Pre-built `app.wasm` binaries are committed. To rebuild: diff --git a/tests/frame/check_frame.py b/tests/frame/check_frame.py new file mode 100644 index 0000000..eacce3f --- /dev/null +++ b/tests/frame/check_frame.py @@ -0,0 +1,370 @@ +"""Check that a Servo host paints and presents a known page through weft-compositor. + +The harness starts Xvfb, runs weft-compositor nested on it with the winit +backend, launches a Servo host as a Wayland client showing `reference.html`, +captures the X screen and checks the presented pixels: four solid quadrants +(red, green, blue, white) in the page's arrangement and dark text pixels +inside the white quadrant. It exits non-zero when the frame never appears or +does not match. + +`--host system` runs weft-servo-shell with the page as its system UI. +`--host app` installs the page as a package in a temporary app store and runs +weft-app-shell for it. The host must print READY, and the page must be on +screen within a short grace period after READY, because the compositor shows +a presented frame slightly later. READY printed within that grace before the +page is presented is therefore not detected. `--slow-style SECONDS` makes +early readiness observable: the page stays hidden until a stylesheet that a +local HTTP server delivers after the delay reveals it, so a host that reports +READY before the document has loaded shows no page within the grace period. + +Requires Xvfb, xwd and ImageMagick's convert. Processes are started from +argument arrays and are always terminated before the harness exits. +""" + +import argparse +import http.server +import os +import re +import shutil +import signal +import subprocess +import sys +import tempfile +import threading +import time +from pathlib import Path + + +HERE = Path(__file__).resolve().parent +ROOT = HERE.parents[1] +SCREEN = (1024, 768) +COLORS = { + "red": (255, 0, 0), + "green": (0, 255, 0), + "blue": (0, 0, 255), + "white": (255, 255, 255), +} +MIN_SIDE = 40 +MIN_TEXT_PIXELS = 30 +ANSI_ESCAPE = re.compile(r"\x1b\[[0-9;]*m") + + +def parse_ppm(data): + """Decode a binary P6 PPM into (width, height, bytes).""" + tokens = [] + index = 0 + while len(tokens) < 4: + while data[index:index + 1].isspace(): + index += 1 + if data[index:index + 1] == b"#": + index = data.index(b"\n", index) + 1 + continue + end = index + while not data[end:end + 1].isspace(): + end += 1 + tokens.append(data[index:end]) + index = end + magic, width, height, maxval = tokens + if magic != b"P6" or int(maxval) != 255: + raise ValueError("expected an 8-bit P6 image") + width, height = int(width), int(height) + pixels = data[index + 1:index + 1 + width * height * 3] + if len(pixels) != width * height * 3: + raise ValueError("truncated image") + return width, height, pixels + + +def bounding_box(width, height, pixels, color): + """Return (x0, y0, x1, y1) of pixels exactly matching color, or None.""" + target = bytes(color) + xs, ys = [], [] + for y in range(0, height, 2): + row = pixels[y * width * 3:(y + 1) * width * 3] + start = row.find(target) + while start != -1: + if start % 3 == 0: + xs.append(start // 3) + ys.append(y) + start = row.find(target, start + 3) + else: + # A match spanning two pixels; realign on the next byte. + start = row.find(target, start + 1) + if not xs: + return None + return min(xs), min(ys), max(xs), max(ys) + + +def dark_pixels(width, pixels, box): + x0, y0, x1, y1 = box + count = 0 + for y in range(y0, y1 + 1): + for x in range(x0, x1 + 1): + offset = (y * width + x) * 3 + if max(pixels[offset:offset + 3]) < 96: + count += 1 + return count + + +def evaluate(width, height, pixels): + """Return a list of problems with the captured frame; empty means it matches.""" + boxes = {name: bounding_box(width, height, pixels, color) for name, color in COLORS.items()} + problems = [f"no {name} region" for name, box in boxes.items() if box is None] + if problems: + return problems + for name, (x0, y0, x1, y1) in boxes.items(): + if x1 - x0 < MIN_SIDE or y1 - y0 < MIN_SIDE: + problems.append(f"{name} region too small: {x1 - x0 + 1}x{y1 - y0 + 1}") + red, green, blue, white = (boxes[n] for n in ("red", "green", "blue", "white")) + if not green[0] > red[2]: + problems.append("green is not right of red") + if not blue[1] > red[3]: + problems.append("blue is not below red") + if not (white[0] > blue[2] and white[1] > green[3]): + problems.append("white is not below green and right of blue") + if abs(red[1] - green[1]) > 4 or abs(red[0] - blue[0]) > 4: + problems.append("quadrants are not aligned") + text = dark_pixels(width, pixels, white) + if text < MIN_TEXT_PIXELS: + problems.append(f"no text in white region ({text} dark pixels)") + return problems + + +APP_ID = "org.weft.test.frame" +COMPOSITE_GRACE = 2.0 + + +def install_app(store, page): + """Install `page` as the UI entry of a minimal package and return the store root.""" + package = store / APP_ID + (package / "ui").mkdir(parents=True) + shutil.copyfile(page, package / "ui" / "index.html") + (package / "wapp.toml").write_text( + "[package]\n" + f'id = "{APP_ID}"\n' + 'name = "Frame reference"\n' + 'version = "0.0.0"\n' + "\n[runtime]\n" + 'module = "app.wasm"\n' + "\n[ui]\n" + 'entry = "ui/index.html"\n', + encoding="utf-8", + ) + return store + + +def slow_style_server(delay): + """Serve a stylesheet that reveals the page after `delay` seconds.""" + class Handler(http.server.BaseHTTPRequestHandler): + def do_GET(self): + time.sleep(delay) + body = b"body { visibility: visible; }" + self.send_response(200) + self.send_header("Content-Type", "text/css") + self.send_header("Content-Length", str(len(body))) + self.end_headers() + self.wfile.write(body) + + def log_message(self, *args): + pass + + server = http.server.ThreadingHTTPServer(("127.0.0.1", 0), Handler) + threading.Thread(target=server.serve_forever, daemon=True).start() + return server + + +def hidden_until_styled(page, destination, port): + """Copy `page`, hiding its body until the delayed stylesheet loads.""" + html = page.read_text(encoding="utf-8") + link = (f'\n' + f'\n') + if "" not in html: + raise ValueError(f"{page} has no ") + destination.write_text(html.replace("", link, 1), encoding="utf-8") + return destination + + +def capture(display): + xwd = subprocess.run(["xwd", "-root", "-silent", "-display", display], + capture_output=True, check=True, timeout=20) + ppm = subprocess.run(["convert", "xwd:-", "ppm:-"], input=xwd.stdout, + capture_output=True, check=True, timeout=20) + return ppm.stdout + + +def free_display(): + for number in range(90, 140): + if not Path(f"/tmp/.X11-unix/X{number}").exists() and \ + not Path(f"/tmp/.X{number}-lock").exists(): + return f":{number}" + raise RuntimeError("no free X display number") + + +def start(command, log, env): + return subprocess.Popen(command, stdout=log, stderr=subprocess.STDOUT, env=env, + start_new_session=True) + + +def signal_group(process, signum): + try: + os.killpg(process.pid, signum) + except ProcessLookupError: + pass + + +def stop(process): + """Terminate the process and everything left in its process group.""" + if process is None: + return + signal_group(process, signal.SIGTERM) + try: + process.wait(timeout=10) + except subprocess.TimeoutExpired: + signal_group(process, signal.SIGKILL) + process.wait(timeout=10) + signal_group(process, signal.SIGKILL) + + +def wait_for(predicate, timeout, interval=0.5): + deadline = time.monotonic() + timeout + while time.monotonic() < deadline: + result = predicate() + if result: + return result + time.sleep(interval) + return None + + +def main(argv=None): + parser = argparse.ArgumentParser(description=__doc__, + formatter_class=argparse.RawDescriptionHelpFormatter) + parser.add_argument("--compositor", type=Path, + default=ROOT / "target/debug/weft-compositor") + parser.add_argument("--host", choices=("system", "app"), default="system") + parser.add_argument("--shell", type=Path, + help="host binary (default: target/debug/weft-servo-shell or " + "target/debug/weft-app-shell)") + parser.add_argument("--page", type=Path, default=HERE / "reference.html") + parser.add_argument("--slow-style", type=float, metavar="SECONDS", + help="hide the page until a stylesheet delayed by SECONDS loads") + parser.add_argument("--timeout", type=float, default=120.0, + help="seconds to wait for a matching frame") + parser.add_argument("--output", type=Path, default=ROOT / "target/frame-check", + help="directory for logs and the captured screenshot") + args = parser.parse_args(argv) + if args.shell is None: + name = "weft-servo-shell" if args.host == "system" else "weft-app-shell" + args.shell = ROOT / "target/debug" / name + + for tool in ("Xvfb", "xwd", "convert"): + if shutil.which(tool) is None: + print(f"missing required tool: {tool}", file=sys.stderr) + return 2 + for binary in (args.compositor, args.shell): + if not binary.is_file(): + print(f"missing binary: {binary}", file=sys.stderr) + return 2 + + args.output.mkdir(parents=True, exist_ok=True) + runtime = Path(tempfile.mkdtemp(prefix="weft-frame-")) + runtime.chmod(0o700) + display = free_display() + base_env = {key: value for key, value in os.environ.items() + if key not in ("DISPLAY", "WAYLAND_DISPLAY", "WAYLAND_SOCKET")} + base_env["XDG_RUNTIME_DIR"] = str(runtime) + base_env.setdefault("RUST_LOG", "info") + + page = args.page + style_server = None + if args.slow_style: + style_server = slow_style_server(args.slow_style) + page = hidden_until_styled(args.page, runtime / "page.html", + style_server.server_address[1]) + + processes = [] + logs = {name: open(args.output / f"{name}.log", "w", encoding="utf-8") + for name in ("xvfb", "compositor", "shell")} + try: + xvfb = start(["Xvfb", display, "-screen", "0", f"{SCREEN[0]}x{SCREEN[1]}x24", + "-nolisten", "tcp"], logs["xvfb"], base_env) + processes.append(xvfb) + if not wait_for(lambda: Path(f"/tmp/.X11-unix/X{display[1:]}").exists(), 15): + print("Xvfb did not start", file=sys.stderr) + return 1 + + compositor_env = dict(base_env, DISPLAY=display) + compositor = start([str(args.compositor), "--winit"], logs["compositor"], + compositor_env) + processes.append(compositor) + compositor_log = args.output / "compositor.log" + + def socket_name(): + if compositor.poll() is not None: + return "exited" + text = ANSI_ESCAPE.sub("", compositor_log.read_text(encoding="utf-8", + errors="replace")) + match = re.search(r'socket_name="([^"]+)"', text) + return match and match.group(1) + + socket = wait_for(socket_name, 30) + if socket in (None, "exited"): + print(f"compositor did not open a Wayland socket; see {compositor_log}", + file=sys.stderr) + return 1 + + shell_env = dict(base_env, WAYLAND_DISPLAY=socket) + if args.host == "system": + shell_env["WEFT_SYSTEM_UI_HTML"] = str(page.resolve()) + command = [str(args.shell)] + else: + shell_env["WEFT_APP_STORE"] = str(install_app(runtime / "store", page)) + command = [str(args.shell), APP_ID, "1"] + shell = start(command, logs["shell"], shell_env) + processes.append(shell) + shell_log = args.output / "shell.log" + + def ready_printed(): + text = shell_log.read_text(encoding="utf-8", errors="replace") + return any(line.strip() == "READY" for line in text.splitlines()) + + problems = ["no frame captured"] + screenshot = None + ready_at = None + deadline = time.monotonic() + args.timeout + while time.monotonic() < deadline: + if shell.poll() is not None: + problems = [f"shell exited with status {shell.returncode}"] + break + if args.host == "app" and ready_at is None and ready_printed(): + ready_at = time.monotonic() + ready = ready_at is not None + screenshot = capture(display) + problems = evaluate(*parse_ppm(screenshot)) + if ready and problems and time.monotonic() - ready_at > COMPOSITE_GRACE: + problems = [f"page not on screen {COMPOSITE_GRACE:g} s after READY"] + problems + break + if not problems and (args.host == "system" or ready): + break + if not problems: + problems = ["frame presented but READY not printed"] + time.sleep(1) + + if screenshot is not None: + (args.output / "frame.ppm").write_bytes(screenshot) + if problems: + print("frame check failed: " + "; ".join(problems), file=sys.stderr) + print(f"logs and last capture in {args.output}", file=sys.stderr) + return 1 + print(f"frame check passed; capture in {args.output / 'frame.ppm'}") + return 0 + finally: + for process in reversed(processes): + stop(process) + if style_server is not None: + style_server.shutdown() + for log in logs.values(): + log.close() + shutil.rmtree(runtime, ignore_errors=True) + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/tests/frame/reference.html b/tests/frame/reference.html new file mode 100644 index 0000000..4428b86 --- /dev/null +++ b/tests/frame/reference.html @@ -0,0 +1,21 @@ + + + + +WEFT frame reference + + + +
+
+
+
WEFT
+ + From 1e19326d3953440a231ea8b08cbd3ff6e2ea7b5f Mon Sep 17 00:00:00 2001 From: Marco Allegretti Date: Thu, 8 Oct 2026 22:58:47 +0000 Subject: [PATCH 3/3] fix(compositor): collapse nested submit condition in winit backend The nested if around backend.submit failed clippy::collapsible_if under -D warnings, breaking the linux-only clippy job. Use a let chain instead. --- crates/weft-compositor/src/backend/winit.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/crates/weft-compositor/src/backend/winit.rs b/crates/weft-compositor/src/backend/winit.rs index 087b04c..7575211 100644 --- a/crates/weft-compositor/src/backend/winit.rs +++ b/crates/weft-compositor/src/backend/winit.rs @@ -157,10 +157,8 @@ pub fn run() -> anyhow::Result<()> { false } }; - if render_ok { - if let Err(e) = backend.submit(Some(&[full_damage])) { - tracing::warn!(?e, "backend submit failed"); - } + if render_ok && let Err(e) = backend.submit(Some(&[full_damage])) { + tracing::warn!(?e, "backend submit failed"); } state.space.elements().for_each(|window| {