sway
sway copied to clipboard
XWayland screen share lag while game is focused
-
Sway Version:
sway version 1.8-dev-1c69d0e7 (Jun 14 2022, branch 'master')
-
Debug Log:
-
Configuration File:
- Default config
-
Description:
- Start Steam -> CS:GO (or any other Steam game)
- Start Discord (or any other website that allows screen sharing XWayland applications like Mozilla's gum_test)
- Start screen sharing the Steam game (not through Pipewire but through XWayland, so individual window capture)
- Observe the screen share lag when the game is focused
- Observe the smoother gameplay output while something else is focused
To be clear, the game doesn't lag, it's the screen share output that becomes choppy while the game is focused. Focusing a different window results in a smooth screen share which is really word. I've tested this in Wayland Gnome and it doesn't occur there.
Games like Minecraft work just fine so maybe it's just Steam games or Vulkan titles? I'll test a few other games to make sure.
Anything else that I can provide to help?
Are you using the discord the app, or the website, what browser, is that browser running in XWayland?
I can't help but feel like this is expected behaviour, XShm screen capture is slow, and Minecraft uses far less resources compared to CS:GO, and there's no real way around it.
Unless you're running Nvidia and Windows, I wouldn't expect the screen capture system to work in Discord App very well, they don't seem to care if you own an AMD card even on Windows Native client, it's really choppy.
Try OBS with wlrobs or obs-vkcapture, and the virtual camera output, it's your best bet for a solid 30fps on discord, or just stream to YouTube or something to get 60fps.
https://github.com/emersion/xdg-desktop-portal-wlr added dmfbuf support 10 days ago, so that will help with performance issues in native wayland apps that enable it, that might help with screensharing in wayland based Firefox (once Firefox starts using it), but you're still out of luck unless you want to manually patch the Discord app with wayland aware chromium/electron.
@YellowOnion it works perfectly fine in Wayland Gnome so it should work fine here. CSGO is slow in the menu which isn't very resource intensive. It runs perfectly fine when the game is not focused for some reason
I did notice with the gum test In Firefox on Wayland (not XWayland) that 30fps capture was doing about 24fps, and 60fps 36fps, probably an issue with xdg-desktop-portal-wlr.
Again, this is you need to clarify how you're capturing the desktop, XShm is slow, it's a software blit to main memory, it's never going to keep up with dmabuf based solutions. If this is Wayland Firefox, like above, then we can narrow down what is causing the issues (not xdg-desktop-portal-gnome).
@YellowOnion updated the description. I'm only sharing the game and not the whole desktop. I'm not sure what method that is but it isn't through any desktop portal.
I've tried this in xwayland chromium due to Firefox lacking the support for the legacy individual xwayland window sharing in Wayland (due to them preferring the portal method instead).