-
Notifications
You must be signed in to change notification settings - Fork 232
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
vainfo crashes if gamescope is running #23
Comments
I looked into this a bit. There are several problems and a decision needs to be made how to proceed. First vainfo tries to connect to the Wayland server because vainfo calls wl_display_connect with arg NULL (https://github.com/intel/libva-utils/blob/master/common/va_display_wayland.c#L85) which defaults to wayland-0 if WAYLAND_DISPLAY is not set (https://manpages.debian.org/experimental/libwayland-doc/wl_display_connect.3.en.html). gamescope currently calls wl_display_add_socket_auto (https://github.com/Plagman/gamescope/blob/master/src/wlserver.c#L411) which does use the wayland-0 socket if not already taken. The worst is that this crashes gamescope at the moment:
That's independent of any hardware decoding issue and should be fixed asap. Clients should never be able to crash the compositor by calling into the wl_drm interface. To trick vainfo into using the X11 backend one can set the Wayland socket name to something else like this:
This will not work when there is some other Wayland compositor running at the same time that takes the wayland-0 socket (and gamescope not setting WAYLAND_DISPLAY). Then vainfo would try to connect to the wayland-0 socket again. One can also just force vainfo to use a certain backend: This exposes the main problem though: libva's X11 backend does not support DRI3, only DRI2. But XWayland is only serving the DRI3 extension (see also https://bugs.freedesktop.org/show_bug.cgi?id=101681#c3). There was a PR to add DRI3 support to libva: intel/libva#180 Both got stuck though and the change to the intel-vaapi-driver means that the gallium/radeonsi vaapi driver also need to be changed. Because Intel's new media-driver won't provide vo (video-output) it does not need to be changed according to: intel/media-driver#790 (comment). Overall this all only affects the vo-part of libva. It is not needed for the decoder/encoder part to work. At least in mpv you can select vaapi decoding with (under X11) or without its output part by:
In particular in gamescope I can get mpv with vaapi decoding to work like this:
The env variables are necessary because otherwise libva tries to use its vo-part (without calling into the driver, see https://github.com/intel/libva/blob/master/va/x11/va_x11.c#L77) to search for the right driver what fails because of missing DRI2. Moving forwardThe last paragraph shows that one can get hardware video en-/decoding to work in a client if some environment details are prearranged for/by the client. It might make more sense though to aim for implementing the DRI3 interface in libva. Or ignore vaapi on XWayland and instead support Wayland native clients in gamescope since vaapi hw decoding works without any problems there and vaapi drivers normally implement the backend. But this depends on what clients we need vaapi for and if they can/could be Wayland native ones. On the other side supporting Wayland native clients would also solve the troubles with the missing WAYLAND_DISPLAY variable. We could just set it and allow clients to act as normal Wayland clients if they want to. |
Yes, this is some annoying libwayland behaviour. We've tried undoing this mistake, but some people want to keep it "because env variables are evil". A solution is to set WAYLAND_DISPLAY to something that isn't a socket. An empty string works well. |
Is this the last issue with vainfo? Does libva decoding work within a gamescope embedded session now? That's really what I'd like to get to, so that Steam Remote Play works properly with hardware decoding. |
Well, we still need DRI3 support in VA-API as @subdiff said, except if Steam Remote Play doesn't use the VO part (in which case we would need to set the proper env variables it seems). I'll do some more testing and maybe revive that libva PR. |
vaapi fails to initialize when using Steam Remote Play:
|
It seems Steam Remote Play's ffmpeg is a little bit old and tries X11 before DRM. This commit from 2019 changes ffmpeg's default behavior to first try DRM, then fallback to X11. I believe upgrading would fix this issue. |
As per this thread, it's not desirable to add Wayland support to ffmpeg's wcontext_vaapi (the X11 support is mostly here for legacy). |
The |
it somehow detects a wayland compositor is running and tries connecting to it, even though i'm running it from a completely separate context without WAYLAND_DISPLAY set. how come?
The text was updated successfully, but these errors were encountered: