webkit-spike: hidden run result, D-035..D-040, plans 08 WebKit engine S044-S055
GTK 4 host + transparent egui GLArea over WebKitGTK proven hidden (Xvfb + nested niri): pick fall-through, real input and IME, egui menus over video, pacing equal with and without the overlay. Spike fixes: IM client widget, wl-input Y flip, SPIKE_EGUI=0 layout, URL trim. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
parent
b6a5a21481
commit
63b39d7b7e
5 changed files with 640 additions and 16 deletions
BIN
docs/engine/spike/ctx_link.jpg
Normal file
BIN
docs/engine/spike/ctx_link.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 140 KiB |
BIN
docs/engine/spike/ctxmenu.jpg
Normal file
BIN
docs/engine/spike/ctxmenu.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 155 KiB |
BIN
docs/engine/spike/flyout.jpg
Normal file
BIN
docs/engine/spike/flyout.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 201 KiB |
BIN
docs/engine/spike/ime_preedit_url.png
Normal file
BIN
docs/engine/spike/ime_preedit_url.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2 KiB |
|
|
@ -1,8 +1,71 @@
|
|||
# WebKit embedding spike (D-033, in progress)
|
||||
# WebKit embedding spike (D-033)
|
||||
|
||||
## WIP state (2026-11-13, stopped for the usage limit)
|
||||
## Result (2026-11-13): design (b) works
|
||||
|
||||
**Done**
|
||||
Nacre's chrome as a transparent egui `Gtk.GLArea` over WebKitGTK 6.0 views in a GTK 4 window holds up: egui draws
|
||||
over a playing video, GTK's own pick sends pointer input to egui only where egui has something, everything else
|
||||
reaches WebKit natively (click, wheel, right click, typing, IME), and egui costs almost nothing per frame. D-033
|
||||
stands. The GPU path was not exercised (see Unproven).
|
||||
|
||||
### How it was run (D-034: hidden)
|
||||
`kwin_wayland` is not installed (no sway/weston/cage either), so the hidden session is **Xvfb + a nested niri**:
|
||||
niri's winit backend runs as an X11 client of Xvfb and gives a private Wayland socket with the same protocols the
|
||||
user's niri has (wlr virtual pointer, input-method-v2, virtual keyboard, screencopy for `grim`). Scripts:
|
||||
`spikes/webkit-egui/run/` (`nested.sh start|stop`, `spike.sh`, `seq*.sh`; outputs in `$SPIKE_RUN`, default
|
||||
`/tmp/webkit-spike`). Quirks, all handled there:
|
||||
- Xvfb has no DRI3, so the nested niri renders with llvmpipe and cannot import GPU dmabufs (it died on the first
|
||||
WebKit frame). Clients run with software GL too: `LIBGL_ALWAYS_SOFTWARE=1 WEBKIT_DMABUF_RENDERER_FORCE_SHM=1
|
||||
GSK_RENDERER=gl`. The nested output (`winit`, 1280x800 @ 60 Hz) caps painting at ~30 fps with llvmpipe.
|
||||
- The nested winit output mirrors absolute virtual-pointer Y: `WL_INPUT_FLIP_Y=1` in `wl-input`.
|
||||
- The Wayland socket path must be short (`SUN_LEN`): runtime dir `/run/user/<uid>/nsp`.
|
||||
- `NIRI_SOCKET` from the user's session must be overridden, or `niri msg` talks to the real compositor.
|
||||
- Private bus via `dbus-run-session`; `GTK_A11Y=none NO_AT_BRIDGE=1 GDK_DEBUG=no-portals` keep a11y/portal noise out.
|
||||
|
||||
### Checks (YouTube watch `aqz-KE-bpKQ`, Wikipedia, DuckDuckGo, example.com; real compositor input)
|
||||
| Check | Result |
|
||||
|---|---|
|
||||
| egui flyout over a playing video, transparent elsewhere | yes (`docs/engine/spike/flyout.jpg`) |
|
||||
| `pick` (GTK's hit test): toolbar, open flyout → `NacreEguiArea`; page, and page under a closed flyout → `WebKitWebView` | yes, all 8 points |
|
||||
| real click on page | starts YouTube playback; clicks on recommendations navigate |
|
||||
| real click on an egui flyout item over the page | "Zoom in" applied (zoom 1.1), page got nothing |
|
||||
| wheel over page | `scrollY` 0 → 410 after 5 notches |
|
||||
| right click on YouTube's video | YouTube's own player menu at the pointer (`ctxmenu.jpg`), as in Chromium |
|
||||
| right click on a link elsewhere | WebKit `context-menu` signal (hit test gives the link) → egui menu at the pointer (`ctx_link.jpg`); its "Open link in new tab" opens tab 2 |
|
||||
| typing (virtual keyboard) into the egui URL field + Enter | navigates |
|
||||
| typing into a page textarea (DuckDuckGo) | `abc ` arrives |
|
||||
| IME preedit + commit into a page textarea | native WebKit: `abc 日本語` (preedit visible in the value during composition) |
|
||||
| IME into the egui URL field | first failed (no text-input-v3 enabled); fixed by `IMMulticontext::set_client_widget` (+ cursor location from egui's `platform_output.ime`); then preedit and commit reach egui (`ime_preedit_url.png`; CJK shows as boxes only because the spike's egui has no CJK font, Nacre's font setup has) |
|
||||
| `window.open` | opens as a new tab through `create` with a related view; clicking tab 0 switches back |
|
||||
| video | readyState 4; 628 frames, 0 dropped in 21 s of playback (YouTube served 30 fps) |
|
||||
|
||||
### Pacing and memory (one YouTube tab playing, 15 s window, software GL)
|
||||
| | egui overlay on | `SPIKE_EGUI=0` |
|
||||
|---|---|---|
|
||||
| window frames / fps | 450 / 29.6 | 444 / 29.4 |
|
||||
| frame interval p50 / p95 / max | 33 / 50 / 50 ms | 33 / 50 / 50 ms |
|
||||
| egui renders in 15 s, render ms p50 / p95 | 65, 0.46 / 0.60 ms | — |
|
||||
| video frames / dropped | 628 / 0 | 628 / 0 |
|
||||
| tree PSS median / max (`sample.py`, ~21 processes incl. bwrap sandboxes) | 1310 / 1437 MB | 1287 / 1517 MB |
|
||||
| tree CPU median (% of one core) | 204 % | 188 % |
|
||||
|
||||
egui only repaints on its own events (no repaint per video frame), so the overlay costs no extra frames, ~20 MB of PSS
|
||||
and some llvmpipe compositing of the full-window GLArea texture (+16 % of a core in software; should be far less on
|
||||
the GPU). Pacing is identical with and without the overlay.
|
||||
|
||||
### Fixed in the spike during the run
|
||||
`wl-input` Y flip switch; IM client widget + cursor location; URL field input trimmed; with `SPIKE_EGUI=0` the
|
||||
WebView stack is the overlay's child (a `Gtk.Fixed` child kept its 0x0 natural size).
|
||||
|
||||
### Unproven (carry into the 08 plans)
|
||||
- **GPU path**: dmabuf frames from WebKit composited under the GLArea, 60 fps video with the overlay, VRAM. Needs a
|
||||
run on the real GPU: visible on DP-1 when the user is awake (D-034), or `SMOKE_VISIBLE=1` in the ported harness.
|
||||
- Web Inspector window, fullscreen, file chooser / dialogs, several windows, HiDPI scale > 1, drag and drop,
|
||||
Ctrl+L/T capture keys while the page has focus (code present, not exercised).
|
||||
- egui needs the GLArea to repaint on its own animations (`repaint_delay` timer, present) — the S039 motion work
|
||||
relies on that; check animation smoothness once Nacre's chrome runs on it.
|
||||
|
||||
## Background
|
||||
**Setup (session 1)**
|
||||
- Read: CLAUDE.md, HANDOFF "Orchestrator resume (2026-11-13)", D-032, `engine-comparison.md`, `docs/engine/tune/`
|
||||
(check jsons + samples), `tools/engine-test/webkit_shell.py`. Not yet read: `docs/engine/servo-removal.md` (baa3b7f;
|
||||
4 open decisions: ad-block interception, cookie encryption, profile dir rename, Media Session/MPRIS).
|
||||
|
|
@ -17,7 +80,7 @@
|
|||
- Crates (pinned in the spike): `gtk4 =0.11.5` (feature v4_20), `webkit6 =0.6.1` (feature v2_52; latest, no v2_54
|
||||
feature), `egui`/`egui_glow =0.37.0`, `glow =0.17.0`, `wayland-client =0.31.15`, `wayland-protocols-wlr`/`-misc
|
||||
=0.3.12`. No usable Rust crate for WPE Platform 2.x (would need gir/bindgen).
|
||||
- Spike code `spikes/webkit-egui/` (own Cargo workspace and target/), **builds, never run yet**:
|
||||
- Spike code `spikes/webkit-egui/` (own Cargo workspace and target/):
|
||||
- `src/egui_area.rs`: `Gtk.GLArea` subclass painting egui with egui_glow (GL via eglGetProcAddress), transparent
|
||||
clear; `contains()` takes the pointer only outside egui's page rect or over an egui Area, so GTK's pick falls
|
||||
through to the WebView for page input; GTK motion/click/scroll/key controllers + `IMMulticontext` → egui events.
|
||||
|
|
@ -36,10 +99,3 @@ app.rs (egui-winit → own GTK→egui input glue as in egui_area.rs). WPE would
|
|||
translation and frame import, and has no Inspector UI. Unproven until the spike runs: GLArea transparency over the
|
||||
WebView, pick fall-through, frame pacing with video under the overlay.
|
||||
|
||||
**Exact next step**: ask the orchestrator/user how to run visibly (the user rejected a run that switched DP-1 to an
|
||||
empty workspace and maximized the window; options: visible without moving focus, or hidden nested
|
||||
`kwin_wayland --virtual`). Then run `spikes/webkit-egui/target/release/webkit-egui` with a throwaway HOME and
|
||||
`SPIKE_CMD`, YouTube watch page: shots (toolbar, ⋮ flyout over playing video, context menu), `pick` toolbar vs page,
|
||||
`stats` during playback (with and without `SPIKE_EGUI=0`), wl-input click/scroll/right click/IME into URL field and a
|
||||
page input, popup, two tabs; RAM via `tools/engine-test/sample.py`; Chromium reference shot in the browser pane
|
||||
(D-031). Then finish this doc + D-033, pull, read servo-removal.md, `plan-generate` → `Plans/08 WebKit engine/` (S044+).
|
||||
|
|
|
|||
Loading…
Reference in a new issue