pop-os / cosmic-comp

Compositor for the COSMIC desktop environment
GNU General Public License v3.0
487 stars 89 forks source link

gamescope wayland backend does not shut down cleanly with cosmic-comp and fails to properly re-launch until session restart #681

Open matte-schwartz opened 3 months ago

matte-schwartz commented 3 months ago

up-to-date gamescope defaults to a Wayland backend, which appears to interact poorly with Cosmic's Wayland session. interestingly, the first time you launch gamescope -- vkcube, things appear to work well, even resizing the window: gamescope-good.log

However, trying to shut down gamescope with gamescopectl shutdown leads to a frozen gamescope window unless you force terminate it. Trying to relaunch gamescope -- vkcube afterwards works for a few seconds before crashing: gamescope-bad.log

it generates this coredump for gamescope: gamescope-sigabrt-coredump.log

I haven't seen this before on Mutter or KWin which leads me to believe it's a cosmic-comp issue, although I could be wrong. I don't use other Tiling WMs so maybe it happens on them too. gamescope --backend sdl -- vkcube does seem to work although this has mostly been phased out for the wayland backend except as a fallback option.

matt@threadripper-pc:~$ inxi -GSC ``` inxi -GSC System: Host: threadripper-pc Kernel: 6.10.2-202.fsync.fc40.x86_64 arch: x86_64 bits: 64 Desktop: Gamescope v: N/A Distro: Nobara Linux 40 (KDE Plasma) CPU: Info: 32-core model: AMD Ryzen Threadripper 7970X s bits: 64 type: MT MCP MCM cache: L2: 32 MiB Speed (MHz): avg: 1368 min/max: 545/5673 cores: 1: 545 2: 545 3: 545 4: 5491 5: 545 6: 545 7: 545 8: 545 9: 5048 10: 545 11: 545 12: 545 13: 5338 14: 545 15: 545 16: 545 17: 545 18: 5337 19: 545 20: 545 21: 545 22: 545 23: 545 24: 545 25: 545 26: 545 27: 5341 28: 545 29: 545 30: 5341 31: 545 32: 545 33: 545 34: 545 35: 545 36: 545 37: 545 38: 545 39: 5502 40: 5528 41: 545 42: 545 43: 545 44: 545 45: 545 46: 545 47: 545 48: 545 49: 545 50: 5340 51: 545 52: 545 53: 545 54: 545 55: 545 56: 545 57: 5313 58: 545 59: 545 60: 545 61: 5147 62: 545 63: 545 64: 545 Graphics: Device-1: AMD Navi 31 [Radeon RX 7900 XT/7900 XTX/7900M] driver: amdgpu v: kernel Display: wayland server: Xwayland v: 24.1.0 compositor: Gamescope driver: N/A resolution: 3440x1440 API: EGL v: 1.5 drivers: kms_swrast,radeonsi,swrast platforms: gbm,wayland,x11,surfaceless,device API: OpenGL v: 4.6 compat-v: 4.5 vendor: amd mesa v: 24.1.5 renderer: AMD Radeon RX 7900 XTX (radeonsi navi31 LLVM 18.1.6 DRM 3.57 6.10.2-202.fsync.fc40.x86_64) API: Vulkan v: 1.3.280 drivers: N/A surfaces: xcb,xlib,wayland ```

inxi believes that gamescope is the compositor, maybe since gamescope doesn't shut down cleanly? not sure. I'm using Cosmic on a Fedora based distro.

Drakulix commented 3 months ago

So your bad log contains these lines:

[gamescope] [Info]  wlserver: [wayland] unable to lock lockfile /run/user/1000/gamescope-0.lock, maybe another compositor is running
[gamescope] [Info]  wlserver: Running compositor on wayland display 'gamescope-1'

And

terminate called after throwing an instance of 'std::system_error'
  what():  Invalid argument
[gamescopereaper] [Info]  reaper: Parent of gamescopereaper was killed. Killing children.

Which lead me to believe, the previous run left some files or even processes in place due to it's unclean shutdown, which then cause issues on the next run.

The latter is imo a gamescope bug and unclean shutdown on any system could potentially cause this until the next reboot (pinging @Joshua-Ashton in case they care about fixing this).

The issue with COSMIC then obviously lies with the first run not terminating properly, which I really would like to fix. Given the packaging situation with gamescope can be quite of a mess depending on which distro you are running, could you point me to the exact commit of gamescope you are running? (Or give me the version string of the gamescope package of whatever package manager you might use?) I'll try to replicate the issue then.

Also if you could do a good-run with WAYLAND_DEBUG=1 set and upload that log, that would also be very helpful. Note the log might get very verbose, so please try to shutdown gamescope as soon as it appears to be fully launched.

matte-schwartz commented 3 months ago

I tend to follow along with gamescope changes as they happen and build regularly, so my testing was done on gamescope built from: https://github.com/ValveSoftware/gamescope/commit/e31b8dea137d2cedd4cf71fede560feb2ad3ffc5

If it helps, you can see exactly how I build it on Fedora https://copr-dist-git.fedorainfracloud.org/cgit/matte-schwartz/gamescope-vanilla/gamescope.git/commit/?id=1b488e5740a60942ef921430e5c6f0348b4f919f

A log of the good run with WAYLAND_DEBUG=1 for ~10 seconds followed by gamescopectl shutdown in another terminal window, which is the "correct" way to shut down gamescope now: gamescope-wayland-debug.log