obs-studio icon indicating copy to clipboard operation
obs-studio copied to clipboard

Pipewire screen capture not working with Radeon RX 7900 XT

Open majewsky opened this issue 2 years ago • 11 comments

Operating System Info

Other

Other OS

Arch Linux

OBS Studio Version

29.0.0

OBS Studio Version (Other)

No response

OBS Studio Log URL

https://obsproject.com/logs/Z0nR5Dxndg77DnZ6

OBS Studio Crash Log URL

No response

Expected Behavior

The Pipewire screen capture source should be working.

Current Behavior

After installing my new GPU, a Radeon RX 7900 XT, screen capture sources are not showing any images at all. I can select and move it in the UI, but it's a fully transparent rectangle.

Steps to Reproduce

  1. Open up OBS on a scene with a Pipewire screen capture source.
  2. Look at the scene preview.

Anything else we should know?

I reproduced this issue with both the OBS packaged by Arch Linux as well as with the Flatpak (both obs-studio-29.0.0 using mesa-22.3.3 and llvm-libs 15.x). I'm on Wayland, my compositor is Sway 1.8.

The relevant error message is:

10:06:44.014: [pipewire] Renegotiating stream
10:06:44.030: Cannot create EGLImage: EGL failed to allocate resources for the requested operation.

This suggests that the issue might exist within Pipewire, Sway or somewhere else in the OpenGL stack. I double-checked Pipewire-based screensharing in my Jitsi instance (using both Firefox and the Webkit-based Qutebrowser), and that's working perfectly fine. But obviously, it's still possible that OBS is trying to capture the screen using a different set of parameters. Unfortunately, the screen capture source does not offer me any configuration parameters to tinker with.

majewsky avatar Jan 29 '23 09:01 majewsky

Can reproduce, same GPU. I'm running LLVM 15 with mesa 22.3.2 and on Hyprland instead of Sway (still wlroots).

I'm not using the flatpak version

edit: Void Linux (glibc)

simvux avatar Jan 29 '23 19:01 simvux

Screen capture doesn't work for me either. I am using Arch Linux with mesa-git, hyprland-git and the xdg-desktop-portal-hyprland-git. Webcord can use pipewire screen sharing without issue. Opening obs from a terminal I get the following error message:

error: Cannot create EGLImage: EGL failed to allocate resources for the requested operation.
info: [pipewire] Renegotiating stream
error: Cannot create EGLImage: EGL failed to allocate resources for the requested operation.
info: [pipewire] Renegotiating stream
...

Teddy-Kun avatar Feb 04 '23 14:02 Teddy-Kun

@simvux @Teddy-Kun Thanks for your confirmations! Since all of us are on wlroots compositors, I have tested with other another Wayland compositor now. And sure enough, screen capture into OBS via PipeWire works fine in a Plasma session.

I'm only speaking as a user, so don't take this as me saying that wlroots is at fault here, but I think it makes sense to make the wlroots devs aware as well. I tried opening an issue in their tracker, but my user account needs to be approved first. If one of you has an account there that works, please report this issue over there as well. Otherwise I'll do it when my account gets approved.

majewsky avatar Feb 04 '23 21:02 majewsky

@majewsky I have opened an issue here: #3577

Teddy-Kun avatar Feb 04 '23 21:02 Teddy-Kun

Can you still repro this with obs 29.0.2?

q234rty avatar Feb 05 '23 05:02 q234rty

Yes it still happens in 29.0.2

Teddy-Kun avatar Feb 05 '23 11:02 Teddy-Kun

I can reproduce this bug on obs 29.0.2 (flathub) too !

natir avatar Feb 10 '23 11:02 natir

mesa-22.3.3 and llvm-libs 15.x

As far as I understand, that MESA driver requires LLVM 15, and the KDE 6.4 runtime uses LLVM14 and cannot switch to LLVM15. We would need to wait for a KDE runtime that uses LLVM15 to be available.

RytoEX avatar Feb 10 '23 15:02 RytoEX

i cannot replicate this with intel (old/new) on sway. Please provide an obs log if you are affected instead of trying to give a description of your hardware.

kkartaltepe avatar Feb 10 '23 16:02 kkartaltepe

Also just a note, for the continual renegotiation that presents as:

error: Cannot create EGLImage: EGL failed to allocate resources for the requested operation.
info: [pipewire] Renegotiating stream
error: Cannot create EGLImage: EGL failed to allocate resources for the requested operation.
info: [pipewire] Renegotiating stream

This suggests that OBS and your compositor are unable to agree on a dmabuf format. On AMD there may be hundreds of formats to check which might take some time at 60fps. You should probably try and extract the full set of modifiers offered by your compositor against what obs can load. If you can run obs with PIPEWIRE_DEBUG=4 ./obs that should provide sufficient logging to diagnose the negotiation failure. This log will be extremely large.

kkartaltepe avatar Feb 12 '23 03:02 kkartaltepe

If I launch chromium (native wayland version) then I seem to also get EGL errors that may or may not be related.

[16918:16918:0212/195902.433334:ERROR:angle_platform_impl.cc(43)] Display.cpp:1021 (initialize): ANGLE Display::initialize error 0: Internal Vulkan error (-3): Initialization of an object could not be completed for implementation-specific reasons, in ../../third_party/angle/src/libANGLE/renderer/vulkan/RendererVk.cpp, initialize:1404.
ERR: Display.cpp:1021 (initialize): ANGLE Display::initialize error 0: Internal Vulkan error (-3): Initialization of an object could not be completed for implementation-specific reasons, in ../../third_party/angle/src/libANGLE/renderer/vulkan/RendererVk.cpp, initialize:1404.
[16918:16918:0212/195902.433398:ERROR:gl_display.cc(508)] EGL Driver message (Critical) eglInitialize: Internal Vulkan error (-3): Initialization of an object could not be completed for implementation-specific reasons, in ../../third_party/angle/src/libANGLE/renderer/vulkan/RendererVk.cpp, initialize:1404.
[16918:16918:0212/195902.433408:ERROR:gl_display.cc(932)] eglInitialize SwANGLE failed with error EGL_NOT_INITIALIZED
[16918:16918:0212/195902.433420:ERROR:gl_ozone_egl.cc(23)] GLDisplayEGL::Initialize failed.
[16918:16918:0212/195902.433815:ERROR:viz_main_impl.cc(186)] Exiting GPU process due to errors during initialization
[16876:16987:0212/195902.450031:ERROR:object_proxy.cc(623)] Failed to call method: org.freedesktop.DBus.Properties.Get: object_path= /org/freedesktop/UPower: org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.UPower was not provided by any .service files
[16876:16987:0212/195902.450078:ERROR:object_proxy.cc(623)] Failed to call method: org.freedesktop.UPower.GetDisplayDevice: object_path= /org/freedesktop/UPower: org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.UPower was not provided by any .service files
[16876:16987:0212/195902.450119:ERROR:object_proxy.cc(623)] Failed to call method: org.freedesktop.UPower.EnumerateDevices: object_path= /org/freedesktop/UPower: org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.UPower was not provided by any .service files
[16981:16981:0212/195902.471849:ERROR:angle_platform_impl.cc(43)] Display.cpp:1021 (initialize): ANGLE Display::initialize error 0: Internal Vulkan error (-3): Initialization of an object could not be completed for implementation-specific reasons, in ../../third_party/angle/src/libANGLE/renderer/vulkan/RendererVk.cpp, initialize:1404.
ERR: Display.cpp:1021 (initialize): ANGLE Display::initialize error 0: Internal Vulkan error (-3): Initialization of an object could not be completed for implementation-specific reasons, in ../../third_party/angle/src/libANGLE/renderer/vulkan/RendererVk.cpp, initialize:1404.
[16981:16981:0212/195902.471900:ERROR:gl_display.cc(508)] EGL Driver message (Critical) eglInitialize: Internal Vulkan error (-3): Initialization of an object could not be completed for implementation-specific reasons, in ../../third_party/angle/src/libANGLE/renderer/vulkan/RendererVk.cpp, initialize:1404.
[16981:16981:0212/195902.471910:ERROR:gl_display.cc(932)] eglInitialize SwANGLE failed with error EGL_NOT_INITIALIZED
[16981:16981:0212/195902.471920:ERROR:gl_ozone_egl.cc(23)] GLDisplayEGL::Initialize failed.
[16981:16981:0212/195902.472383:ERROR:viz_main_impl.cc(186)] Exiting GPU process due to errors during initialization

Chromium does work fine however. So it's probably fallbacking to some alternate form of rendering.

But I'm thinking this could be some bug in libglvnd or mesa or something causing these errors, not necessarily OBS.

Could someone who gets EGL errors in OBS try to replicate this?

simvux avatar Feb 12 '23 19:02 simvux

I have the same issue on the same hardware. 7900XT on Fedora 37. I use the flatpak version. I cannot spot anything in the logs:

12:35:48.679: Platform: Wayland
12:35:48.679: CPU Name: 13th Gen Intel(R) Core(TM) i9-13900K
12:35:48.679: CPU Speed: 5009.933MHz
12:35:48.680: Physical Cores: 24, Logical Cores: 32
12:35:48.680: Physical Memory: 64010MB Total, 19166MB Free
12:35:48.680: Kernel Version: Linux 6.1.10-200.fc37.x86_64
12:35:48.680: Distribution: "KDE Flatpak runtime" "5.15-21.08"
12:35:48.680: Session Type: wayland
12:35:48.681: Qt Version: 6.4.2 (runtime), 6.4.2 (compiled)
12:35:48.681: Portable mode: false
12:35:48.693: OBS 29.0.2 (linux)
12:35:48.694: ---------------------------------
12:35:48.694: ---------------------------------
12:35:48.694: audio settings reset:
12:35:48.694: 	samples per sec: 48000
12:35:48.694: 	speakers:        2
12:35:48.694: 	max buffering:   960 milliseconds
12:35:48.694: 	buffering type:  dynamically increasing
12:35:48.695: ---------------------------------
12:35:48.695: Initializing OpenGL...
12:35:48.695: Using EGL/Wayland
12:35:48.709: Initialized EGL 1.5
12:35:48.718: Loading up OpenGL on adapter AMD AMD Radeon Graphics (gfx1100, LLVM 15.0.7, DRM 3.49, 6.1.10-200.fc37.x86_64)
12:35:48.718: OpenGL loaded successfully, version 4.6 (Core Profile) Mesa 22.3.4 (git-a5ffb70f86), shading language 4.60
12:35:48.732: ---------------------------------
12:35:48.732: video settings reset:
12:35:48.732: 	base resolution:   1920x1080
12:35:48.732: 	output resolution: 1920x1080
12:35:48.732: 	downscale filter:  Bicubic
12:35:48.732: 	fps:               60/1
12:35:48.732: 	format:            NV12
12:35:48.732: 	YUV mode:          Rec. 709/Partial
12:35:48.732: NV12 texture support not available
12:35:48.732: P010 texture support not available
12:35:48.734: Audio monitoring device:
12:35:48.734: 	name: Default
12:35:48.734: 	id: default
12:35:48.734: ---------------------------------
12:35:48.741: No AJA devices found, skipping loading AJA UI plugin
12:35:48.741: Failed to initialize module 'aja-output-ui.so'
12:35:48.747: No AJA devices found, skipping loading AJA plugin
12:35:48.747: Failed to initialize module 'aja.so'
12:35:48.749: Failed to load 'en-US' text for module: 'decklink-captions.so'
12:35:48.751: Failed to load 'en-US' text for module: 'decklink-output-ui.so'
12:35:48.753: A DeckLink iterator could not be created.  The DeckLink drivers may not be installed
12:35:48.753: Failed to initialize module 'decklink.so'
12:35:48.828: [pipewire] Available captures:
12:35:48.828: [pipewire]     - Desktop capture
12:35:48.837: v4l2loopback not installed, virtual camera disabled
12:35:48.841: [obs-browser]: Version 2.19.0
12:35:48.841: [obs-browser]: CEF Version 103.0.5060.134 (runtime), 103.0.0-5060-shared-textures_143.2591+g4204d54+chromium-103.0.5060.134 (compiled)
12:35:48.847: VAAPI: API version 1.15
12:35:48.848: FFmpeg VAAPI H264 encoding supported
12:35:48.862: [obs-websocket] [obs_module_load] you can haz websockets (Version: 5.1.0 | RPC Version: 1)
12:35:48.862: [obs-websocket] [obs_module_load] Qt version (compile-time): 6.4.2 | Qt version (run-time): 6.4.2
12:35:48.862: [obs-websocket] [obs_module_load] Linked ASIO Version: 101201
12:35:48.865: [obs-websocket] [obs_module_load] Module loaded.
12:35:48.872: ---------------------------------
12:35:48.872:   Loaded Modules:
12:35:48.872:     text-freetype2.so
12:35:48.872:     rtmp-services.so
12:35:48.872:     obs-x264.so
12:35:48.872:     obs-websocket.so
12:35:48.872:     obs-vst.so
12:35:48.872:     obs-transitions.so
12:35:48.872:     obs-outputs.so
12:35:48.872:     obs-filters.so
12:35:48.872:     obs-ffmpeg.so
12:35:48.872:     obs-browser.so
12:35:48.872:     linux-v4l2.so
12:35:48.872:     linux-pulseaudio.so
12:35:48.872:     linux-pipewire.so
12:35:48.872:     linux-jack.so
12:35:48.872:     linux-capture.so
12:35:48.872:     image-source.so
12:35:48.872:     frontend-tools.so
12:35:48.872:     decklink-output-ui.so
12:35:48.872:     decklink-captions.so
12:35:48.872: ---------------------------------
12:35:48.872: ==== Startup complete ===============================================
12:35:48.886: All scene data cleared
12:35:48.886: ------------------------------------------------
12:35:48.889: pulse-input: Server name: 'PulseAudio (on PipeWire 0.3.65) 15.0.0'
12:35:48.889: pulse-input: Audio format: s16le, 48000 Hz, 2 channels
12:35:48.889: pulse-input: Started recording from 'alsa_output.usb-GN_Audio_A_S_Jabra_Engage_75_0372B166A811-00.analog-stereo.monitor' (default)
12:35:48.889: [Loaded global audio device]: 'Desktop Audio'
12:35:48.889: pulse-input: Server name: 'PulseAudio (on PipeWire 0.3.65) 15.0.0'
12:35:48.889: pulse-input: Audio format: s16le, 16000 Hz, 1 channels
12:35:48.889: pulse-input: Started recording from 'alsa_input.usb-GN_Audio_A_S_Jabra_Engage_75_0372B166A811-00.mono-fallback' (default)
12:35:48.889: [Loaded global audio device]: 'Mic/Aux'
12:35:48.889: PipeWire initialized
12:35:48.890: Switched to scene 'Scene'
12:35:48.890: ------------------------------------------------
12:35:48.890: Loaded scenes:
12:35:48.890: - scene 'Scene':
12:35:48.890:     - source: 'Screen Capture (PipeWire)' (pipewire-desktop-capture-source)
12:35:48.890: ------------------------------------------------
12:35:49.483: adding 21 milliseconds of audio buffering, total audio buffering is now 21 milliseconds (source: Desktop Audio)
12:35:49.483: 
12:36:13.890: [pipewire] Error creating screencast session: Timeout was reached
12:36:18.744: ==== Shutting down ==================================================
12:36:18.746: pulse-input: Stopped recording from 'alsa_output.usb-GN_Audio_A_S_Jabra_Engage_75_0372B166A811-00.analog-stereo.monitor'
12:36:18.746: pulse-input: Got 1192 packets with 1430400 frames
12:36:18.746: pulse-input: Stopped recording from 'alsa_input.usb-GN_Audio_A_S_Jabra_Engage_75_0372B166A811-00.mono-fallback'
12:36:18.746: pulse-input: Got 1187 packets with 474800 frames
12:36:18.746: [pipewire] Screencast session cancelled
12:36:18.752: All scene data cleared
12:36:18.752: ------------------------------------------------
12:36:18.796: [obs-websocket] [obs_module_unload] Shutting down...
12:36:18.796: [obs-websocket] [obs_module_unload] Finished shutting down.
12:36:18.800: [Scripting] Total detached callbacks: 0
12:36:18.800: Freeing OBS context data
12:36:18.807: == Profiler Results =============================
12:36:18.807: run_program_init: 263.716 ms
12:36:18.807:  ┣OBSApp::AppInit: 2.543 ms
12:36:18.807:  ┃ ┗OBSApp::InitLocale: 0.513 ms
12:36:18.807:  ┗OBSApp::OBSInit: 221.274 ms
12:36:18.807:    ┣obs_startup: 1.531 ms
12:36:18.807:    ┗OBSBasic::OBSInit: 206.829 ms
12:36:18.807:      ┣OBSBasic::InitBasicConfig: 0.037 ms
12:36:18.807:      ┣OBSBasic::ResetAudio: 0.091 ms
12:36:18.807:      ┣OBSBasic::ResetVideo: 39.998 ms
12:36:18.807:      ┣OBSBasic::InitOBSCallbacks: 0.002 ms
12:36:18.807:      ┣OBSBasic::InitHotkeys: 0.016 ms
12:36:18.807:      ┣obs_load_all_modules2: 137.786 ms
12:36:18.807:      ┃ ┣obs_init_module(aja-output-ui.so): 0.041 ms
12:36:18.807:      ┃ ┣obs_init_module(aja.so): 0.033 ms
12:36:18.807:      ┃ ┣obs_init_module(decklink-captions.so): 0 ms
12:36:18.807:      ┃ ┣obs_init_module(decklink-output-ui.so): 0 ms
12:36:18.807:      ┃ ┣obs_init_module(decklink.so): 0.043 ms
12:36:18.807:      ┃ ┣obs_init_module(frontend-tools.so): 37.254 ms
12:36:18.807:      ┃ ┣obs_init_module(image-source.so): 0.004 ms
12:36:18.807:      ┃ ┣obs_init_module(linux-capture.so): 0 ms
12:36:18.807:      ┃ ┣obs_init_module(linux-jack.so): 0.002 ms
12:36:18.807:      ┃ ┣obs_init_module(linux-pipewire.so): 1.14 ms
12:36:18.807:      ┃ ┣obs_init_module(linux-pulseaudio.so): 0.002 ms
12:36:18.807:      ┃ ┣obs_init_module(linux-v4l2.so): 4.357 ms
12:36:18.807:      ┃ ┣obs_init_module(obs-browser.so): 0.03 ms
12:36:18.807:      ┃ ┣obs_init_module(obs-ffmpeg.so): 5.045 ms
12:36:18.807:      ┃ ┃ ┗nvenc_check: 0.404 ms
12:36:18.807:      ┃ ┣obs_init_module(obs-filters.so): 0.016 ms
12:36:18.807:      ┃ ┣obs_init_module(obs-outputs.so): 0.002 ms
12:36:18.807:      ┃ ┣obs_init_module(obs-transitions.so): 0.005 ms
12:36:18.807:      ┃ ┣obs_init_module(obs-vst.so): 0.001 ms
12:36:18.807:      ┃ ┣obs_init_module(obs-websocket.so): 2.34 ms
12:36:18.807:      ┃ ┣obs_init_module(obs-x264.so): 0.001 ms
12:36:18.807:      ┃ ┣obs_init_module(rtmp-services.so): 0.366 ms
12:36:18.807:      ┃ ┗obs_init_module(text-freetype2.so): 0.005 ms
12:36:18.807:      ┣OBSBasic::ResetOutputs: 0.051 ms
12:36:18.807:      ┣OBSBasic::CreateHotkeys: 0.02 ms
12:36:18.807:      ┣OBSBasic::InitService: 0.723 ms
12:36:18.807:      ┣OBSBasic::InitPrimitives: 0.084 ms
12:36:18.807:      ┗OBSBasic::Load: 17.044 ms
12:36:18.807: obs_hotkey_thread(25 ms): min=0 ms, median=0 ms, max=0.009 ms, 99th percentile=0 ms, 100% below 25 ms
12:36:18.807: audio_thread(Audio): min=0.003 ms, median=0.01 ms, max=0.09 ms, 99th percentile=0.018 ms
12:36:18.807: obs_graphics_thread(16.6667 ms): min=0.036 ms, median=0.164 ms, max=6.975 ms, 99th percentile=0.434 ms, 100% below 16.667 ms
12:36:18.807:  ┣tick_sources: min=0 ms, median=0.001 ms, max=0.022 ms, 99th percentile=0.003 ms
12:36:18.807:  ┣output_frame: min=0.018 ms, median=0.123 ms, max=0.335 ms, 99th percentile=0.263 ms
12:36:18.807:  ┃ ┗gs_context(video->graphics): min=0.017 ms, median=0.122 ms, max=0.335 ms, 99th percentile=0.262 ms
12:36:18.807:  ┃   ┣render_video: min=0.002 ms, median=0.004 ms, max=0.042 ms, 99th percentile=0.013 ms
12:36:18.807:  ┃   ┃ ┗render_main_texture: min=0.001 ms, median=0.003 ms, max=0.029 ms, 99th percentile=0.011 ms
12:36:18.807:  ┃   ┗gs_flush: min=0 ms, median=0.001 ms, max=0.013 ms, 99th percentile=0.002 ms
12:36:18.807:  ┗render_displays: min=0.001 ms, median=0.042 ms, max=6.932 ms, 99th percentile=0.189 ms
12:36:18.807: =================================================
12:36:18.807: == Profiler Time Between Calls ==================
12:36:18.807: obs_hotkey_thread(25 ms): min=25.003 ms, median=25.053 ms, max=25.148 ms, 100% within ±2% of 25 ms (0% lower, 0% higher)
12:36:18.807: obs_graphics_thread(16.6667 ms): min=16.089 ms, median=16.667 ms, max=17.238 ms, 99.889% within ±2% of 16.667 ms (0.0554939% lower, 0.0554939% higher)
12:36:18.807: =================================================
12:36:18.809: Number of memory leaks: 2

Any way I could make it give more information? Screen Capturing with the Gnome Tool used to be broken as well for a while but seems to have been fixed.

aut0 avatar Feb 14 '23 11:02 aut0

#8293 might resolve this.

columbarius avatar Feb 19 '23 01:02 columbarius

similar xdpw patch: https://github.com/emersion/xdg-desktop-portal-wlr/pull/258

columbarius avatar Feb 19 '23 18:02 columbarius

@columbarius Just tried compiling your branch from the PR of obs and master of xdg-desktop-portal-wlr and can confirm this works! Big thanks.

side note; to get OBS to compile, i had to comment out the line obs-studio/plugins/obs-ffmpeg/obs-ffmpeg-mpegts.c:214. Because the property codec is deprecated and OBS's build has -Werror=deprecated-declarations

simvux avatar Feb 21 '23 18:02 simvux

Hm, interestingly the error still appears 3 or 4 times when the stream starts. But then stops and visually everything works.

Going into settings does cause a segmentation fault but I suspect that's because of the hack I did to get it to compile mentioned above :p

simvux avatar Feb 21 '23 18:02 simvux

Hm, interestingly the error still appears 3 or 4 times when the stream starts. But then stops and visually everything works.

Those errors are expected. Format negotiation has options which can only be fixed by testing. As such OBS tries to import a buffer and if that fails it will send this information back to the producer. Those are the errors you see.

Going into settings does cause a segmentation fault but I suspect that's because of the hack I did to get it to compile mentioned above :p

If this happens again, please provide a trace :)

columbarius avatar Feb 22 '23 11:02 columbarius

The upgrade to xdg-desktop-portal-wlr-0.7.0 resolves this issue for me, so I'm going to assume that https://github.com/emersion/xdg-desktop-portal-wlr/pull/260 was what did the trick. @columbarius Thank you very much for your help!

majewsky avatar Apr 19 '23 16:04 majewsky