Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pipewire "out of buffers" and render lag with Linux on Wayland #11580

Open
lexano-ivs opened this issue Dec 2, 2024 · 5 comments
Open

Pipewire "out of buffers" and render lag with Linux on Wayland #11580

lexano-ivs opened this issue Dec 2, 2024 · 5 comments

Comments

@lexano-ivs
Copy link
Contributor

lexano-ivs commented Dec 2, 2024

Operating System Info

Ubuntu 24.04

Other OS

No response

OBS Studio Version

31.0.0-rc1

OBS Studio Version (Other)

No response

OBS Studio Log URL

https://obsproject.com/logs/ejZ0DoN56yhfNVBO

OBS Studio Crash Log URL

No response

Expected Behavior

I expect no render lag when using multiple pipewire screen capture sources (each using an individual application), and no messages of the following format in the debug log:

16:27:07.224: [pipewire] Out of buffers!

Current Behavior

Render lag count is increasing very frequently and also the skipped frames are incrementing as well. The debug log often output a single or sometimes a burst of messages of the form:

16:27:07.224: [pipewire] Out of buffers!

The presence of these "Out of buffers" messages seems to directly cause render lag counts to increment.

The exact line that is being tripped is

blog(LOG_DEBUG, "[pipewire] Out of buffers!");

If I use fewer Pipewire application captures, the problem is reduced (or completely masked if there is only 1).

Steps to Reproduce

  1. Use Ubuntu 24.04 with Wayland an NVIDIA GPU (I don't think the GPU matters but I was using this)
  2. Install SuperTuxkart and glxgears
  3. Open a shell with multiple tabs
  4. Shell tab 1: Run glxgears
  5. Shell tab 2: Run supertuxkart --demo-mode=5 --demo-laps=3 --demo-karts=3. Configure SuperTuxkart with VSYNC on and set resolution to 1080p with maximum GPU detail. SuperTuxkart will run in demo mode if left alone for a few seconds.
  6. Open another shell, and run something like htop or nvidia-smi dmon just to get some activity
  7. Start OBS studio. I used the flatpak build.
  8. Configure canvas and output to 1440p.
  9. Add Pipewire Screen capture individual sources for glxgears, supertuxkart, and the shell with htop or similar.
  10. In OBS, open the stats window with View->Stats
  11. Add another Pipewire Screen capture source for the OBS Stats window.
  12. Add a Media Source and playback a local AVC file in a loop using HW Decode if available. I used a 1080p clip but anything similar will work. The Media Source in fact didn't seem to make a difference in my testing but reporting it for completeness.
  13. Arrange the scene into something suitable.
  14. Open the log file for local viewing: Help -> Log Files -> View Current Log
  15. Start streaming to Twitch.
  16. The log will eventually show "[pipewire] Out of buffers!" and the stats window will show render lag and skipped frames.

Anything else we should know?

The canvas and output are set to 2560x1440p for this test. The issue with pipewire running out of buffers also happens with 1080p, but much less frequently. Using 1440p makes it much easier to reproduce.

The issue becomes far more prevalent if using the TEB (Twitch Enhanced Broadcasting) beta flatpak build at https://github.com/amazon-contributing/upstreaming-to-obs-studio/wiki/TEB-Beta-Linux-Installation#teb-v40-build. In this case, multiple encodes are running in tandem and the number of "Out of buffers!" messages spikes in addition to the render lag count. While the stream is still running in this case, simply disabling all but 1 (any 1) pipewire capture from view stops the error messages and render lag counts.

@lexano-ivs
Copy link
Contributor Author

For reference, a screenshot of my configuration:
Screenshot from 2024-12-02 16-51-26

@kkartaltepe
Copy link
Collaborator

Your log is incomplete, replicate the issue and then restart obs and upload the previous log.

Use Ubuntu 24.04 with Wayland an NVIDIA GPU (I don't think the GPU matters but I was using this)

No this is probably the most important thing besides which compositor you are using. Please attempt to replicate with another vendor and another compositor.

@tytan652
Copy link
Collaborator

tytan652 commented Dec 3, 2024

You will have to try to reproduce with either Fedora, Arch Linux or a distro that do have more recent dependencies.
PipeWire get fixes but Ubuntu does not get them, and Debian based distro mess too much with patches around PipeWire.

@lexano-ivs
Copy link
Contributor Author

lexano-ivs commented Dec 3, 2024

I setup the same configuration with EndeavourOS (Arch-based) with the Gnome desktop on Wayland, and applied all updates as of today. This is indeed much more stable than Ubuntu 24.04 in terms of the pipewire "Out of buffers" issue. I don't see the problem during steady-state in this configuration. It does point to a problem with a prior version of pipewire and/or differences in the desktop environment or compositor.

Update: The "Out of buffers" problem is happening with TEB enabled. The test above was with a 31.0.0-rc1 using a single output stream to Twitch. With TEB (between 3 and 5 output streams), I'm seeing many "Out of buffer" messages. The trigger seems to be several pipewire capture sessions and multiple output streams simultaneously.

Log file with TEB is at https://obsproject.com/logs/Z66AsQcbwBd67sLy

@lexano-ivs
Copy link
Contributor Author

The host PC I use for this testing and development has an NVIDIA 4060 and AMD 6650XT. I removed the 4060 to test the 6650XT. During a 30 minute TEB stream with 4 renditions (1440p, 1080p, 720p, 360p) and several pipewire application captures, there wasn't a single "Out of buffers!" message, and 0 render lags as well. It does seem the problem is related to NVIDIA, whether the nvidia driver or how the desktop interacts with the driver.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants