sway: sway crashes when interacting with chromium
- Sway Version:
sway version 1.10-dev-2686afb9 (May 7 2024, branch ‘master’)
- Debug Log:
https://paste.sr.ht/~whynothugo/95a3445a0e678c2a642994d7662d5f0357ae1d14
- Stack Trace:
I didn’t run sway with gdb; will try again and follow-up.
- Description:
Interacting with chromium makes sway crash. Sometimes it’s when right clicking, but often times this happens when toggling fullscreen.
I can’t find an exact reproducer. Opening a terminal and chromium and moving the windows around / toggling full screen seems to toggle it. Sometimes it happens at the first right-click.
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 6
- Comments: 34 (18 by maintainers)
It’s a wlroots issue. If a client sends bad state, it should never crash the entire compositor.
I’m triggering what I’m currently assuming is the same crash by opening a print preview window in Chrome (using its wayland Ozone backend), using Sway 1.10.1 and wlroots 0.18.2 with the patch from https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4981 applied. Same “cairo_image_surface_create failed”, then:
(height matches, box width much larger than texture width).
I have a 3840x2400 output with scale factor 2, but this doesn’t obviously look like something scale-factor-related. My titlebars are (based on counting pixels in a screenshot) 52 pixels tall, but there’s a bunch of padding around the titlebar text so if there’s a texture not including that text a 36 pixel height for that seems plausible. (Also,
options->dst_boxhas x=10, y=8, and width and height same assrc_box: assuming that’s relative to the output that’d fit with it being titlebar text).Applying the logging patch from https://github.com/swaywm/sway/issues/8194#issuecomment-2600936550 (on top of the other wlroots patch, it looks like the added logging still makes sense), that logging does not trigger.
Haven’t wrapped my head around what all this code does yet…
Looking at
sway_text_node_set_max_width, there’s anupdate_source_boxcall before therender_backing_buffercall (here).render_backing_buffercontains its ownupdate_source_boxcall here, which is paired with awlr_scene_buffer_set_buffercall. Judging by that previous logged error, we’re exitingrender_backing_bufferearly (here).Again, don’t know what this code does yet, but that seemed suspicious… I tried commenting out the
update_source_boxcall before therender_backing_buffercall (reasoning that as long asrender_backing_bufferdoesn’t fail it’ll callupdate_source_boxagain anyway and at first glance that’d plausibly be early enough) and now I’m no longer crashing but I get a very horizontally stretched titlebar: it’s plausible the text is supposed to be 374 pixels (from the earlier coredump) wide, but it’s stretched horizontally to fill the entire titlebar. I also saw a similarly stretched titlebar briefly when starting Chrome.So that’s not the right fix but hopefully that narrows it down a bit further… (I’ll look into this more if I find time)
I accidentally found a reliable reproducer: A massive window title triggers it, tested with both Firefox and Chromium. Here’s two PoC HTML files: black-bar.txt causes the title bar to only show a black bar, and doubling the title size (crash.txt) causes a crash.
Firefox may trigger this too: