dnkl/foot
41
2.0k
Fork
You've already forked foot
243

Wayland error + freeze until sigkilled when a large number of damage rectangles are attached to the surface's pending buffer #2338

Open
opened 2026年05月14日 23:37:09 +02:00 by lilyyy411 · 1 comment

Foot Version

foot version: 1.26.1-13-gcc6b29fe (May 13 2026, branch 'master') -pgo +ime -graphemes +toplevel-tag +blur +assertions

TERM environment variable

foot

Compositor Name and Version

niri 26.04

Distribution

Linux Mint trixie/sid (xia)

Terminal multiplexer

No response

Shell, TUI, application

No response

Server/standalone mode

  • Standalone
  • Server

Foot config

default config

Description of Bug and Steps to Reproduce

In extreme cases where the pending buffer has an absolutely absurd number of damage rectangles (for me, it was around 9.9-10k), calls to [wl_surface_damage_buffer] in render.c grid_render() can cause a Wayland error Error sending request: Resource temporarily unavailable to be printed to the terminal. Then, as strace logs confirm, foot gets frozen attempting to constantly poll the Wayland socket and never receives an event again and requires being sigkilled to close the window.

This Wayland error comes from some internal limit on the number of damage rectangles that can be attached to a surface's pending buffer, but more importantly from the fact that foot does not currently attempt to optimize the number of damage rectangles given to the compositor. On a local clone, I was able to fix the bug and as a bonus, considerably boost foot's performance at high resolution in personal benchmarks, by implementing a naive greedy merging algorithm, and I'll make a PR when I get the chance.

You're probably wondering how the hell I even managed to get to 10k damage rectangles... I was writing my own terminal video player that renders with ASCII space characters as pixels so I could benchmark various terminals in sheer escape sequence parsing speed and foot was the only terminal that I tried that completely froze when the cell width became close to 1px.

Relevant logs, stacktraces, etc.

image
image

### Foot Version foot version: 1.26.1-13-gcc6b29fe (May 13 2026, branch 'master') -pgo +ime -graphemes +toplevel-tag +blur +assertions ### TERM environment variable foot ### Compositor Name and Version niri 26.04 ### Distribution Linux Mint trixie/sid (xia) ### Terminal multiplexer _No response_ ### Shell, TUI, application _No response_ ### Server/standalone mode - [x] Standalone - [x] Server ### Foot config ```ini default config ``` ### Description of Bug and Steps to Reproduce In extreme cases where the pending buffer has an absolutely absurd number of damage rectangles (for me, it was around 9.9-10k), calls to [`wl_surface_damage_buffer`] in `render.c` [`grid_render()`](<https://codeberg.org/dnkl/foot/src/branch/master/render.c#L3600-L3609>) can cause a Wayland error `Error sending request: Resource temporarily unavailable` to be printed to the terminal. Then, as strace logs confirm, foot gets frozen attempting to constantly poll the Wayland socket and never receives an event again and requires being sigkilled to close the window. This Wayland error comes from some internal limit on the number of damage rectangles that can be attached to a surface's pending buffer, but more importantly from the fact that foot does not currently attempt to optimize the number of damage rectangles given to the compositor. On a local clone, I was able to fix the bug and as a bonus, considerably boost foot's performance at high resolution in personal benchmarks, by implementing a naive greedy merging algorithm, and I'll make a PR when I get the chance. You're probably wondering how the hell I even managed to get to 10k damage rectangles... I was writing my own terminal video player that renders with ASCII space characters as pixels so I could benchmark various terminals in sheer escape sequence parsing speed and foot was the only terminal that I tried that completely froze when the cell width became close to 1px. ### Relevant logs, stacktraces, etc. ![image](/attachments/1b0772e3-942e-426c-a960-4b9cd27b06fc) ![image](/attachments/47e85fa5-19b1-49ba-9135-5bbe6f6f4d73)
979 KiB
399 KiB
Owner
Copy link

This Wayland error comes from some internal limit on the number of damage rectangles that can be attached to a surface's pending buffer, but more importantly from the fact that foot does not currently attempt to optimize the number of damage rectangles given to the compositor.

We've so far relied on pixman's builtin merging in pixman_region32_union_rect(). But if we can improve upon it ourselves, that's great.

> This Wayland error comes from some internal limit on the number of damage rectangles that can be attached to a surface's pending buffer, but more importantly from the fact that foot does not currently attempt to optimize the number of damage rectangles given to the compositor. We've so far relied on pixman's builtin merging in `pixman_region32_union_rect()`. But if we can improve upon it ourselves, that's great.
Sign in to join this conversation.
No Branch/Tag specified
master
osc-5522
sixel-heap-buffer-overflow
releases/1.27
releases/1.26
releases/1.25
releases/1.24
multi-cursor
releases/1.23
pixman-16f-2
releases/1.22
releases/1.21
releases/1.20
releases/1.19
releases/1.18
releases/1.17
releases/1.16
releases/1.15
releases/1.14
releases/1.13
releases/1.12
releases/1.11
releases/1.10
releases/1.9
releases/1.8
releases/1.7
releases/1.6
releases/1.5
releases/1.4
releases/1.3
releases/1.2
releases/1.1
releases/1.0
1.27.0
1.26.1
1.26.0
1.25.0
1.24.0
1.23.1
1.23.0
1.22.3
1.22.2
1.22.1
1.22.0
1.21.0
1.20.2
1.20.1
1.20.0
1.19.0
1.18.1
1.18.0
1.17.2
1.17.1
1.17.0
1.16.2
1.16.1
1.16.0
1.15.3
1.15.2
1.15.1
1.15.0
1.14.0
1.13.1
1.13.0
1.12.1
1.12.0
1.11.0
1.10.3
1.10.2
1.10.1
1.10.0
1.9.2
1.9.1
1.9.0
1.8.2
1.8.1
1.8.0
1.7.2
1.7.1
1.7.0
1.6.4
1.6.3
1.6.2
1.6.1
1.6.0
1.5.4
1.5.3
1.5.2
1.5.1
1.5.0
1.4.4
1.4.3
1.4.2
1.4.1
1.4.0
1.3.0
1.2.3
1.2.2
1.2.1
1.2.0
1.1.0
1.0.0
0.9.0
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
dnkl/foot#2338
Reference in a new issue
dnkl/foot
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?