obsproject / obsproject/obs-studio
Pipewire "out of buffers" and render lag with Linux on Wayland
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 76.4k
- Forks
- 10.2k
- Avg merge
- 4d 23h
- Merged PRs (30d)
- 12
Description
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 https://github.com/obsproject/obs-studio/blob/c8e215be3da8d0a5cfd83bb35db4be045a7669b5/plugins/linux-pipewire/pipewire.c#L676
If I use fewer Pipewire application captures, the problem is reduced (or completely masked if there is only 1).
Steps to Reproduce
- Use Ubuntu 24.04 with Wayland an NVIDIA GPU (I don't think the GPU matters but I was using this)
- Install SuperTuxkart and glxgears
- Open a shell with multiple tabs
- Shell tab 1: Run
glxgears - 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. - Open another shell, and run something like
htopornvidia-smi dmonjust to get some activity - Start OBS studio. I used the flatpak build.
- Configure canvas and output to 1440p.
- Add Pipewire Screen capture individual sources for glxgears, supertuxkart, and the shell with htop or similar.
- In OBS, open the stats window with View->Stats
- Add another Pipewire Screen capture source for the OBS Stats window.
- 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.
- Arrange the scene into something suitable.
- Open the log file for local viewing: Help -> Log Files -> View Current Log
- Start streaming to Twitch.
- 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with plugins/linux-pipewire/pipewire.c at the reported line 676, then reproduce the issue using the listed Ubuntu Wayland setup and multiple PipeWire application captures. Compare the OBS log and Stats window while increasing the number and resolution of sources. Done means the reproduction no longer produces repeated "[pipewire] Out of buffers!" messages or associated render lag and skipped frames.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, linux, ubuntu
- Domain
- desktop, operating-systems, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100