wl_shm: keep a buffer valid after its pool is destroyed
CI / test (push) Failing after 18s

Qt Quick apps (kwi) render through Mesa's software EGL path, which creates a pool,
creates one buffer and destroys the pool at once. We closed the fd and dropped the
pool, so every snapshot returned None and the window stayed blank. The pool now lives
until its last buffer is destroyed (re-keyed so recycled client ids can't collide).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
nandiandClaude Sonnet 5.5 committed 2026-11-25 00:24:33 -08:00
1 parent df1f37ee78
commit 82cac8a915
2 files changed
+75 -4

No files matched your search

+20
View File
@@ -223,6 +223,7 @@ fn commit_shm_frame(
surf_id : UInt,
xdg_surf_id : UInt,
win_id : UInt64,
destroy_pool? : Bool = false,
) -> Unit raise {
match c.configure_serial {
Some(ser) => {
@@ -277,6 +278,11 @@ fn commit_shm_frame(
w_buf.i32(stride)
w_buf.u32(0U)
c.send(w_buf.finish_msg(pool_id, 0U))
if destroy_pool {
// Mesa's software EGL path (Qt Quick apps like kwi) destroys the pool right away;
// the buffer must stay valid.
c.send(@wayland.WireWriter::new().finish_msg(pool_id, 1U))
}
// wl_surface.attach(buf, 0, 0) + damage_buffer + commit
let w_att = @wayland.WireWriter::new()
@@ -356,3 +362,17 @@ test "e2e pure-moonbit wayland compositor with lib/wm, ssd decorations, and shm
@sys.close_fd(c2.fd)
comp.close()
}
///|
test "a buffer stays valid after its wl_shm_pool is destroyed" {
let socket_path = "/tmp/wayland-moon-pooldestroy-" +
@sys.getpid().to_string() +
".sock"
let theme = @scene.ThemeTokens::moon_night()
let comp = @host.MoonPlasmaCompositor::new(socket_path, theme, 1280, 720).unwrap()
let (c, shm, surf, xdg, _tl, _deco) = open_and_configure_client(
comp, socket_path, "Kwi", "org.kde.kwi",
)
commit_shm_frame(comp, c, shm, surf, xdg, 1UL, destroy_pool=true)
assert_true(comp.windows.get(1UL).unwrap().surface is Some(_))
}