The debdiff I attached on 2026-11-12 can crash gnome-shell; please use mutter_46.2-1ubuntu0.24.04.19.debdiff, attached here, instead.
The first backported commit connects a notify::mapped handler to every surface actor of a window and never disconnects it. 46.2 keeps the surface actor when a client creates a new xdg_toplevel or xdg_popup on the same wl_surface (mutter 47 creates a new one, merge request 3667), so showing the new window runs the handler with the freed window actor of the destroyed one. With 46.2-1ubuntu0.24.04.18+local1 this crashed gnome-shell twice in one day, after Telegram Desktop and an Electron application had each created a new toplevel on an old wl_surface. The new debdiff adds upstream merge request 5347 (https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/5347, not merged yet), which disconnects the handler, and a test case that shows two toplevels one after the other on the same wl_surface. Run alone, the case fails in 9 of 10 runs without the fix, and with AddressSanitizer it reports a heap-use-after-free in is_surface_actor_mapped_changed(); with the fix it passes in all 10 runs and under AddressSanitizer. The package build gives the same test results as with the first debdiff, and so do the 66 checks in the headless shell. I built and tested this source as 46.2-1ubuntu0.24.04.18+local2; the debdiff differs from it only in the changelog entry and in the Bug-Ubuntu lines of the patch headers. The description now lists the two new patches. ** Description changed: [ Impact ] mutter 46.2 in Ubuntu 24.04 never gives the xdg_toplevel "suspended" state to a covered window that has a hidden subsurface, that is, a wl_subsurface without a buffer. The window stays active for as long as it is covered, so a client that stops drawing while it is suspended keeps drawing. mutter keeps a window active while any of its surface actors is not obscured: meta_window_actor_add_surface_actor() in src/compositor/meta- window-actor.c takes one suspend inhibitor for each surface actor that is not obscured, and update_suspend_state() in src/core/window.c keeps a window that is not hidden active while it holds an inhibitor. Whether a surface actor is obscured is decided by the culling pass before - painting, and that pass gives an actor that is not visible no unobscured - region, which counts as not obscured (cull_out_children_common() in - src/compositor/meta-cullable.c, set_unobscured_region() in - src/compositor/meta-surface-actor.c). The actor of a hidden subsurface - is not visible, so it holds an inhibitor for as long as it exists. + painting, and that pass clears the unobscured region of an actor that is + not visible, and an actor without an unobscured region counts as not + obscured (cull_out_children_common() in src/compositor/meta-cullable.c, + set_unobscured_region() in src/compositor/meta-surface-actor.c). The + actor of a hidden subsurface is not visible, so it holds an inhibitor + for as long as it exists. Google Chrome windows can have hidden subsurfaces; on the affected machine each Chrome window had two. When a tab is being captured, a covered Chrome window that is not suspended keeps drawing and requests a frame callback with every frame. mutter holds those callbacks while the window is covered and sends all of them when the window is shown again. At about 35 frames per second, in under four minutes the burst is larger than the send buffer of the Wayland socket, gnome-shell disconnects Chrome, and Chrome exits ("Fatal Wayland communication error"). The Chrome side of this is https://issues.chromium.org/issues/584386512. A Chrome window without hidden subsurfaces, which mutter 46.2 does suspend, stops committing frames 3 seconds after it is covered. [ Fix ] Upstream fixed this in mutter 49.rc with merge request 4588, https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4588: b3fad292b074ad573a73999fa89d55b73a8e0f32 window-actor: Track state affecting suspend inhibation explicitly 9c97332606dc61797deda5f0426524f6d9a956f6 window-actor: Handle visibility condition for suspending window 79a73f919c579f1a5b67402f306311048bd98126 tests/wayland/toplevel-suspend: Add test for suspending on screen shield With these, the window actor counts its mapped surface actors, its obscured surface actors and its mapped clones. The window counts as visible while one of its clones is mapped, or while the window actor itself is mapped and not every mapped surface actor is obscured. A hidden subsurface is not mapped, so it no longer keeps the window active. The merge request was written to suspend windows while the screen is locked and does not refer to an issue; I did not find an upstream issue or a Launchpad bug about the hidden subsurface case. Ubuntu 26.04 (mutter 50.1) and 26.10 (mutter 51.0) have the fix, and Ubuntu 22.04 (mutter 42.9) predates the suspended state, which mutter 45 introduced, so 24.04 is the supported release that needs it. The two window-actor commits apply to 46.2-1ubuntu0.24.04.18 with line offsets only. The test commit needed two adjustments for 46.2, which its patch header describes. The attached debdiff adds the three commits as - patches, and a fourth patch, not from upstream, with two cases for - hidden subsurfaces in the /wayland/toplevel/suspended test. + patches, a fourth patch, not from upstream, with two cases for hidden + subsurfaces in the /wayland/toplevel/suspended test, and two more + patches for a crash that the first commit causes on 46.2. + + The first commit connects a notify::mapped handler to every surface + actor of a window and never disconnects it. 46.2 keeps the surface actor + when a client creates a new xdg_toplevel or xdg_popup on the same + wl_surface, while mutter 47 creates a new one (merge request 3667, + https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3667), so on 46.2 + showing the new window runs the handler with the freed window actor of + the destroyed one. On the affected machine Telegram Desktop and an + Electron application did that with toplevels, and gnome-shell crashed + twice in one day. The fifth patch is merge request 5347, + https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/5347, which + disconnects the handler and is not merged yet. The sixth patch, not from + upstream, adds a case for this to the /wayland/toplevel/suspended test. [ Test Plan ] The attached suspend_client.c shows an opaque 480x320 window and prints every xdg_toplevel.configure it receives, with the time and whether the suspended state is set. With --hidden-subsurface it also creates a subsurface that never gets a buffer. To build it (packages libwayland- dev, wayland-protocols and libwayland-bin): wayland-scanner client-header /usr/share/wayland-protocols/stable/xdg-shell/xdg-shell.xml xdg-shell-client-protocol.h wayland-scanner private-code /usr/share/wayland-protocols/stable/xdg-shell/xdg-shell.xml xdg-shell-protocol.c gcc -o suspend_client suspend_client.c xdg-shell-protocol.c $(pkg-config --cflags --libs wayland-client) In a GNOME session on Wayland: 1. Run "./suspend_client plain" and "./suspend_client sub --hidden-subsurface". 2. Cover both windows completely with a fullscreen window, for example a browser after pressing F11, for 10 seconds, then leave fullscreen. 3. With the fix, both programs print a configure line with suspended=1 about 3 seconds after they are covered, and one with suspended=0 when they are uncovered. With 46.2-1ubuntu0.24.04.18, only "plain" prints suspended=1. The package build runs the /wayland/toplevel/suspended test, which the - debdiff extends. With the debdiff all nine of its cases pass. With the + debdiff extends. With the debdiff all ten of its cases pass. With the two window-actor patches reversed, the upstream screen shield case waits until meson stops the test after 360 seconds, and with that case left out, the new hidden subsurface case waits until the timeout instead; the - six cases that 46.2 already has pass either way. The suspend-state- + six cases that 46.2 already has pass either way. With the fifth patch + removed, the case for a reused wl_surface, run alone, fails in 9 of 10 + runs, and with AddressSanitizer it reports a heap-use-after-free in + is_surface_actor_mapped_changed(); the same sequence with an xdg_popup + does too. With the fifth patch, the case passes in all 10 runs and under + AddressSanitizer, and so does the xdg_popup sequence. The suspend-state- timeout test passes with and without the patches. I also ran ten scripted cases with 66 checks, each the state of a window at the end of a timed phase, in an isolated headless gnome-shell 46.0-0ubuntu6~24.04.17, once with the installed libmutter-14.so.0 and once with the one built from the debdiff (loaded through LD_LIBRARY_PATH; /proc/<pid>/maps showed which one each shell used). With both, windows stayed active when they were shown with a hidden subsurface, half covered, covered except for a mapped subsurface outside the main surface, shown as clones in the Activities overview while - covered, after a hidden subsurface was added with a parent commit that - draws nothing, and after a covered subsurface was unmapped while the - rest of the window was visible. They became active again as soon as they - were uncovered, unminimized or unlocked. Covered and minimized windows - without hidden subsurfaces were suspended with both. Covered windows - with a hidden subsurface were suspended only with the debdiff, also when - the subsurface had been mapped and was unmapped again while covered. + covered, after a hidden subsurface was added with a parent commit + without a buffer or damage, and after a covered subsurface was unmapped + while the rest of the window was visible. They became active again as + soon as they were uncovered, unminimized or unlocked. Covered and + minimized windows without hidden subsurfaces were suspended with both. + Covered windows with a hidden subsurface were suspended only with the + debdiff, also when the subsurface had been mapped and was unmapped again + while covered. [ Where problems could occur ] The patches change when mutter gives windows the suspended state, and clients use that state to stop work; Chrome, for example, stops committing frames. A mistake would show as a window that stops updating - while it is visible, or as one that keeps working while nobody can see - it. In the cases above where a window has to stay active, the results - did not change. + while it is visible, or as one that keeps working while it is hidden. In + the cases above where a window has to stay active, the results did not + change. Apart from the hidden subsurface case, the backport changes two situations, as mutter 49 does: - While the screen is locked, GNOME Shell hides the window groups. With the backport, windows are suspended about 3 seconds after the screen locks and are active again when it is unlocked. With 46.2-1ubuntu0.24.04.18 they stay active behind the lock screen. Suspending windows behind the lock screen is the purpose of the upstream merge request. - A minimized window, or a window on another workspace, is active while the Activities overview shows it, and is suspended again about 3 seconds after the overview closes. With 46.2-1ubuntu0.24.04.18 such windows stay suspended in the overview, because update_suspend_state() checked MetaWindow::hidden. + + The fifth patch only disconnects a handler that the first patch + connects, as disconnect_surface_actor_from() already does for the + notify::is-obscured handler. Without it, the backport can crash gnome- + shell in the case described under [ Fix ]. Only Wayland clients that bind xdg_wm_base version 6 or later receive the suspended state. mutter reads the state only to build the xdg_toplevel configure (src/wayland/meta-window-wayland.c and src/wayland/meta-wayland-window-configuration.c), so X11 and Xwayland clients and Xorg sessions are not affected. [ Other Info ] The package build with the debdiff and Ubuntu's own amd64 build of 46.2-1ubuntu0.24.04.18 both have one failing test, /backends/monitor/custom/second-rotated-tiled-config in monitor-unit, with the same assertion; debian/rules ignores test failures, and the test fails the same way without these patches. In the headless shell used for these tests, with and without the patches, a window covered by another window of exactly the same size and position was not suspended, and with a cover 2 pixels larger on each side it was. The covers in the tests therefore reach at least 2 pixels past the covered window. - The fourth patch in the debdiff is mine and not from upstream. It only - adds test cases and can be dropped. + The fourth and sixth patches in the debdiff are mine and not from + upstream. They only add test cases and can be dropped. ** Patch added: "Debdiff against mutter 46.2-1ubuntu0.24.04.18 with merge request 5347 (replaces the first debdiff)" https://bugs.launchpad.net/ubuntu/+source/mutter/+bug/2174026/+attachment/6018940/+files/mutter_46.2-1ubuntu0.24.04.19.debdiff -- You received this bug notification because you are a member of Ubuntu Desktop Bugs, which is subscribed to mutter in Ubuntu. https://bugs.launchpad.net/bugs/2174026 Title: Covered windows with a hidden subsurface are never suspended To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/mutter/+bug/2174026/+subscriptions -- desktop-bugs mailing list [email protected] https://lists.ubuntu.com/mailman/listinfo/desktop-bugs
