Hyprland: kitty: wl_surface error 2: Buffer size (958x538) is not divisible by scale (4)

  • Steps to reproduce:
monitor=,3840x2160@60,auto,4
bind=ALT,RETURN,exec,/usr/bin/systemd-run --user --collect --service-type=exec --slice=kitty --setenv=WAYLAND_DISPLAY=$WAYLAND_DISPLAY /usr/bin/kitty --single-instance --instance-group=kitty
  • Expected outcome kitty pops
  • Noted outcome
Aug 10 10:08:50 asus systemd[852]: Starting /usr/bin/kitty --single-instance --instance-group=kitty...
Aug 10 10:08:50 asus systemd[852]: Started /usr/bin/kitty --single-instance --instance-group=kitty.
Aug 10 10:08:50 asus Hyprland[1772]: Set keyboard focus to surface 1e6384c0, with wind
Aug 10 10:08:50 asus Hyprland[2025]: Running as unit: run-r5cc54e36155a4a64a3795a9bdbf8a33d.service
Aug 10 10:08:50 asus Hyprland[1772]: 00:00:47.799 [INFO] [wayland] error in client communication (pid 1789)
Aug 10 10:08:50 asus kitty[1789]: wl_surface@34: error 2: Buffer size (958x538) is not divisible by scale (4)
Aug 10 10:08:50 asus Hyprland[1772]: ow name: zsh
Aug 10 10:08:50 asus Hyprland[1772]: Enabling TextInput on no IME!
Aug 10 10:08:50 asus Hyprland[1772]: Committing TextInput on no IME!
Aug 10 10:08:50 asus Hyprland[1772]: Committing TextInput on no IME!
Aug 10 10:08:50 asus Hyprland[1772]: Committing TextInput on no IME!
Aug 10 10:08:50 asus Hyprland[1772]: Destroying workspace ID 1

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 3
  • Comments: 27 (7 by maintainers)

Most upvoted comments

why are you scaling up 4 times, what’s wrong with you

This error now happens nearly every time imv is opened. Something like this:

apm@apg ~> imv
Reading paths from stdin...
wl_surface@10: error 2: Buffer size (512x621) is not divisible by scale (2)

Since it’s not a cursor surface, this still triggers the bug despite the existing workaround in wlr_compositor.c. One could add a wlroots patch that just avoids that if entirely, but obviously it’d be better to get this fixed in wlroots itself.

I’m not sure if other apps are affected.

This error now happens nearly every time imv is opened. Something like this:

apm@apg ~> imv
Reading paths from stdin...
wl_surface@10: error 2: Buffer size (512x621) is not divisible by scale (2)

Since it’s not a cursor surface, this still triggers the bug despite the existing workaround in wlr_compositor.c. One could add a wlroots patch that just avoids that if entirely, but obviously it’d be better to get this fixed in wlroots itself.

I’m not sure if other apps are affected.

Same issue appears right after upgrading Hyprland from 0.35.0-2 to 0.37.0-1. 0.36.0 is not tested because it was not packaged in Archlinux official repos. Maybe will test it later.

Upd 24.04.04: Git bisect’ed from v0.35.0 to v0.37.0, the following commit seems to be the first bad commit that produced imv’s crash.

f4f3aa2e505ca1b22688fb4a32f31c4bfb851dd0 is the first bad commit
commit f4f3aa2e505ca1b22688fb4a32f31c4bfb851dd0
Author: vaxerski <vaxry@vaxry.net>
Date:   Wed Feb 28 11:45:43 2024 +0000

    layout: add size prediction for initial xdg commits
    
    fixes #4022

 src/events/Windows.cpp       |  4 ++-
 src/layout/DwindleLayout.cpp | 66 ++++++++++++++++++++++++++++++++++++++------
 src/layout/DwindleLayout.hpp |  1 +
 src/layout/IHyprLayout.cpp   |  4 +++
 src/layout/IHyprLayout.hpp   |  6 ++++
 src/layout/MasterLayout.cpp  | 27 ++++++++++++++++++
 src/layout/MasterLayout.hpp  |  1 +
 7 files changed, 100 insertions(+), 9 deletions(-)

I am experiencing the same issue. In my case, I tracked it down to the fact that kitty stores a cached window-size:

-> cat ~/.cache/kitty/main.json
{"window-size": [859, 517]}

And this window size does not take into account the scale factor. If I remove that file, kitty launches fine. I’m also going to update the linked issue with this information and then see if I can configure kitty to avoid this behavior.

This error now happens nearly every time imv is opened. Something like this:

apm@apg ~> imv
Reading paths from stdin...
wl_surface@10: error 2: Buffer size (512x621) is not divisible by scale (2)

Since it’s not a cursor surface, this still triggers the bug despite the existing workaround in wlr_compositor.c. One could add a wlroots patch that just avoids that if entirely, but obviously it’d be better to get this fixed in wlroots itself.

I’m not sure if other apps are affected.

since hyprland has now forked wlroots, can we apply the patch that @TheSunCat mentioned downstream? @vaxerski i don’t think it will be fixed upstream at wlroots since wlroots would rather report this as an error, because it is indeed a violation of protocols from the app’s part as i understand it see discussions at https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/733#note_1738935 and https://gitlab.freedesktop.org/wayland/wayland/-/issues/194 however, since many apps are having this problem (kitty, imv, wezterm to name a few), it may be worth it to patch a workaround here for hyprland, provided that this patch doesn’t break other things, until these apps have fixed it. the patch would simply be reverting this commit: https://gitlab.freedesktop.org/wlroots/wlroots/-/commit/18595000f3a21502fd60bf213122859cc348f9af

in the case of wlroots, in wlroots. Well, unless a compositor ditches the wlroots’ cursor impl

This needs to be fixed in the compositor and more generally in the wayland cursor library. applications can do nothing about it. The commit you linked to has nothing to do with this.

I can second this. I have two monitors: the 2k monitor (at 1.0 scaling) doesn’t suffer from this problem, but when I put any work on the native laptop screen (at 1.2 scaling), lots of applications would crash, including pop-up dialogs from dolphin.

Monitor eDP-1 (ID 0):
	1920x1200@59.950001 at 480x1440
	description: Sharp Corporation 0x1548 (eDP-1)
	make: Sharp Corporation
	model: 0x1548
	serial:
	active workspace: 1 (1)
	reserved: 0 29 0 0
	scale: 1.20
	transform: 0
	focused: no
	dpmsStatus: 1
	vrr: 0

Monitor DP-2 (ID 1):
	2560x1440@74.971001 at 0x0
	description: HP Inc. HP Z27n G2 6CM0150NZB (DP-2 via DP)
	make: HP Inc.
	model: HP Z27n G2
	serial: 6CM0150NZB
	active workspace: 2 (2)
	reserved: 0 29 0 0
	scale: 1.00
	transform: 0
	focused: yes
	dpmsStatus: 1
	vrr: 0

This crash happens often but not consistently with:

  • OBS flatpak on second monitor (1.0 scaling)
  • supersonic-desktop (Fyne toolkit, native Wayland) when opening on laptop monitor (scaling 1.4) OR instant crash on opening the special workspace
  • Blender when opening certain menus
  • nheko (Qt5) when moving between monitors
  • Firefox when moving between monitors

As of recently I have noticed it happening more often. Is there anything I can do to help get this fixed or at least work around it for now? It is difficult to use Hyprland knowing many programs can and will instantly crash and lose unsaved work. This does not happen in Sway with the same scaling options.

Based on the information provided in the kitty issue, this may well be an issue with hyprland and not in kitty itself.

Set your kitty config to be a prime number, then launch kitty with the attempt to use that resolution. It tries to resize to that number multiplied by the scale and it fails with this Wayland error:

~ took 6s 
-> cat ~/.cache/kitty/main.json
{"window-size": [701, 419]}⏎                                                                             
~ 
-> kitty --config NONE -o hide_window_decorations=yes -o remember_window_size=yes --debug-rendering
GL version string: '4.6 (Core Profile) Mesa 22.1.7' Detected version: 4.6
top-level configure event: size: 0x0 states: 
XDG decoration configure event received: has_server_side_decorations: 1
Calling wl_pointer_set_cursor in setCursorImage with surface: 0x56093867b4d0
Scale changed to 2 in dispatchChangesAfterConfigure
Resizing framebuffer to: 701x419 at scale: 2
final window content size: 701x419 resized: 1
Setting window geometry in configure event: x=0 y=0 701x419
Calling wl_pointer_set_cursor in setCursorImage with surface: 0x56093867b4d0
Scale changed to 2 in surface enter event
Resizing framebuffer to: 701x419 at scale: 2
top-level configure event: size: 859x517 states: TOPLEVEL_STATE_ACTIVATED TOPLEVEL_STATE_MAXIMIZED 
Calling wl_pointer_set_cursor in setCursorImage with surface: 0x56093867b4d0
Resizing framebuffer to: 859x517 at scale: 2
final window content size: 859x517 resized: 1
Setting window geometry in configure event: x=0 y=0 859x517
[247 00:32:20.255818] [glfw error 65544]: process_desktop_settings: failed with error: [org.freedesktop.DBus.Error.ServiceUnknown] The name org.freedesktop.portal.Desktop was not provided by any .service files
wl_surface@22: error 2: Buffer size (701x419) is not divisible by scale (2)
[247 00:32:20.263018] [glfw error 65544]: Wayland: fatal display error: Protocol error
Calling wl_pointer_set_cursor in setCursorImage with surface: 0x56093867b4d0