Do proper wayland teardown cleaning up listeners and fds#2066
Conversation
ed8b88b to
863aaca
Compare
|
@3v1n0, any chance you'd get some time to have a look at this PR? |
|
ping @3v1n0 |
|
Friendly ping @3v1n0 ALT Linux is on the way to drop libwlroots 0.18 from testing (sisyphus) repo. Was able to build gamescope with patches but would really appreciate proper upstream support. |
|
Marco probably busy with soon to be released Ubuntu 26.04 @emersion Could gamescope skip 0.19 and jump straight to 0.20? I tried building Debian package with libwlroots 0.20 (with patches from this PR) and in my quick testing it was ok |
863aaca to
0f0ddc0
Compare
|
Sorry for the delay, I think I handled the main things, let me know |
If we do not do this newer wlroots would rightly assert every time that
a surface gets closed with:
gamescope: types/wlr_compositor.c:734:
surface_handle_resource_destroy:
Assertion `wl_list_empty(&surface->events.commit.listener_list)'
failed.
gamescope: types/wlr_compositor.c:737:
surface_handle_resource_destroy:
Assertion `wl_list_empty(&surface->events.destroy.listener_list)'
failed.
Prevents:
gamescope: xwayland/server.c:462: wlr_xwayland_server_destroy:
Assertion `wl_list_empty(&server->events.ready.listener_list)' failed
Starting from wlroots 0.19 all these would trigger assertion errors
Destroy the event signals handlers on shutdown
Avoid heap-allocating the listener with new; embed it directly in the wlserver_t struct instead.
We were not closing the KMS session on destruction since the DRM FD might be still being polled by the page-flip thread. Handle this gracefully now by: - Create a pipe - Pass the pipe to the thread - Make the thread to repeatedly and atomically check if it should exit When we're about to finish the drm backend: - Mark the thread as thread as completed - Close the pipe write end to signal the thread that we're done - Join the thread to wait its completion - Finally close KMS on wayland side and unset the drm fd This allows to finally close all the remaining resources or signal connections that we created on wayland side
0f0ddc0 to
baf810e
Compare
| if ( wlserver.wlr.session ) | ||
| { | ||
| wl_list_remove( &wlserver.session_active.link ); | ||
| wlr_session_destroy( wlserver.wlr.session ); |
There was a problem hiding this comment.
This commit causes a SIGSEGV on exit for me in libseat.
Do we really need it? The session will destroy itself automatically with wl_display_destroy().
|
With the commit mentioned above reverted, this branch works well for me! |
In debian we're already using wlroots-0.19, but with it every time a client window is closed or when gamescope itself is closed, we crash with an assertion error.
So remove event listeners (helping #1990) and close the drm FD, ensuring that the page-flip thread is completed.
See commits for details.