docs/design/gpui-spikes.md: the three GPUI spikes measured, go for all three
Plan section 6 step 1's report: the setup (Xvfb :91 with openbox, Mesa lavapipe through wgpu's Vulkan backend, gpui-kit 0.8.0, Rust 1.95.0, the load of each run), and per spike the figures and checks with a go/no-go against the plan's criteria: - video: img() with the port of video.rs' delivery holds 42 to 49 fps at 1440p60 and 55 to 58 at 1080p60 on the software device, the static control 60 to 62; drop_image keeps the atlas flat (without it +1.9 GiB in 10 s); a new 1440p picture costs GPUI's thread 6 to 7 ms (a new atlas texture and two copies); a persistent texture needs a GPUI change; the Slint demo stream compared on the same display at its 720p30; - composer, IME, chat lines: all checks pass, X11 preedit with fcitx5 and Pinyin works, Wayland preedit not exercised headless; colour emoji in U+1F600-U+1F640 need a one-line GPUI patch (tried in a scratch build); InteractiveText loses clicks shorter than a frame; - second window: shared root entity, focus, fullscreen, close and the X11 global hotkey all pass; the shared preview's cost. Settled for step 3: gpui-kit =0.8.0 (0.8.1 noted), Rust 1.95 (the 1.94 error), ashpd on async-io, the wgpu renderer (not blade) on X11 and Wayland, Inter and Lucide, the theme tokens against gpui-component's, the first slice, the plan's risks restated, the open choices, and what this attempt changed in the interrupted one's work. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b6f8f16108
commit
3167817b89
6 files changed
+556
No files matched your search
@@ -0,0 +1,556 @@
|
||||
# GPUI spikes: go/no-go for the Slint to GPUI migration
|
||||
|
||||
Plan section 6, step 1 ("Spikes first"): three spikes on the pinned
|
||||
`gpui-kit`, each a crate of the separate workspace `spikes/gpui/` (its own
|
||||
lock; not a member of the root workspace, nothing wired into `voelin-ui`).
|
||||
How to rebuild and rerun everything: [spikes/gpui/README.md](../../spikes/gpui/README.md).
|
||||
|
||||
**Status (2026-10-27).** Step 1 is done: all three spikes are a **go**,
|
||||
with the conditions under "Settled for step 3". The work was started on
|
||||
2026-10-25 by an attempt that was interrupted before it committed anything
|
||||
or measured the video cases; its code was judged and kept (with the changes
|
||||
listed in "History"), and every figure and check below was run again on
|
||||
2026-10-27.
|
||||
|
||||
| Spike | The plan's no-go | Seen (software rendering, see Setup) | Verdict |
|
||||
|---|---|---|---|
|
||||
| 1. Video | below 30 fps at 1440p60 with no custom-element way out | `img()` with the port of `video.rs`' delivery: 42 to 49 fps at 1440p60, 55 to 58 at 1080p60, on lavapipe; `cx.drop_image` keeps the atlas flat; a new 1440p picture costs GPUI's thread 6 to 7 ms; a persistent texture needs a GPUI change | **go**, with a GPU run first in the viewer slice |
|
||||
| 2. Composer, IME, chat lines | no usable preedit | X11 preedit with fcitx5 and Pinyin works (marked text, candidate window at the caret, commit); emoji at the caret, paste, Ctrl+Enter, `TextRun`s as `StyledText` with links all work; Wayland preedit not exercised headless; colour emoji need a one-line GPUI patch | **go** |
|
||||
| 3. Second window | the second window cannot share state or steal the hotkey | one root entity in two windows, both change it, focus, fullscreen and close work, the X11 global hotkey reaches the model while the second window has focus, the preview is one shared `RenderImage` (+46 % of a core on lavapipe for the second window) | **go** |
|
||||
|
||||
Before step 3 can start: Rust 1.95 for the client (no `gpui-kit` builds on
|
||||
1.94) and the client's ashpd on `async-io` (GPUI's and the client's ashpd
|
||||
features cannot be built together); both are under "Settled for step 3".
|
||||
|
||||
## Setup
|
||||
|
||||
Every figure on this page comes from one machine and one software stack:
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| Machine | AMD Ryzen 9 7950X3D (16 cores, 32 threads), 61 GiB, NixOS; no GPU was used |
|
||||
| Display | Xvfb `:91`, 3840x2160x24, openbox, a private D-Bus bus (`spikes/gpui/headless.sh`); the Wayland runs on sway's headless backend with its pixman renderer (`headless-wayland.sh`) |
|
||||
| Device | Mesa 26.2.5 lavapipe (`llvmpipe (LLVM 21.1.8, 256 bits)`) through wgpu's Vulkan backend, the only Vulkan driver (`VK_DRIVER_FILES` = its `lvp_icd.x86_64.json`); GPUI's log: "Selected GPU adapter: llvmpipe … (Vulkan)" |
|
||||
| GPUI | `gpui-kit` 0.8.0 (`gpui-pre` 0.3.9, `gpui-component` 0.8.0, `gpui-kit-assets` 0.8.0) |
|
||||
| Rust | 1.95.0 (fenix, `spikes/gpui/shell.sh`); nixpkgs 02c087f3fe67 for the libraries and tools |
|
||||
| Load | another task's load generator kept the machine busy for part of the day; every run records the load average before and after it (`<case>.load`), and the tables give it |
|
||||
|
||||
A software Vulkan device renders on the CPU: the `llvmpipe` threads in the
|
||||
tables below are what a GPU takes over. What it does not take over is said
|
||||
per spike.
|
||||
|
||||
## Spike 1: the video path
|
||||
|
||||
`spikes/gpui/video` ([README](../../spikes/gpui/video/README.md)) ports
|
||||
`video.rs`' delivery (video.rs:360-480: `deliver`, `FrameSlot`, `Handoff`,
|
||||
`Buffers`, `Latest`) to GPUI: the decoder hands over its newest frame only, a
|
||||
converter thread turns it into an `Arc<RenderImage>` (BGRA,
|
||||
`spike_common::bgra::to_bgra`, the BGRA twin of `convert::to_rgba`), the
|
||||
window takes the newest from the `Latest` in `render`, shows it with
|
||||
`img()` and drops the one it replaces from every window's atlas
|
||||
(`cx.drop_image`). `--mode pipeline` is `Video::demo`'s source
|
||||
(`LocalPreview` with `SourceId::Synthetic`, the real VP8 encoder and
|
||||
decoder, in the same process); `--mode raw` hands I420 frames from memory to
|
||||
the converter at 60 fps, so what is lost is GPUI's; `--mode static` is the
|
||||
control: one picture uploaded once, the window repainted every frame.
|
||||
`Buffers`' reuse cannot be ported: a `RenderImage` owns its pixels and
|
||||
gives no way back to them, so every picture is a new buffer.
|
||||
|
||||
**Conversion** (`--bench`, one thread, 300 runs; I420 to 32-bit, ms):
|
||||
|
||||
| | RGBA, reused buffer | BGRA, reused buffer | BGRA, new buffer | BGRA, new buffer as `RenderImage` |
|
||||
|---|---|---|---|---|
|
||||
| 1920x1080 | 0.34 | 0.27 | 0.38 | 0.49 |
|
||||
| 2560x1440 | 0.67 | 0.53 | 0.71 | 0.72 |
|
||||
|
||||
BGRA costs what RGBA costs (the same `yuv` routines with the channels
|
||||
swapped; a test checks they agree pixel for pixel). In the running
|
||||
converter a 1440p picture takes 2.0 ms, not 0.7: a new 14 MiB buffer each
|
||||
time is fresh memory, page faults included, which the reuse `video.rs`
|
||||
does today avoids. That is the price of `RenderImage`, on a thread of its
|
||||
own.
|
||||
|
||||
**In the window** (Xvfb `:91`, lavapipe; 70 s per case, the first 10 not
|
||||
counted; the load average before and after each case; "main" is GPUI's
|
||||
thread):
|
||||
|
||||
| Case | Shown fps (of 60) | CPU, process | llvmpipe | main thread | converter | Memory over 60 s | Load |
|
||||
|---|---|---|---|---|---|---|---|
|
||||
| static 1920x1080 | 60.2 (repaints) | 405 % | 391 % | 5.4 % | — | flat (199 MiB) | 40 / 35 |
|
||||
| static 2560x1440 | 62.0 (repaints) | 727 % | 710 % | 5.0 % | — | flat (230 MiB) | 35 / 28 |
|
||||
| raw 1920x1080 | **54.6** | 374 % | 345 % | 15.5 % | 6.8 % | flat (361 MiB) | 28 / 34 |
|
||||
| raw 2560x1440 | **41.9** | 525 % | 477 % | 28.0 % | 11.5 % | within one picture (486 to 501 MiB) | 34 / 34 |
|
||||
| raw 2560x1440, earlier run | 49.0 | 642 % | 577 % | 39.0 % | 15.1 % | within one picture | 43 / 44 |
|
||||
| raw 1920x1080, earlier run | 57.6 | 410 % | 376 % | 18.1 % | 7.8 % | flat | 43 / 43 |
|
||||
| pipeline 1920x1080 (encoded 26.3 fps) | 22.9 | 1085 % | 135 % | 7.1 % | 2.4 % | flat | 34 / 43 |
|
||||
| pipeline 2560x1440 (encoded 10.8 fps) | 9.6 | 1131 % | 102 % | 9.9 % | 1.9 % | flat | 43 / 53 |
|
||||
| pipeline 2560x1440, voelin-media's RGBA (encoded 13.3) | 12.5 | 1259 % | 131 % | 12.9 % | 2.2 % | flat | 53 / 61 |
|
||||
| **no `drop_image`**, pipeline 2560x1440 at 15 fps, 12 s | 13.9 | 1219 % | 146 % | 17.8 % | 2.3 % | **+1.9 GiB in 10 s** (827 to 2,816 MiB) | 61 / 45 |
|
||||
| pipeline 1280x720 at 30 fps, 4.6 Mbit/s (`Video::demo`'s settings) | 28.5 (of 29.6 decoded) | 317 % | 79 % | 6.0 % | 1.2 % | flat (253 MiB) | 45 / 36 |
|
||||
| **Slint**, `VOELIN_DEMO_STREAM=1` (the same 720p30 pipeline), 1440x960 window | window redrawn 58 to 61 times a second (`SLINT_DEBUG_PERFORMANCE`), X damage 59.9/s | 253 % | — | 6.6 % | 0.9 % | flat (151 MiB) | 36 / 28 |
|
||||
|
||||
The X server counted as many content changes of the window (XDamage, from
|
||||
outside the process) as the spike counted frames shown, within 0.3 fps, in
|
||||
every case but the `--no-drop` one.
|
||||
|
||||
What the figures say:
|
||||
|
||||
- **`img()` holds 1440p60 above the plan's 30 fps on a software device**
|
||||
(42 and 49 fps in two runs, 55 and 58 at 1080p), with GPUI's thread a
|
||||
quarter to a third busy. The static control repaints the same window at
|
||||
60 to 62 fps, so what the raw cases lose is the cost of a new picture per
|
||||
frame, not of drawing the window.
|
||||
- **The cost of a new picture on GPUI's thread:** main-thread CPU per frame
|
||||
goes from 0.8-0.9 ms (static) to 2.8-3.1 ms at 1080p and 6.7-8.0 ms at
|
||||
1440p (raw), so a new 1440p picture costs GPUI's thread 6 to 7 ms. In
|
||||
gpui-pre 0.3.9 that is: `paint_image` misses the atlas; a 2560x1440 image
|
||||
is larger than an atlas page (1024x1024), so `push_texture` creates a
|
||||
texture for it (`device.create_texture`), `upload_texture` copies the
|
||||
bytes (`bytes.to_vec()`, 14 MiB) and `write_texture` copies them again
|
||||
into wgpu's staging memory; `drop_image` on the next frame frees the
|
||||
texture (it has no other tile) and the next picture creates one again.
|
||||
- **`drop_image` keeps the atlas flat:** 60 s at 1440p60 stay within one
|
||||
picture's size (14 MiB) of where they started; without it every picture
|
||||
stays in the atlas (lavapipe's textures are process memory: +1.9 GiB in
|
||||
10 s at 15 fps, 11.6 GiB a minute).
|
||||
- **The pipeline cases are bound by the encoder**, not by GPUI: the
|
||||
synthetic sender's VP8 encoder runs in the same process and kept up with
|
||||
26 fps at 1080p and 11 at 1440p at this load (9 to 11 cores busy), and
|
||||
the window showed nearly every frame decoded. In the client, the encoder
|
||||
runs on the streamer's machine.
|
||||
- **Against Slint, same machine and display** (the only rate the demo
|
||||
stream offers is `StreamerConfig::default()`'s 1280x720 at 30 fps; Slint
|
||||
at 1440p60 would need a change in `voelin-ui`, out of this task's scope):
|
||||
both show the stream at the rate it is decoded (GPUI counted 28.5 of
|
||||
29.6; Slint's converter thread does the same work, 0.9 % against 1.2 %).
|
||||
Slint's software renderer draws on the app's main thread (6.6 %, the
|
||||
whole process 253 % with the encoder's 238 %); GPUI draws the window
|
||||
through Vulkan, which on lavapipe is 79 % of a core that a GPU takes
|
||||
over. The plan's
|
||||
"35-49 fps at 1440p60" is not a Slint figure: it is the decode rate of a
|
||||
4-core VM with FFmpeg's VP8 on slice threads
|
||||
(`docs/research/stream-fps.md`), since fixed in the decoder.
|
||||
|
||||
**What a real GPU changes.** The `llvmpipe` column (100 % to 710 %) moves to
|
||||
the GPU, and so does the copy from wgpu's staging memory into the texture.
|
||||
What stays on the CPU is the converter thread (2 ms a 1440p picture) and
|
||||
on GPUI's thread the two copies of the picture and the texture's creation
|
||||
and destruction: the 6 to 7 ms measured here are their upper bound (on lavapipe
|
||||
the texture's memory is also the process's), which fits a 60 Hz frame
|
||||
(16.7 ms) at 1440p but leaves little at 4K (four times 1080p's bytes) or
|
||||
at 144 Hz. A GPU run is the first thing slice 6 (the stream viewer) does.
|
||||
|
||||
**A custom element with a persistent texture** is the way to take those
|
||||
copies out, and it is not available from outside GPUI on Linux:
|
||||
`Window::paint_surface` (a `CVPixelBuffer`) exists only on macOS and iOS,
|
||||
and the atlas (`PlatformAtlas`: `get_or_insert_with`, `remove`) has no way to
|
||||
write new pixels into a tile it keeps. A custom `Element` can only call
|
||||
`paint_image`, which is what `img()` does. What it costs: a change to
|
||||
gpui-pre-wgpu (an atlas entry updated in place with `write_texture`, about
|
||||
a hundred lines with the renderer's bookkeeping) carried as a
|
||||
`[patch.crates-io]` and offered upstream, plus its Windows and macOS
|
||||
counterparts. Since `img()` already holds 1440p60 above 30 fps on software
|
||||
rendering, it is an optimisation for 4K and high refresh rates, not a
|
||||
condition of the go.
|
||||
|
||||
**Go.** The video path works on `img()` with the port of today's delivery,
|
||||
above the plan's threshold at 1440p60 on a software device, with a flat
|
||||
atlas; the conditions are a GPU run in slice 6 and the per-picture cost
|
||||
above.
|
||||
|
||||
## Spike 2: composer, IME and chat lines
|
||||
|
||||
`spikes/gpui/composer` ([README](../../spikes/gpui/composer/README.md)): a
|
||||
chat view of sample messages made by `voelin-ui-vm` and a composer.
|
||||
|
||||

|
||||
|
||||
| Check (`drive.sh`, `ime.sh`) | Result |
|
||||
|---|---|
|
||||
| Multi-line input: gpui-component's `Textarea` (`TextareaState`, auto-grow 1 to 6 rows, placeholder) | works |
|
||||
| An emoji from the picker (the first 96 of `voelin_ui_vm::emoji::archive().category(0)`) goes in at the caret (`TextareaState::insert`): "ab", caret between, picker → "a😀b" | PASS |
|
||||
| Ctrl+Enter sends without a newline (bound to `Send` in the `Input` context after gpui-component's bindings, so its "secondary enter" newline does not come first) | PASS |
|
||||
| A picture on the clipboard (`image/png`) becomes an attachment (`Textarea::on_paste`, `ClipboardEntry::Image`) | PASS |
|
||||
| A file's path on the clipboard (text that is the absolute path of an existing file; `ExternalPaths` for file managers) becomes an attachment | PASS |
|
||||
| The message goes with both attachments | PASS |
|
||||
| A click on a masked link reaches the app with the URL and "masked" (asks first) | PASS |
|
||||
| X11 preedit with a CJK input method: fcitx5 5.1.23 + Pinyin as the XIM server (on-the-spot), "nihao" typed: the input shows "ni hao" as marked text, the candidate window opens under the caret, Space commits 你好, Ctrl+Enter sends it | PASS (3 checks) |
|
||||
| Wayland preedit (`zwp_text_input_v3`) with fcitx5 under headless sway | not exercised (below) |
|
||||
|
||||

|
||||
|
||||
**Chat lines.** `voelin_ui_vm::chat::line` turns BBCode into `TextBlock`s of
|
||||
`TextRun`s (`bridge.rs:195`); each block is one `StyledText` with one GPUI
|
||||
`TextRun` per `TextRun` (font, colour, background, underline, strike) inside
|
||||
`InteractiveText`, whose clickable ranges are the link runs. Bold, italic,
|
||||
underline, strike, code (the theme's monospace font on a background),
|
||||
author colours, quotes, code blocks, lists, bare and masked links, a refused
|
||||
`javascript:` link (plain text), CJK through the system's Noto Sans CJK, a
|
||||
ZWJ sequence (👩💻), a flag (🇫🇷) and jumbo emoji (one to three alone) all
|
||||
draw as the screenshot shows. The Twemoji archive is not needed for any of
|
||||
it: `TextRun.emoji` only says that a run is an emoji.
|
||||
|
||||
**Colour emoji: a gap, with a one-line fix.** With this desktop's font
|
||||
configuration, the smileys U+1F600 to U+1F640 (😀 😂 😍 🙀, among the most
|
||||
used emoji) draw in **monochrome**, the others (🙂 🎉 🙋 👩💻) in colour.
|
||||
The probe in `drive.sh` counts the glyphs GPUI draws in colour
|
||||
(`ShapedGlyph::is_emoji`) for three lines:
|
||||
|
||||
| Line (colour glyphs of the emoji in it) | Emoji runs in Noto Color Emoji | Inter and its fallback chain |
|
||||
|---|---|---|
|
||||
| `a😀b` (1 emoji), the system's fonts | 0 | 0 |
|
||||
| `😂🙀🙂🎉` (4), the system's fonts | 2 | 2 |
|
||||
| `👩💻` (1), the system's fonts | 1 | 1 |
|
||||
| the same three, only the Noto fonts (`FONTCONFIG_FILE`) | 1, 4, 1 | 1, 4, 1 |
|
||||
| the same three, the system's fonts, GPUI with the patch below | 1, 4, 1 | 1, 4, 1 |
|
||||
|
||||

|
||||

|
||||
|
||||
Three things in GPUI 0.3.9 and cosmic-text 0.19 add up to this:
|
||||
|
||||
1. A font is only a primary font if it has a glyph for `m`
|
||||
(`load_family` in gpui-pre-wgpu's `cosmic_text_system.rs`: "The editor
|
||||
measures layout with the width of 'm'"). Noto Color Emoji has none, so a
|
||||
run whose font is Noto Color Emoji is drawn in GPUI's fallback stack, and
|
||||
a `FontFallbacks` chain that names it silently drops it.
|
||||
2. Colour emoji therefore come only from cosmic-text's own fallback list,
|
||||
which on Unix tries "Noto Sans", **"DejaVu Sans"**, … and "Noto Color
|
||||
Emoji" last (`common_fallback` in cosmic-text's `font/fallback/unix.rs`).
|
||||
DejaVu Sans has U+1F600 to U+1F640 in monochrome, and nearly every Linux
|
||||
desktop has DejaVu Sans.
|
||||
3. A glyph is drawn in colour only from a font whose PostScript name is
|
||||
`NotoColorEmoji` (`check_is_known_emoji_font`, "TODO: Include other
|
||||
common emoji fonts"): by the code, Twemoji or JoyPixels installed as the
|
||||
system's emoji font would draw in monochrome (not tried).
|
||||
|
||||
The fix is one line in `load_family` (gpui-pre-wgpu 0.3.9), letting the
|
||||
known emoji font through the `m` test, after which both a run in Noto
|
||||
Color Emoji and the fallback chain draw every emoji in colour (last row of
|
||||
the table; the composer's other checks pass with it):
|
||||
|
||||
```diff
|
||||
if font.as_swash().charmap().map('m') == 0
|
||||
&& !allowed_bad_font_names.contains(&postscript_name.as_str())
|
||||
+ && !check_is_known_emoji_font(&postscript_name)
|
||||
{
|
||||
continue;
|
||||
};
|
||||
```
|
||||
|
||||
Step 3 carries it as a `[patch.crates-io]` of `gpui-pre-wgpu` (and sends
|
||||
it upstream) before the chat slice, and bundles Noto Color Emoji (OFL,
|
||||
10.7 MB) so the one font GPUI draws in colour is always there. The spikes'
|
||||
committed code runs on stock GPUI; the patched run was a scratch build.
|
||||
|
||||
**Links: a click shorter than a frame is lost.** `InteractiveText` installs
|
||||
its mouse-up listener in the frame painted after the mouse-down
|
||||
(`elements/text.rs`), so a press and release that both arrive before the
|
||||
next frame never click (the interrupted attempt lost xdotool's plain
|
||||
click this way; `drive.sh` holds the button 120 ms). A touchpad tap can be
|
||||
that short. Step 3 draws links as elements with `on_click` or fixes the
|
||||
listener upstream.
|
||||
|
||||
**IME.** GPUI owns the preedit: its X11 backend is an XIM client (on-the-spot,
|
||||
the preedit drawn in the input as marked text, the candidate window placed at
|
||||
the caret from the input handler's bounds) and its Wayland backend speaks
|
||||
`zwp_text_input_v3` (preedit string, commit string, the cursor rectangle);
|
||||
gpui-component's inputs draw the marked range. The app does nothing for it.
|
||||
On Wayland the preedit could not be exercised headless: under sway's
|
||||
headless backend with fcitx5 5.1.23's Wayland frontend (input-method-v2)
|
||||
and wtype's virtual keyboard, GPUI enabled its text input and sent the
|
||||
cursor rectangle once sway sent `zwp_text_input_v3.enter` (only after the
|
||||
seat's focus moved away and back: sway sent none for a text input made
|
||||
while the window already had focus), but the virtual keyboard's keys went
|
||||
to the app as plain keys, not through fcitx5's keyboard grab, so no
|
||||
preedit came (the script stayed in the scratch directory). It needs a real
|
||||
session (a physical keyboard) on KDE, GNOME or sway.
|
||||
|
||||
**Go.** Every composer and message behaviour the plan asks for works with
|
||||
gpui-component as it is; usable preedit is shown on X11 with a real CJK
|
||||
input method. The emoji gap and the short-click gap are risks with known
|
||||
fixes, not no-gos.
|
||||
|
||||
## Spike 3: the second window
|
||||
|
||||
`spikes/gpui/windows` ([README](../../spikes/gpui/windows/README.md)): a
|
||||
main window and a Studio-like window opened with `cx.open_window`
|
||||
(`gpui_kit::open_window`, which wraps the view in gpui-component's `Root`),
|
||||
both rendering views that `cx.observe` one root entity `Shared`.
|
||||
|
||||

|
||||
|
||||
| Check (`drive.sh`) | Result |
|
||||
|---|---|
|
||||
| Ctrl+O in the main window opens the studio's window | PASS |
|
||||
| Ctrl+K twice in the studio window: the shared counter is 2 in both windows | PASS |
|
||||
| The global push-to-talk key (F8, `voelin_platform::hotkey::HotkeyManager::x11`: XInput2 raw events on the root window) held while the studio window has focus reaches the shared model (TALKING in both windows) | PASS |
|
||||
| … and its release | PASS |
|
||||
| F11: the studio window fullscreen (3840x2160) and back | PASS |
|
||||
| … with its own size back (1000x900) | PASS |
|
||||
| Ctrl+Tab in the studio window: GPUI activates the main window (`Window::activate_window`) | PASS |
|
||||
| Ctrl+K in the main window: the same counter, 3 | PASS |
|
||||
| Alt+F4 on the studio window (the window manager asks it to close): `on_window_should_close` docks the studio, the app goes on | PASS |
|
||||
| The hotkey with the main window active and no studio window | PASS |
|
||||
| Alt+F4 on the main window ends the app (in 0.1 s) | PASS |
|
||||
|
||||
Keys in either window go through GPUI's action dispatch to the window's
|
||||
focused view and from there to the shared entity; the hotkey's events (a
|
||||
tokio `UnboundedReceiver`) are read by a GPUI foreground task, which needs
|
||||
no tokio reactor, and update the same entity. Neither window can tell where
|
||||
a change came from, which is what the Studio window of `voelin-ui` needs.
|
||||
|
||||
**The preview.** GPUI cannot read a window's pixels (no `take_snapshot`),
|
||||
so the studio's picture comes from where it comes from today: the engine's
|
||||
compositor (`voelin_media::studio::Studio`, one scene of the test pattern,
|
||||
1920x1080 at 30 fps) and its preview tap at the studio's default 960x540,
|
||||
15 fps (RGBA). A thread converts each preview frame into one BGRA
|
||||
`RenderImage`; the shared entity holds the newest, both windows show the
|
||||
same `Arc` with `img()`, and the one it replaces leaves every window's atlas
|
||||
(`cx.drop_image(old, None)`). What it costs (`windows/measure.sh`, 45 s,
|
||||
10 s of warm-up):
|
||||
|
||||
| Case | CPU, process | llvmpipe | main thread | compositor (engine) | preview conversion | Memory | Load |
|
||||
|---|---|---|---|---|---|---|---|
|
||||
| main window with the preview | 100 % | 52 % | 3.4 % | 43 % (`voelin-compose` 25 %, scaling, the test pattern) | 0.6 % (15 pictures a second) | 278 MiB, flat | 28 / 17 |
|
||||
| both windows with the preview | 147 % | 97 % | 6.9 % | 39 % | 0.7 % | 304 MiB, flat | 17 / 26 |
|
||||
| both windows, no compositor | 0.5 % | — | 0.1 % | — | — | 218 MiB, flat | 26 / 40 |
|
||||
|
||||
The second window showing the same picture costs about 46 % of a core
|
||||
here, nearly all of it lavapipe drawing a second 1000x900 window 15 times a
|
||||
second (a GPU's work), and 26 MiB; the picture is converted once (0.7 %)
|
||||
and shared by `Arc`, and dropping the replaced one from every window keeps
|
||||
memory flat. GPUI draws nothing while nothing changes (0.5 % with both
|
||||
windows open and no preview).
|
||||
|
||||
**Go.** Both windows share state, both change it, focus moves either way,
|
||||
fullscreen and close behave, and the global hotkey reaches the shared model
|
||||
while the second window has focus (on X11; on Wayland the hotkey is the
|
||||
portal's, see "Dependencies").
|
||||
|
||||
## Settled for step 3
|
||||
|
||||
### The version to pin
|
||||
|
||||
**`gpui-kit` 0.8.0, exactly**, the version measured here (gpui-pre 0.3.9).
|
||||
0.8.1 (gpui-pre 0.3.10) came out on 2026-10-26, after these spikes were
|
||||
built; step 3's first commit moves to the newest release only after
|
||||
building the three spikes on it (`cargo update -p gpui-kit --precise` in
|
||||
`spikes/gpui`, then the READMEs' runs). A pre-1.0 release may change any
|
||||
API (the pin is exact for that reason, and `gpui-kit` pins its `gpui-pre`
|
||||
exactly too); upgrades are commits of their own.
|
||||
|
||||
**Rust 1.95 or newer.** No `gpui-kit` release builds on the client's Rust
|
||||
1.94: every `gpui-pre` 0.3.x (0.3.0 to 0.3.10, which every `gpui-kit` from
|
||||
0.6.0 to 0.8.1 pins) calls `std::hint::cold_path`, stable since 1.95.0:
|
||||
|
||||
```text
|
||||
$ TOOLCHAIN=1.94 spikes/gpui/shell.sh sh -c 'cd spikes/gpui && cargo check --locked --ignore-rust-version'
|
||||
error[E0658]: use of unstable library feature `cold_path`
|
||||
--> …/gpui-pre-0.3.9/src/profiler.rs:473:13
|
||||
error[E0658]: use of unstable library feature `cold_path`
|
||||
--> …/gpui-pre-0.3.9/src/profiler.rs:494:13
|
||||
error: could not compile `gpui-pre` (lib) due to 2 previous errors
|
||||
```
|
||||
|
||||
(without `--ignore-rust-version` cargo stops before that: the workspace says
|
||||
`rust-version = "1.95"`).
|
||||
|
||||
So step 3 starts by moving `rust-toolchain.toml` to 1.95 (or the stable of
|
||||
the day) in the root workspace, a change of its own with the usual checks.
|
||||
The spikes build and pass clippy on 1.95.0 and on nightly 2026-10-24.
|
||||
|
||||
### Dependencies
|
||||
|
||||
- **ashpd.** GPUI's Linux backend enables ashpd's `async-io` feature; the
|
||||
client's `voelin-media` (`pipewire`: the screen-cast and camera portals)
|
||||
and `voelin-platform` (`portal`: global shortcuts, file chooser, proxy
|
||||
resolver) enable `tokio`, and ashpd refuses both at once
|
||||
(`compile_error!` in ashpd 0.13.13). The spikes leave both features out
|
||||
(X11 capture and hotkeys only). **Step 3 must move the client's ashpd use
|
||||
to `async-io`** before `voelin-ui` can depend on gpui-kit with PipeWire
|
||||
capture and the portal hotkey; zbus with `async-io` runs its own I/O
|
||||
thread, so it does not need GPUI's executor.
|
||||
- **Size and compile time.** The spikes' lock has 1,069 packages; the
|
||||
release binaries are 390 to 480 MB with line tables. A full debug build
|
||||
of the workspace with a toolchain it had not built with before (nightly)
|
||||
took 3 min 14 s on the 32 threads at a load average around 90.
|
||||
|
||||
### The Linux renderer
|
||||
|
||||
The plan says "blade: Vulkan"; gpui-pre 0.3.9 renders through **wgpu**
|
||||
(`gpui-pre-wgpu`), which finds Vulkan and GL adapters and takes the first
|
||||
that passes its configuration test (here: llvmpipe on Vulkan; GL was found
|
||||
too). Both backends are a **go on this machine's software device**: X11
|
||||
(Xvfb with openbox) for every measurement; Wayland (sway's headless
|
||||
backend, its pixman renderer, a 2560x1440 output) opens the window, draws
|
||||
it, takes keys (the composer through a virtual keyboard) and enables its
|
||||
text input. Its frame rate there was low: spike 1's static and raw 1440p
|
||||
cases showed 15.3 and 13.1 fps at a load average rising from 40 to 148,
|
||||
where X11 showed 62 and 42 to 49; a rerun with the compositor's own CPU
|
||||
measured beside it (to tell sway's pixman compositing at 2560x1440 from
|
||||
GPUI's Wayland path) did not find a quiet machine in time, so the Wayland
|
||||
frame rate stays an open point for step 3, to be measured on a real
|
||||
session. What it needs:
|
||||
|
||||
- **On a real GPU:** a Vulkan driver (Mesa RADV, ANV or NVK, NVIDIA's) or
|
||||
GL as wgpu's fallback; nothing else in the app changes. The rasterising
|
||||
the tables charge to `llvmpipe` moves to the GPU; the per-frame upload of
|
||||
a new picture (spike 1) stays on the CPU's side as two copies of the
|
||||
picture.
|
||||
- **Software only** (a VM, a remote desktop): lavapipe works and is what
|
||||
these figures measure. A 2560x1440 window repaints at 60 fps with
|
||||
nothing new to upload and at 42 to 49 with a new picture every frame, on
|
||||
5 to 7 of this CPU's cores; the UI around it costs little (spike 3's
|
||||
windows, 1000x900 and 1200x900, cost half a core each at 15 frames a
|
||||
second).
|
||||
- X11 needs a window manager for fullscreen, activation and close requests
|
||||
(openbox here); GPUI asks for XInput 2.4 and logs "Found no xinput mouse
|
||||
pointers" on Xvfb, harmlessly. On Wayland, GPUI needs a seat (weston's
|
||||
headless backend has none, so `headless-wayland.sh` uses sway).
|
||||
|
||||
### Inter and Lucide
|
||||
|
||||
- **Inter**: the five TTFs the client bundles (`crates/voelin-ui/ui/assets/fonts`)
|
||||
go in with `cx.text_system().add_fonts` (`spike_common::fonts`) and are
|
||||
used by family name; the screenshots are Inter. Nothing depends on what
|
||||
fontconfig finds for Latin text.
|
||||
- **Lucide through `svg()`**: an `AssetSource` serves the client's own 147
|
||||
Lucide 1.48 SVGs (`voelin/<name>.svg`, read from
|
||||
`crates/voelin-ui/ui/assets/icons`) before gpui-kit-assets' Lucide 1.43
|
||||
catalog (`icons/<name>.svg`, what gpui-component's `Icon` uses); `svg()`
|
||||
draws them as masks tinted with `text_color` (the composer's emoji and
|
||||
send buttons). Two Lucide versions side by side is the one thing to
|
||||
settle: step 3 serves the client's set under gpui-component's paths
|
||||
(`icons/`) so both draw the same icons.
|
||||
|
||||
### The theme against "Theme tokens"
|
||||
|
||||
gpui-component's theme (`Theme`, `ThemeColor`: about 135 colours; JSON
|
||||
themes through `ThemeRegistry`, light and dark) is shadcn's vocabulary;
|
||||
gpui-base 0.8 adds code-level tokens (radius none/sm/md/lg/xl/full, spacing
|
||||
xxs to xxl, type xs to xl and mono, shadows, motion 120/180/280 ms). The
|
||||
client's tokens (docs/ui.md, "Theme tokens") map like this:
|
||||
|
||||
| `ui/theme.slint` | gpui-component | |
|
||||
|---|---|---|
|
||||
| `mode`, `dark` | `ThemeMode`, `Theme::change`, the registry's light and dark themes | "system" follows the window appearance |
|
||||
| `font-scale` | `font_size` (one base size) | the eight type sizes scale in the client's code |
|
||||
| `bg-app` | `background` | |
|
||||
| `backdrop` (gradient) | a gradient token (0.8's `ThemeToken` parses `linear-gradient`) | |
|
||||
| `bg-rail`, `surface` | `sidebar.background`, `title_bar.background` | |
|
||||
| `surface-2` (cards, inputs) | `secondary.background`, `group_box.background` | |
|
||||
| `surface-3` (hover, menus) | `accent.background`, `list.hover.background`, `popover.background` | gpui-component's "accent" is a **hover background**, not the brand colour |
|
||||
| `surface-4` (pressed) | `secondary.active.background` | |
|
||||
| `scrim`, `scrim-light`, `overlay` | `overlay` | one value for three |
|
||||
| `border`, `border-strong`, `border-popup` | `border`, `input.border`, — | |
|
||||
| `glow`, `glow-width` | `ring` | no width |
|
||||
| `accent`, `accent-hover`, `accent-pressed`, `on-accent` | `primary.background`, `primary.hover.background`, `primary.active.background`, `primary.foreground` | |
|
||||
| `accent-soft` (selected rows), `accent-soft-hover` | `list.active.background`, `table.active.background`; — | |
|
||||
| `accent-text` (links), `name-text` | `link.foreground` (and hover, active); — | |
|
||||
| `danger`, `success`, `warning`, `info` | `danger.background`, `success.background`, `warning.background`, `info.background` (with hover, active, foreground) | |
|
||||
| `*-soft`, `live`, `live-soft`, `idle`, `dnd`, `offline`, `gold`, `meter-*` | — (`base.red` … `base.cyan` and their light variants are a palette, not roles) | |
|
||||
| `text`, `text-muted` | `foreground`, `muted.foreground` | |
|
||||
| `text-secondary`, `text-disabled`, `icon` | — | |
|
||||
| `radius-xs` … `radius-pill` | `radius` (6), `radius.lg`; gpui-base's radius tokens | five steps against two in JSON |
|
||||
| `space-1` … `space-8` | gpui-base's spacing tokens (code, not JSON) | |
|
||||
| `font-xs` … `font-3xl`, weights | gpui-base's type tokens (code) | |
|
||||
| sizes (`control-height` 36, `row-height`, `rail-width`, …) | — (gpui-component sizes its controls itself: `Size::Small/Medium/Large`) | |
|
||||
| `fast` 120 ms, `normal` 200 ms | motion tokens 120/180 ms | |
|
||||
|
||||
So the theme is two layers: a `VoelinTheme` global with every token of
|
||||
`theme.slint` (the source of truth, light and dark), and on each change the
|
||||
colours gpui-component's widgets read written into its `ThemeColor` (about
|
||||
40 of the 135), so its inputs, lists, menus and dialogs look like ours. A
|
||||
gpui-component JSON theme file alone cannot carry the presence, live, meter
|
||||
and size tokens.
|
||||
|
||||
### What step 3's first slice (the desktop shell) must contain
|
||||
|
||||
1. The toolchain move to 1.95 and ashpd on `async-io` (above), each its own
|
||||
commit with the root workspace's checks.
|
||||
2. The GPUI front end's crate (its name to choose; the plan keeps both UIs
|
||||
as two `[[bin]]`s on the same `HostedEngine` until parity), with
|
||||
`gpui-kit = "=0.8.0"` or the version the spikes were rebuilt on, and the
|
||||
deny and notices updates for its ~1,000 packages.
|
||||
3. The root entity `Entity<AppState>`, the engine's events through a GPUI
|
||||
foreground task (spike 3's hotkey task is the pattern), the 1 s tick as
|
||||
a `background_executor().timer` loop.
|
||||
4. `VoelinTheme` with the two layers above, Inter via `add_fonts`, the
|
||||
client's Lucide set as gpui-component's `icons/`.
|
||||
5. The shell itself (slice 1 of the plan: ≈13 properties and 11 callbacks of
|
||||
`bind/servers.rs`): the server rail, the sidebar, the top bar, empty
|
||||
main area, window state, with screenshots made the `docs/ui.md` way
|
||||
(`headless.sh` here is the GPUI equivalent of its xvfb recipe).
|
||||
6. A meter like `spike_common::meter` (CPU by thread group, memory, the
|
||||
app's own counters, once a second) as a development switch, so every
|
||||
later slice can say what it costs.
|
||||
|
||||
Not in it: video (slice 6) needs the decision of spike 1's "What a real GPU
|
||||
changes"; emoji need the patch above before the chat slice (4).
|
||||
|
||||
### The risks of plan section 6, against what was seen
|
||||
|
||||
| Risk (plan) | Seen |
|
||||
|---|---|
|
||||
| Pre-1.0 API churn | Real: 0.8.1 came a week after 0.8.0; `gpui-pre` pins move in lockstep. Pin exactly, upgrade in commits of their own, rebuild the spikes first. |
|
||||
| Wayland IME, fractional scaling | X11 preedit works; Wayland's text-input-v3 is implemented by GPUI (enable, cursor rectangle, preedit and commit strings) but was not exercised end to end headless: a check on a real session is part of the chat slice. Fractional scaling not exercised (Xvfb at scale 1, `GPUI_X11_SCALE_FACTOR=1`). |
|
||||
| Accessibility weaker than Slint's | GPUI talks to AT-SPI (`accesskit_unix`, `atspi` in the tree; "org.a11y.Bus" looked for at start); not exercised. |
|
||||
| Compile time | 1,069 packages; a full debug build 3 min 14 s on 32 threads under load. |
|
||||
| New: colour emoji | GPUI draws U+1F600 to U+1F640 from DejaVu Sans in monochrome on most desktops; one-line patch above. |
|
||||
| New: ashpd features | GPUI and the client's portals cannot share a binary until the client uses `async-io`. |
|
||||
| New: short clicks on links | `InteractiveText` loses a click shorter than a frame. |
|
||||
| New: video upload cost | Every new picture is a new atlas texture plus two copies (spike 1); a persistent texture needs a GPUI change. |
|
||||
| New: Rust 1.95 | gpui-kit needs it; the client is on 1.94. |
|
||||
|
||||
### Open choices for step 3
|
||||
|
||||
- Video: `img()` as measured here, or the persistent-texture change to
|
||||
gpui-pre-wgpu. The GPU run of the viewer slice decides; the cases that
|
||||
could need it are 4K, high refresh rates and several streams on screen at
|
||||
once (the per-picture cost on GPUI's thread adds up per stream: four
|
||||
1080p60 tiles would be about 8 ms of every frame on this path).
|
||||
- Emoji: carry the one-line GPUI patch (`[patch.crates-io]` of
|
||||
`gpui-pre-wgpu`) and send it upstream, or bundle Noto Color Emoji and a
|
||||
font configuration without DejaVu's emoji range (not possible from inside
|
||||
the app: cosmic-text reads the font database, not fontconfig's order).
|
||||
- Icons: the client's Lucide 1.48 set under gpui-component's paths, or
|
||||
gpui-kit-assets' 1.43 catalog with the client's additions.
|
||||
- Theme: which gpui-component colours the `VoelinTheme` writes (about 40)
|
||||
and whether its JSON format is offered to users at all.
|
||||
- Links: elements with `on_click` per link, or a fix of `InteractiveText`.
|
||||
|
||||
## History
|
||||
|
||||
An attempt of 2026-10-25 wrote the workspace, the three spikes, their
|
||||
scripts and READMEs, ran the composer, IME and windows scenarios and a few
|
||||
720p trial runs (at a load average of 100 to 157, so not used here), and
|
||||
was interrupted before it committed anything or measured the video cases.
|
||||
Its work was judged on 2026-10-27, kept, and committed in four pieces (the
|
||||
commit messages say what changed in each); the changes:
|
||||
|
||||
- `shell.sh` takes 1.94 and nightly from the pinned fenix (the store paths
|
||||
it named had been garbage-collected); the README's Wayland paragraph
|
||||
(sway, not weston), its `cargo fmt` command (`-p`, not `--all`, which
|
||||
takes in the client's crates) and its toolchain lines.
|
||||
- Spike 1: `--mode static` (the control: no new pictures) and its two cases
|
||||
in `measure.sh`.
|
||||
- Spike 2: one GPUI text run per `TextRun` instead of highlights (each run
|
||||
its font: emoji, monospace for code, which `font_family("monospace")` did
|
||||
not find); a sample of the smileys DejaVu Sans has; the emoji probe in
|
||||
place of a font probe that printed "?" for every fallback font.
|
||||
- Spike 3: the window's size after a fullscreen toggle logged and checked;
|
||||
how long the app takes to end; `windows/measure.sh` in place of README
|
||||
commands that wrote into the current directory.
|
||||
|
||||
Nothing was dropped. The 720p trial runs, the 2026-10-25 screenshots and
|
||||
the extracted `gpui-pre` crates the attempt used to look for `cold_path`
|
||||
stayed in the attempt's scratch directory.
|
||||
|
||||
Found while measuring, and fixed in two commits of their own: the headless
|
||||
scripts did not move `XDG_STATE_HOME`, so the Slint app's runs (on
|
||||
2026-10-25, and three on 2026-10-27) wrote their logs into the desktop's
|
||||
`~/.local/state/voelin/logs`, whose five rotated files are now all from
|
||||
these runs; and `headless-wayland.sh` left every headless sway running
|
||||
(nixpkgs' wrapper puts sway under a `dbus-run-session` of its own), which
|
||||
it now does not.
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 33 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 3.9 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 3.7 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.9 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 26 KiB |
Reference in new issue
Block a user