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

Stop pooling background surface buffers #288

Merged
merged 1 commit into from
Mar 22, 2023

Conversation

mstoeckl
Copy link
Contributor

@mstoeckl mstoeckl commented Mar 12, 2023

Quoting the commit message:

The wl_buffers for the background surface only need to be updated when the output dimensions change. Using the fixed pool of two buffers to cache these buffers does not help, since if a new buffer is needed, it will have a different size than whatever buffers were cached. Furthermore, because the pool has fixed size, it is possible to run out of buffers if configure events arrive faster than pool buffers are marked not busy,, which can lead to protocol errors when the background surface is committed after acknowledging a new size, but without attaching a buffer that matches that size.

Without this change, one way to make Swaylock run out of buffers is to run it inside a nested instance of Sway, configured to draw a large image as the background, and then rapidly resize the nested instance until Swaylock receives several configure events in a single wl_display_dispatch() call.

This fixes #180 and might help with #282.

The new buffer allocation strategy for the background is closer to what swaybg does.

@mstoeckl mstoeckl force-pushed the buffer-like-swaybg branch from e42aa73 to f8ed4e1 Compare March 12, 2023 21:06
render.c Outdated Show resolved Hide resolved
render.c Outdated Show resolved Hide resolved
@emersion
Copy link
Member

Looks good to me apart from this

The wl_buffers for the background surface only need to be updated
when the output dimensions change. Using the fixed pool of two
buffers to cache these buffers does not help, since if a new buffer
is needed, it will have a different size than whatever buffers were
cached. Furthermore, because the pool has fixed size, it is possible
to run out of buffers if configure events arrive faster than
pool buffers are marked not busy, which can lead to protocol errors
when the background surface is committed after acknowledging a new
size, but without attaching a buffer that matches that size.
@mstoeckl mstoeckl force-pushed the buffer-like-swaybg branch from f8ed4e1 to 7413783 Compare March 22, 2023 00:54
Copy link
Member

@emersion emersion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@emersion emersion merged commit 1d3e62c into swaywm:master Mar 22, 2023
@mstoeckl mstoeckl deleted the buffer-like-swaybg branch March 22, 2023 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Swaylock can run out of buffers when output is resized
2 participants