ValveSoftware / SteamOS

SteamOS community tracker
1.55k stars 70 forks source link

Pipewire based capture is broken in 20230323.1000 #1000

Closed safijari closed 10 months ago

safijari commented 1 year ago

Your system information

Please describe your issue in as much detail as possible:

Starting a capture using gstreamer's pipewiresrc causes gamescrope to crash. This appears to be related to a regression that existed in pipewire 0.3.61 (apparently a request for a 0 by 0 frame is sent to gamescope which hits an assert). Downgrading to the old 0.3.59 fixes the issue.

Steps for reproducing this issue:

  1. Be on main OS branch
  2. Install gstreamer-vaapi gst-plugin-pipewire gst-plugins-bad-libs gst-plugins-good
  3. Run gst-launch-1.0 -e -vvv pipewiresrc do-timestamp=true ! vaapipostproc ! queue ! vaapih264enc ! h264parse ! matroskamux name=sink ! filesink location=/tmp/test.mkv

I know this isn't exactly in the standard usecase for Steam OS, but this serves as the backbone of a popular plugin called Decky Recorder which adds screen recording and Replay Mode to the Steam Deck. It would be a shame if that functionality was lost with the upcoming OS upgrade. Please consider upgrading to a newer version of pipewire that does not suffer from this issue or to remain on 0.3.59 for now. Alternatively gamescope could ignore any requests for a malformed frame.

safijari commented 1 year ago

@kisak-valve on the subject of which issue tracker this should go on:

I originally opened this ticket because as I see it this is a Steam OS issue at the end of the day. As a developer on decky-recorder I'm unfortunately only able to stand on the sidelines and watch as a fairly well used plugin very likely goes from being usable to unusable in one update and trying to find a way to avoid that. One way to do that is for the Steam OS team to defer updating pipewire for 3.5 until this problem can be resolved.

I opened the ticket in the gamescope tracker after I realized this might be a gamescope issue.

safijari commented 1 year ago

As of today it no longer crashes gamescope, but gstreamer is still not able to negotiate the stream with gamescope.


Setting pipeline to PAUSED ...
ERROR: from element /GstPipeline:pipeline0/GstPipeWireSrc:pipewiresrc0: Internal data stream error.
Additional debug info:
../gstreamer/subprojects/gstreamer/libs/gst/base/gstbasesrc.c(3127): gst_base_src_loop (): /GstPipeline:pipeline0/GstPipeWireSrc:pipewiresrc0:
streaming stopped, reason not-negotiated (-4)
ERROR: pipeline doesn't want to preroll.
Failed to set pipeline to PAUSED.
Setting pipeline to NULL ...
Freeing pipeline ...```
TCU14 commented 1 year ago

As of today it no longer crashes gamescope, but gstreamer is still not able to negotiate the stream with gamescope.

Have you figured out a way around this? I've been setting up OBS as an alternative to decky recorder in the meantime, problem is to record in gaming mode instead of exclusively desktop mode I believe it requires vkcapture and gstreamer and I'm thinking it'll run into this same exact issue.

safijari commented 1 year ago

As of today it no longer crashes gamescope, but gstreamer is still not able to negotiate the stream with gamescope.

Have you figured out a way around this? I've been setting up OBS as an alternative to decky recorder in the meantime, problem is to record in gaming mode instead of exclusively desktop mode I believe it requires vkcapture and gstreamer and I'm thinking it'll run into this same exact issue.

OBS will probably also run into the same issues if it's doing capture using pipewire. Desktop mode runs X11 which has none of the screen recorder issues that gamemode does because gamemode runs on Wayland. Decky Recorder will likely not function in desktop mode actually.

One way to avoid this is to do DRM capture directly rather than using pipewire. Sunshine does this (I have a fork of Sunshine that's hosted on my github that you can test). This requires root permissions though.

The only real fix is for gamescope devs to fix the negotiation problem that their implementation of pipewire is having with gstreamer. I have low hopes.

safijari commented 1 year ago

On latest main things no longer crash but the recording also does not start.

mbilker commented 8 months ago

I tried the test command gst-launch-1.0 -e -vvv pipewiresrc do-timestamp=true ! vaapipostproc ! queue ! vaapih264enc ! h264parse ! matroskamux name=sink ! filesink location=/tmp/test.mkv on 20231213.1000 on my Steam Deck LCD and it worked for the 30 second test video I took. No issues playing back the recorded file as well.