Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kitty chrashes on GNOME 42 when moving to a HiDPI Display #4878

Closed
slrtbtfs opened this issue Mar 24, 2022 · 25 comments
Closed

kitty chrashes on GNOME 42 when moving to a HiDPI Display #4878

slrtbtfs opened this issue Mar 24, 2022 · 25 comments
Labels

Comments

@slrtbtfs
Copy link

Describe the bug

GNOME on Wayland is making trouble again. This time by sending invalid combinations of buffer size and scale factor.

To Reproduce
Steps to reproduce the behavior:

  1. Install GNOME 42
  2. Set up two Monitors, one of them with 200% scaling and one with 100% scaling.
  3. Open kitty
  4. Move kitty from the 100% scaled monitor to the 200% scaled monitor.
  5. If kitty hasn't crashed yet resize the window and try again.

Then kitty crashes with an error like:

wl_surface@22: error 2: Buffer size (1845x1157) must be an integer multiple of the buffer_scale (2)
[083 22:06:22.915993] [glfw error 65544]: Wayland: fatal display error: Protocol error

What seems to be going on on the GNOME side, is that the scaling factor is changed while half of the the window is still on the 100% scale monitor and the size is still the old one.

So far, I haven't found any other application that crashes this way.

Maybe it makes sense to ignore that protocol violation and just round the buffer size.

Environment details

OS: Fedora 36 with GNOME 42
kitty version 0.24.4
reproducible with --config NONE

@slrtbtfs slrtbtfs added the bug label Mar 24, 2022
@kovidgoyal
Copy link
Owner

kovidgoyal commented Mar 25, 2022

That's not an error from kitty, it's coming from libwayland. So kitty cannot
ignore it. Have you tried kitty master/nightly? The timing of handling surface
configure events was changed there to workaround more gnome bugs.

@sp1ritCS
Copy link

Its not just HiDPI, the fallout of GNOME42 seems to be disastrous

kitty without doing anything:

[destroyed object]: error 7: failed to import supplied dmabufs: Arguments are inconsistent (for example, a valid context requires buffers not supplied by a 
[084 04:51:56.638088] [glfw error 65544]: Wayland: fatal display error: Protocol error

(note, this is not just a kitty specific issue, I've already seen GNOME apps not launching)

@kovidgoyal
Copy link
Owner

Another idea, does hiding window decorations prevent the problem? hide_window_decorations yes in kitty.conf

@slrtbtfs
Copy link
Author

Another idea, does hiding window decorations prevent the problem? hide_window_decorations yes in kitty.con

Hiding window decorations doesn't help.

Have you tried kitty master/nightly?

The original error is still reproducible. The error found by @sp1ritCS also occurs sometimes instantly after starting kitty.

@kovidgoyal
Copy link
Owner

Well, these both appear to be bugs in GNOME 42, you should report it there. Not sure what kitty can do about it. Can you try running kitty with --debug-rendering and post the output when re-creating these issues.

@sp1ritCS
Copy link

sp1ritCS commented Mar 26, 2022

The error found by @sp1ritCS also occurs sometimes instantly after starting kitty.

I'm not sure what was the cause of my issue, but I assume it to just be a borked update. I rolled back to the pre GNOME 42 snapshot (and opened a bugreport, where I've got told by someone that he cannot reproduce it) and updated again, after which it worked (but it might have been that during that time kitty got auto rebuilt and then it worked).

@sp1ritCS
Copy link

sp1ritCS commented Mar 26, 2022

But, I've just tested setting my display scale to 200% and I can reproduce your issue (wl_surface@3: error 2: Buffer size (9x16) must be an integer multiple of the buffer_scale (2))

Launching kitty with --debug-rendering results in:

[085 11:29:02.610280] Ignoring unknown config key: open_url_modifiers
[085 11:29:02.610422] Ignoring unknown config key: rectangle_select_modifiers
[085 11:29:02.610448] Ignoring unknown config key: terminal_select_modifiers
Created decoration buffers at scale: 1 vertical_height: 814 horizontal_width: 1304
top-level configure event: size: 0x0 states: 
Resizing framebuffer to: 1280x778 at scale: 2
final window content size: 1280x778
Created decoration buffers at scale: 2 vertical_height: 814 horizontal_width: 1304
Setting window geometry in configure event: x=0 y=-24 1280x802
GL version string: '4.6 (Core Profile) Mesa 22.0.0' Detected version: 4.6
top-level configure event: size: 1280x508 states: 
Resizing framebuffer to: 1280x484 at scale: 2
final window content size: 1280x484
Created decoration buffers at scale: 2 vertical_height: 520 horizontal_width: 1304
Setting window geometry in configure event: x=0 y=-24 1280x508
top-level configure event: size: 960x508 states: TOPLEVEL_STATE_MAXIMIZED 
Resizing framebuffer to: 960x484 at scale: 2
final window content size: 960x484
Created decoration buffers at scale: 2 vertical_height: 520 horizontal_width: 984
Setting window geometry in configure event: x=0 y=-24 960x508
top-level configure event: size: 960x508 states: TOPLEVEL_STATE_MAXIMIZED TOPLEVEL_STATE_ACTIVATED 
final window content size: 960x484
Setting window geometry in configure event: x=0 y=-24 960x508
Resizing framebuffer to: 960x484 at scale: 1
Created decoration buffers at scale: 1 vertical_height: 520 horizontal_width: 984
Resizing framebuffer to: 960x484 at scale: 2
Created decoration buffers at scale: 2 vertical_height: 520 horizontal_width: 984
[085 11:29:02.887941] No render frame received in 0.25 seconds
Resizing framebuffer to: 960x484 at scale: 2
[085 11:29:02.888016] No render frame received in 0.25 seconds
wl_surface@3: error 2: Buffer size (9x16) must be an integer multiple of the buffer_scale (2)
[085 11:29:02.888710] [glfw error 65544]: Wayland: fatal display error: Protocol error
[085 11:29:02.888720] No render frame received in 0.25 seconds

which is a lot more output than with 100% scale:

[085 11:30:23.708676] Ignoring unknown config key: open_url_modifiers
[085 11:30:23.708819] Ignoring unknown config key: rectangle_select_modifiers
[085 11:30:23.708845] Ignoring unknown config key: terminal_select_modifiers
Created decoration buffers at scale: 1 vertical_height: 814 horizontal_width: 1304
top-level configure event: size: 0x0 states: 
final window content size: 1280x778
Setting window geometry in configure event: x=0 y=-24 1280x802
GL version string: '4.6 (Core Profile) Mesa 22.0.0' Detected version: 4.6
top-level configure event: size: 1280x802 states: TOPLEVEL_STATE_ACTIVATED 
final window content size: 1280x778
Setting window geometry in configure event: x=0 y=-24 1280x802
Resizing framebuffer to: 1280x778 at scale: 1
[085 11:30:23.933524] No render frame received in 0.25 seconds

@kovidgoyal
Copy link
Owner

Is 9x16 in that log accurate? I cant think of anything that would create
a buffer of that size when the window is much larger. Is yoru mouse
cursor that size?

@sp1ritCS
Copy link

Yes, the log is exactly what came out of kitties stdout/err, copied from gnome-terminals buffer (If I had modified it, I'd have removed the unknown config key too 😄 )

I'm using KDEs "Breeze Snow" cursor theme, but unless it does some kind of 200% scale fuckery I don't unterstand, neither the smallest variant of "default" nor "text" fits in a 9x16 box.

@kovidgoyal
Copy link
Owner

Is that log from just launching kitty? Not moving it between monitors as in the original report? I have added some more debug output about when exactly scale changes occur. Can you reproduce the log running from master?

@magne
Copy link

magne commented Mar 29, 2022

I have a problem starting kitty on Ubuntu 22.04 beta using Gnome 4.2. I have 3 monitors (laptop + 2 external), all 4K. If I scale the laptop display (fractional/integral scaling does not matter), kitty will not start, but fails with the error described above. If I set all displays to 100%, and scale the laptop display by selecting a lower resolution, kitty starts with no problem.

@sp1ritCS
Copy link

Yes, this is just from launching kitty on 200% scale.

From master:

[088 11:40:03.026862] Ignoring unknown config key: open_url_modifiers
[088 11:40:03.027068] Ignoring unknown config key: rectangle_select_modifiers
[088 11:40:03.027106] Ignoring unknown config key: terminal_select_modifiers
CSD: old.size: 0x0 new.size: 614x376 needs_update: 1 size_changed: 1
Created decoration buffers at scale: 1 vertical_height: 412 horizontal_width: 638
top-level configure event: size: 0x0 states: 
Ignoring first empty surface configure event on mutter.
GL version string: '4.6 (Core Profile) Mesa 22.0.0' Detected version: 4.6
top-level configure event: size: 638x424 states: TOPLEVEL_STATE_ACTIVATED 
Resizing framebuffer to: 638x400 at scale: 2
Scale changed to 2 in dispatchChangesAfterConfigureCSD: old.size: 614x376 new.size: 638x400 needs_update: 1 size_changed: 1
Created decoration buffers at scale: 2 vertical_height: 436 horizontal_width: 662
final window content size: 638x400 resized: 1
Setting window geometry in configure event: x=0 y=-24 638x424
Scale changed to 2 in surface enter eventResizing framebuffer to: 638x400 at scale: 2
CSD: old.size: 638x400 new.size: 638x400 needs_update: 0 size_changed: 0
[088 11:40:03.321577] No render frame received in 0.25 seconds
[088 11:40:03.321616] [glfw error 65544]: Wayland: fatal display error: Broken pipe
[088 11:40:03.321621] No render frame received in 0.25 seconds

@kovidgoyal
Copy link
Owner

Sorry I see nothing untoward in that. Mutter just killed the connection
as far as I can tell for no reason. I suggest you report it to GNOME, I
cant see anything kitty can do about their regression. If someone else
has some ideas, patches are most welcome.

@dgross881
Copy link

dgross881 commented May 18, 2022

Only workaround i've found for now using fedora 36 with fractional scaling enabled at 125% display scale is is to disable wayland for now until issue can be resolved

Add and reboot

KITTY_DISABLE_WAYLAND=1 to /etc/environment

This can also work if opening kitty from another terminal by adding this to your .bashrc or .zshrc file

export KITTY_DISABLE_WAYLAND=1

@kovidgoyal
Copy link
Owner

You dont need an env var for this. Simply set linux_display_backend in
kiity.conf

@kovidgoyal
Copy link
Owner

I spent some more time looking into this and I think I have figured out the root cause. It's a bug/limitation in libwayland-cursor. https://gitlab.freedesktop.org/wayland/wayland/-/issues/194

Basically, libwayland-cursor returns cursor sizes that can be larger than the size requested by the application, and that larger size may not be divisible by the scale. sway works around this bug by not enforcing the divisibility requirement. swaywm/sway#6014

So this needs to be fixed in either libwayland-cursor or in GNOME to not enforce the divisibility requirement.

@nipundrall
Copy link

this is not a kitty issue it's happening with other terminal emulators too. I'm currently using hyprland with arch and have tried other emulators too. need to use a command for waybar. As kovidgoyal said this is something related to wl_cursors_theme. Vaxry have created a hypercusror trying to use it will let you know if it fixes this and if anyone found a solution Please let me know.

@thejch
Copy link

thejch commented Apr 20, 2024

I spent some more time looking into this and I think I have figured out the root cause. It's a bug/limitation in libwayland-cursor. https://gitlab.freedesktop.org/wayland/wayland/-/issues/194

Basically, libwayland-cursor returns cursor sizes that can be larger than the size requested by the application, and that larger size may not be divisible by the scale. sway works around this bug by not enforcing the divisibility requirement. swaywm/sway#6014

So this needs to be fixed in either libwayland-cursor or in GNOME to not enforce the divisibility requirement.

That doesn't seem to be 100% accurate. From my understanding there are two parts to this issue.

  1. For a cursor surface. this is not fixable from kitty's side because it's a libwayland-cursor limitation. As a workaround, wlroots does not enforce this requirement on cursor surfaces, and we will have to wait for libwayland to fix it.
  2. For a non-cursor surface. There is no libwayland limitation that prevents this from being fixed. This is fixable from kitty's side and similar bugs have been fixed on many applications. Gnome mutter and wlroots do enforce this requirement, and this is still causing kitty to crash even to this day. So @kovidgoyal please do consider fixing this to comply to the wayland spec to prevent this error from crashing kitty.

More info:

wayland spec: https://gitlab.freedesktop.org/wayland/wayland/-/blob/f3026c916ef91d78040913298170d5e538dd6618/protocol/wayland.xml#L1451-1455

The new size of the surface is calculated based on the buffer size transformed by the inverse buffer_transform and the inverse buffer_scale. This means that at commit time the supplied buffer size must be an integer multiple of the buffer_scale. If that's not the case, an invalid_size error is sent.

wlroots only enforces the error on non-cursor surfaces: https://gitlab.freedesktop.org/wlroots/wlroots/-/blob/c63275d75e479bf39a104715423d1d6681c3163c/types/wlr_compositor.c#L215-L217, so the crashes on wlroots do not have anything to do with the cursor

firefox bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1795851
chromium bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1409940
mpv bug: mpv-player/mpv#10263
neovide bug: neovide/neovide#2200

@kovidgoyal
Copy link
Owner

kovidgoyal commented Apr 21, 2024 via email

@solaeus
Copy link

solaeus commented May 23, 2024

I'm getting this error message after upgrading to Fedora 40 because I'm using fractional scaling. A workaround for now is to set the display scale to 100% or 200%, open kitty, then go back to fractional scaling. This is fine for me because I keep my terminal open all day but going forward this really needs to be fixed in the wayland library.

@kovidgoyal
Copy link
Owner

Make sure you are running kitty >= 0.34.0 which add support for fractional scaling.

@solaeus
Copy link

solaeus commented May 23, 2024

I'm on 0.34.1, unfortunately. Thanks for your work on this project, it looks like I'm stuck waiting for a fix for the time being.

@kovidgoyal
Copy link
Owner

I tested kitty on GNOME, sway, KDE and hyprland with fractional scaling there were no issues. As I said the only remaining issue is if you move kitty window between two monitors with different scales. You can try running with --debug-rendering that should give a useful log.

@coddingtonbear
Copy link

coddingtonbear commented Jun 11, 2024

I'm afraid to say that, although I know positively that kitty was able to run just fine when using fractional scaling before I upgraded to Ubuntu 24.04, after I performed the upgrade, I'm seeing this error once again.

I've tried rebuilding, but it unfortunately persists:

acoddington@coddingtonbear-t14: ~/Documents/Projects/kitty (v0.35.1)!
 $ kitty/launcher/kitty --version                                                                                                                                                                                                                  [13:26:17]
kitty 0.35.1 created by Kovid Goyal
 
acoddington@coddingtonbear-t14: ~/Documents/Projects/kitty (v0.35.1)!
 $ kitty/launcher/kitty                                                                                                                                                                                                                            [13:26:29]
wl_surface@23: error 2: Buffer size (64x64) must be an integer multiple of the buffer_scale (3).
[0.366] [glfw error 65544]: Wayland: fatal display error: Protocol error
acoddington@coddingtonbear-t14: ~/Documents/Projects/kitty (v0.35.1)!
 $ cat /etc/lsb-release                                                                                                                                                                                                                            [13:26:32]
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=24.04
DISTRIB_CODENAME=noble
DISTRIB_DESCRIPTION="Ubuntu 24.04 LTS"

It's totally possible I've overlooked something, but I can say for sure that if I adjust the two of my three screens that I usually use fractional scaling on such that they no longer do, kitty is once again able to launch.


Shortly after writing the above, when trying to re-enable fractional scaling, I happened to notice that I was able to continue using fractional scaling on my main monitor as long as the Built-in screen (screen 1 in the below screenshot) was not. Maybe that helps narrow down the problem?

image

@solaeus
Copy link

solaeus commented Jun 14, 2024

At one point I upgraded to a knew Fedora Silverblue version and the issue went away for me. Multiple monitors with different scales and fractional scaling on the main monitor and it works just fine now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

9 participants