LizardByte / Sunshine

Self-hosted game stream host for Moonlight.
http://app.lizardbyte.dev/Sunshine/
GNU General Public License v3.0
19k stars 922 forks source link

Black screen when streaming. Error: GL: /build/sunshine/src/platform/linux/graphics.cpp:570: [00000502] #2390

Open gprotta opened 6 months ago

gprotta commented 6 months ago

Is there an existing issue for this?

Is your issue described in the documentation?

Is your issue present in the nightly release?

Describe the Bug

Just run some application and the streaming gets a black screen.

Expected Behavior

The stream should work with video

Additional Context

No response

Host Operating System

Linux

Operating System Version

Fedora 39 - Gnome 45.5 Wayland - Linux 6.7.9-200.fc39.x86_64

Architecture

64 bit

Sunshine commit or version

0.23.0

Package

Linux - rpm

GPU Type

Nvidia

GPU Model

NVIDIA GeForce GTX 1660 Ti with Max-Q Design

GPU Driver/Mesa Version

550.67

Capture Method (Linux Only)

KMS

Config

output_name = 0
adapter_name = /dev/dri/card1

Apps

No response

Relevant log output

[gprotta@fedora build]$ sunshine
[adapter_name] -- [/dev/dri/card1]
[output_name] -- [0]
[2024:04:08:00:11:31]: Info: Sunshine version: v0.23.0
[2024:04:08:00:11:31]: Info: System tray created

(sunshine:72691): Gtk-CRITICAL **: 00:11:31.990: gtk_widget_get_scale_factor: assertion 'GTK_IS_WIDGET (widget)' failed
[2024:04:08:00:11:31]: Error: Failed to create session: Version mismatch between NvFBC and the X driver interface
[2024:04:08:00:11:31]: Info: Found display [wayland-0]
[2024:04:08:00:11:31]: Info: Found interface: wl_output(4) version 4
[2024:04:08:00:11:31]: Info: Found interface: zxdg_output_manager_v1(5) version 3
[2024:04:08:00:11:31]: Info: Found interface: wl_output(31) version 4
[2024:04:08:00:11:31]: Warning: Missing Wayland wire for wlr-export-dmabuf
[2024:04:08:00:11:31]: Info: /dev/dri/card0 -> i915
[2024:04:08:00:11:31]: Info: /dev/dri/card1 -> nvidia-drm
[2024:04:08:00:11:31]: Info: Found display [wayland-0]
[2024:04:08:00:11:31]: Info: Found display [wayland-0]
[2024:04:08:00:11:31]: Info: Found interface: wl_output(4) version 4
[2024:04:08:00:11:31]: Info: Found interface: zxdg_output_manager_v1(5) version 3
[2024:04:08:00:11:31]: Info: Found interface: wl_output(31) version 4
[2024:04:08:00:11:31]: Info: Resolution: 1920x1080
[2024:04:08:00:11:31]: Info: Resolution: 1920x1080
[2024:04:08:00:11:31]: Info: Offset: 0x0
[2024:04:08:00:11:31]: Info: Logical size: 1920x1080
[2024:04:08:00:11:31]: Info: Name: HDMI-2
[2024:04:08:00:11:31]: Info: Found monitor: Dell Inc. 27"
[2024:04:08:00:11:31]: Info: Offset: 0x1080
[2024:04:08:00:11:31]: Info: Logical size: 1920x1080
[2024:04:08:00:11:31]: Info: Name: eDP-1
[2024:04:08:00:11:31]: Info: Found monitor: Built-in display
[2024:04:08:00:11:31]: Info: -------- Start of KMS monitor list --------
[2024:04:08:00:11:31]: Info: Monitor 1 is HDMI-2: Dell Inc. 27"
[2024:04:08:00:11:31]: Info: Monitor 0 is eDP-1: Built-in display
[2024:04:08:00:11:31]: Info: --------- End of KMS monitor list ---------
[2024:04:08:00:11:32]: Info: // Testing for available encoders, this may generate errors. You can safely ignore those errors. //
[2024:04:08:00:11:32]: Info: Trying encoder [nvenc]
[2024:04:08:00:11:32]: Info: Screencasting with KMS
[2024:04:08:00:11:32]: Info: /dev/dri/card0 -> i915
[2024:04:08:00:11:32]: Info: /dev/dri/card1 -> nvidia-drm
[2024:04:08:00:11:32]: Info: Found monitor for DRM screencasting
[2024:04:08:00:11:32]: Info: Found connector ID [88]
[2024:04:08:00:11:32]: Info: Found cursor plane [38]
[2024:04:08:00:11:32]: Info: SDR color coding [Rec. 601]
[2024:04:08:00:11:32]: Info: Color depth: 8-bit
[2024:04:08:00:11:32]: Info: Color range: [JPEG]
[2024:04:08:00:11:32]: Info: SDR color coding [Rec. 601]
[2024:04:08:00:11:32]: Info: Color depth: 8-bit
[2024:04:08:00:11:32]: Info: Color range: [JPEG]
[2024:04:08:00:11:32]: Info: SDR color coding [Rec. 601]
[2024:04:08:00:11:32]: Info: Color depth: 8-bit
[2024:04:08:00:11:32]: Info: Color range: [JPEG]
[2024:04:08:00:11:32]: Warning: [av1_nvenc @ 0x2e07a40] Codec not supported
[2024:04:08:00:11:32]: Error: [av1_nvenc @ 0x2e07a40] Provided device doesn't support required NVENC features
[2024:04:08:00:11:32]: Error: Could not open codec [av1_nvenc]: Function not implemented
[2024:04:08:00:11:32]: Info: Screencasting with KMS
[2024:04:08:00:11:32]: Info: /dev/dri/card0 -> i915
[2024:04:08:00:11:32]: Info: /dev/dri/card1 -> nvidia-drm
[2024:04:08:00:11:32]: Info: Found monitor for DRM screencasting
[2024:04:08:00:11:32]: Info: Found connector ID [88]
[2024:04:08:00:11:32]: Info: Found cursor plane [38]
[2024:04:08:00:11:32]: Info: SDR color coding [Rec. 709]
[2024:04:08:00:11:32]: Info: Color depth: 10-bit
[2024:04:08:00:11:32]: Info: Color range: [JPEG]
[2024:04:08:00:11:33]: Info: 
[2024:04:08:00:11:33]: Info: // Ignore any errors mentioned above, they are not relevant. //
[2024:04:08:00:11:33]: Info: 
[2024:04:08:00:11:33]: Info: Found H.264 encoder: h264_nvenc [nvenc]
[2024:04:08:00:11:33]: Info: Found HEVC encoder: hevc_nvenc [nvenc]
[2024:04:08:00:11:33]: Info: Adding avahi service Sunshine
[2024:04:08:00:11:33]: Info: Configuration UI available at [https://localhost:47990]
[2024:04:08:00:11:34]: Info: Avahi service Sunshine successfully established.
[2024:04:08:00:12:13]: Info: // Testing for available encoders, this may generate errors. You can safely ignore those errors. //
[2024:04:08:00:12:13]: Info: Trying encoder [nvenc]
[2024:04:08:00:12:13]: Info: Screencasting with KMS
[2024:04:08:00:12:13]: Info: /dev/dri/card0 -> i915
[2024:04:08:00:12:13]: Info: /dev/dri/card1 -> nvidia-drm
[2024:04:08:00:12:13]: Info: Found monitor for DRM screencasting
[2024:04:08:00:12:13]: Info: Found connector ID [88]
[2024:04:08:00:12:13]: Info: Found cursor plane [38]
[2024:04:08:00:12:13]: Info: SDR color coding [Rec. 601]
[2024:04:08:00:12:13]: Info: Color depth: 8-bit
[2024:04:08:00:12:13]: Info: Color range: [JPEG]
[2024:04:08:00:12:14]: Info: SDR color coding [Rec. 601]
[2024:04:08:00:12:14]: Info: Color depth: 8-bit
[2024:04:08:00:12:14]: Info: Color range: [JPEG]
[2024:04:08:00:12:14]: Info: SDR color coding [Rec. 601]
[2024:04:08:00:12:14]: Info: Color depth: 8-bit
[2024:04:08:00:12:14]: Info: Color range: [JPEG]
[2024:04:08:00:12:14]: Warning: [av1_nvenc @ 0x7f68303c8540] Codec not supported
[2024:04:08:00:12:14]: Error: [av1_nvenc @ 0x7f68303c8540] Provided device doesn't support required NVENC features
[2024:04:08:00:12:14]: Error: Could not open codec [av1_nvenc]: Function not implemented
[2024:04:08:00:12:14]: Info: Screencasting with KMS
[2024:04:08:00:12:14]: Info: /dev/dri/card0 -> i915
[2024:04:08:00:12:14]: Info: /dev/dri/card1 -> nvidia-drm
[2024:04:08:00:12:14]: Info: Found monitor for DRM screencasting
[2024:04:08:00:12:14]: Info: Found connector ID [88]
[2024:04:08:00:12:14]: Info: Found cursor plane [38]
[2024:04:08:00:12:14]: Info: SDR color coding [Rec. 709]
[2024:04:08:00:12:14]: Info: Color depth: 10-bit
[2024:04:08:00:12:14]: Info: Color range: [JPEG]
[2024:04:08:00:12:14]: Info: 
[2024:04:08:00:12:14]: Info: // Ignore any errors mentioned above, they are not relevant. //
[2024:04:08:00:12:14]: Info: 
[2024:04:08:00:12:14]: Info: Found H.264 encoder: h264_nvenc [nvenc]
[2024:04:08:00:12:14]: Info: Found HEVC encoder: hevc_nvenc [nvenc]
[2024:04:08:00:12:14]: Info: Executing [Desktop]

(sunshine:72691): Gtk-CRITICAL **: 00:12:14.904: gtk_widget_get_scale_factor: assertion 'GTK_IS_WIDGET (widget)' failed
[2024:04:08:00:12:14]: Info: CLIENT CONNECTED
[2024:04:08:00:12:14]: Info: /dev/dri/card0 -> i915
[2024:04:08:00:12:14]: Info: /dev/dri/card1 -> nvidia-drm
[2024:04:08:00:12:14]: Info: Found display [wayland-0]
[2024:04:08:00:12:14]: Info: Found interface: wl_output(4) version 4
[2024:04:08:00:12:14]: Info: Found interface: zxdg_output_manager_v1(5) version 3
[2024:04:08:00:12:14]: Info: Found interface: wl_output(31) version 4
[2024:04:08:00:12:14]: Info: Resolution: 1920x1080
[2024:04:08:00:12:14]: Info: Resolution: 1920x1080
[2024:04:08:00:12:14]: Info: Offset: 0x0
[2024:04:08:00:12:14]: Info: Logical size: 1920x1080
[2024:04:08:00:12:14]: Info: Name: HDMI-2
[2024:04:08:00:12:14]: Info: Found monitor: Dell Inc. 27"
[2024:04:08:00:12:14]: Info: Offset: 0x1080
[2024:04:08:00:12:14]: Info: Logical size: 1920x1080
[2024:04:08:00:12:14]: Info: Name: eDP-1
[2024:04:08:00:12:14]: Info: Found monitor: Built-in display
[2024:04:08:00:12:14]: Info: -------- Start of KMS monitor list --------
[2024:04:08:00:12:14]: Info: --------- End of KMS monitor list ---------
[2024:04:08:00:12:14]: Info: Screencasting with KMS
[2024:04:08:00:12:14]: Info: /dev/dri/card0 -> i915
[2024:04:08:00:12:14]: Info: /dev/dri/card1 -> nvidia-drm
[2024:04:08:00:12:14]: Info: Found monitor for DRM screencasting
[2024:04:08:00:12:14]: Info: Found connector ID [88]
[2024:04:08:00:12:14]: Info: Found cursor plane [38]
[2024:04:08:00:12:15]: Info: SDR color coding [Rec. 601]
[2024:04:08:00:12:15]: Info: Color depth: 8-bit
[2024:04:08:00:12:15]: Info: Color range: [MPEG]
[2024:04:08:00:12:15]: Error: GL: /build/sunshine/src/platform/linux/graphics.cpp:570: [00000502]
CPioGH2002 commented 6 months ago

Same here, albeit on X11. Ubuntu 23.10, Kernel 6.8.4, Nvidia Driver 550.67

Tested with the Flatpak and AppImage release: 0.23

A client (Moonlight on Linux and Windows) keeps the connection but only shows a black screen while the logs feature repeated Error: GL: /build/sunshine/src/platform/linux/graphics.cpp:570.

Bubbasm commented 6 months ago

Was having the same issue, in X11. ArchLinux 6.6.25-1-lts, Nvidia Driver 550.67 I found a workaround where changing Force a Specific Capture Method in Advanced tab in Configuration from the default value of Autodetect (recommended) to X11 made it work. But this caused the video to be laggy.

What finally worked was installing nvlax patch. The AUR archlinux packet is this, but I don't know what would be the equivalents in Ubuntu and Fedora.

CPioGH2002 commented 6 months ago

Can confirm that manually setting "X11" instead of the autodetect does make it work. Have to test more on the impact of that but thanks for the tip. Much appreciated.

Currently, either leaving Force a Specific Capture Method (in the Advanced tab) at "Autodetect" or manually setting it to "KMS" causes the black screen issue. KMS would be preferred over the slower/laggy X11 method from what I understand. But, for the Nvidia folks, there's of course another method in reach, once the driver was patched:

Patcher for Nvidia drivers (to get NvFBC working, which should be best in terms of speed and quality for Nvidia users): https://github.com/keylase/nvidia-patch

Update: After having used the above patcher, manually selecting "NvFBC" is possible and working as it should.

Note for Flatpak users: One has to patch the driver AND the flatpak version of the driver. Check the description of the above patcher to see how you can easily patch both instances. You simply execute a script and that one takes care of the rest, including backups. Note: This step has to be repeated after every new driver install/update.

gprotta commented 6 months ago

I'm running Wayland. I did the "NvFBC" patch and it didn't work.

CPioGH2002 commented 6 months ago

1) Did Sunshine work before for you, with Wayland and your Nvidia card, and only caused problems with the 0.23 version?

2) Are you able to got back to X11 for testing and check if the problem is resolved then?

Both questions aim at finding out if a Sunshine version change lead to the issue or if we are looking at generic Wayland-specific problems in conjunction with Nvidia cards.

When on X11: So far, it seems like the "Autodetect" feature causes the actual problem which can be worked around with manually setting it to the desired/working method. "X11" being the safe but also slow and heavy one.

One can expand the available methods by patching the Nvidia driver, which should lead to better performance and less system load once NvFBC is working. "KMS" should be somewhere in between, if one gets it working.

gprotta commented 6 months ago

@CPioGH2002 1 - I started using it on version 0.22 and 0.23, and both don't work with wayland, same problem. 2 - Yes, X11 working with manually setting.

cgutman commented 6 months ago

Are all of you using hybrid graphics systems with an iGPU and dGPU? I can't reproduce this with a regular single-GPU system with the display physically connected to the Nvidia GPU. Please describe the display topology of your systems (which GPUs are present, which displays are physically connected to which GPUs including internal displays on laptops).

For @gprotta's posted config, I think your issue is this in your config: adapter_name = /dev/dri/card1. You're explicitly forcing Sunshine to encode on the Nvidia GPU even if it can't import the frame buffer from the Intel GPU (which is often the case due to vendor-specific DRM tiling modifiers).

I'm running Wayland. I did the "NvFBC" patch and it didn't work.

This is expected because Nvidia hasn't added Wayland support to NvFBC. The KMS capture backend is optimal for Nvidia Wayland scenarios.

Bubbasm commented 6 months ago

In my case, using ArchLinux 6.6.25-1-lts and Nvidia Driver 550.67 I am only using one discrete Nvidia GPU on a desktop (not laptop) without any iGPU on the processor. Display is physically connected to the GPU

CPioGH2002 commented 6 months ago

Very good point regarding the architecture (hybrid vs. single GPU). I myself only run a single GPU on a desktop system with the monitor being attached to it. My iGPU is disabled, so the Nvidia card is the only one being available and active. Still using X11.

As described, once I get rid of the "autodetect" feature and set the capture method manually, everything is working fine.

@CPioGH2002 1 - I started using it on version 0.22 and 0.23, and both don't work with wayland, same problem. 2 - Yes, X11 working with manually setting.

So, seems like the dreaded Nvidia Wayland support/implementation plays a huge role for the problems described. Perhaps try cgutman's recommendation from above and check if the KMS capture method works on Wayland with your config.

cgutman commented 6 months ago

A few other questions to try and narrow down the issue:

gprotta commented 6 months ago

I tested it just with the laptop screen and it works (iGPU). When I use the HDMI output, only the mouse cursor works, but the screen stays black.

@cgutman Are you using the Nvidia proprietary kernel module or the Nvidia open kernel module? proprietary _Are you passing any nvidia-drm kernel module parameters like modeset=1 or NVregEnableGpuFirmware? none _Can you try to build and run drm_info on your affected system and attach the output here?_ I don't know how to use

cr1cr1 commented 3 months ago

Video Card: NVIDIA GeForce RTX 3080 OS: Arch Linux (latest)

  1. Uninstalled proprietary nvidia drivers I have manually installed.
  2. Installed with paru -Sy:
    • extra/nvidia 550.90.07-4
    • aur/nvidia-patch 550.90.07-1
  3. Reboot

In Sunshine:

Works as expected:

[2024:06:26:12:39:45]: Info: Found H.264 encoder: h264_nvenc [nvenc]
[2024:06:26:12:39:45]: Info: Found HEVC encoder: hevc_nvenc [nvenc]
[2024:06:26:12:39:45]: Info: Executing [Desktop]
[2024:06:26:12:39:45]: Info: CLIENT CONNECTED
[2024:06:26:12:39:45]: Info: Found [1] outputs
[2024:06:26:12:39:45]: Info: Virtual Desktop: 3840x2160
[2024:06:26:12:39:45]: Info: XrandR: available
[2024:06:26:12:39:45]: Info: -- Output --
[2024:06:26:12:39:45]: Info:   Resolution: 3840x2160
[2024:06:26:12:39:45]: Info:   Offset: 0x0
[2024:06:26:12:39:45]: Error: Couldn't destroy session handle: Unable to cleanup NvFBC
[2024:06:26:12:39:45]: Info: Screencasting with NvFBC
BionicRust commented 2 months ago

please fix, @Bubbasm workaround works for now