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

wayland: Block dispatching if back buffer isn't released #55

Merged
merged 1 commit into from
Jan 4, 2023

Conversation

ids1024
Copy link
Member

@ids1024 ids1024 commented Dec 27, 2022

#41

If set_buffer can just be called in a loop without waiting for buffers to be released or a frame callback, but can also be called in other ways, I don't know if there's a better solution than blocking.

Should fix #48. The animation example could probably be implemented better, but this is at least better.

I guess it should be documented that set_buffer may block? I don't know how this compares to other backends.

Leaving as a draft at the moment since #48 still seems to be an issue. The error doesn't occur, but at least in a VM I'm seeing Gnome Shell freezing (not an issue with smithay/cosmic-comp). I guess it's still sending buffers to the server, without an FPS limit or use of the frame callback, and the server doesn't have time to do much else?

rust-windowing#41

If `set_buffer` can just be called in a loop without waiting for buffers
to be released or a frame callback, but can also be called in other
ways, I don't know if there's a better solution than blocking.

Should fix rust-windowing#48. The
animation example could probably be implemented better, but this is at
least better.

I guess it should be documented that `set_buffer` may block? I don't
know how this compares to other backends.
@ids1024
Copy link
Member Author

ids1024 commented Dec 28, 2022

Oh, I forgot about this part:

A server should avoid signaling the frame callbacks if the surface is not visible in any way, e.g. the surface is off-screen, or completely obscured by other opaque surfaces.

https://wayland.app/protocols/wayland#wl_surface:request:frame

We definitely don't want to block indefinitely if a window isn't visible, so we can't wait on a frame callback, and really need the application/winit to handle that. (Even without that, this would be a problem with multiple windows).

So I guess this is the best we can do in softbuffer, at present.

@ids1024 ids1024 marked this pull request as ready for review December 28, 2022 19:44
@ids1024
Copy link
Member Author

ids1024 commented Jan 4, 2023

@i509VCB Does this seem like a reasonable way to deal with double buffering? As you mentioned in #41, double-buffering may not be necessary on compositors that just upload the data to GPU and don't keep the shm buffer, but I don't see an Wayland API that indicates if the compositor will do that. So if we tried to only allocate a second buffer only when the first isn't released, it may tend to eventually end up allocating a second unless the application waits for a frame callback to render.

Copy link
Member

@jackpot51 jackpot51 left a comment

Choose a reason for hiding this comment

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

This looks reasonable to me

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.

Wayland animation example fails on Gnome
2 participants