Bug 471364 - Sharing window with OBS causes periodic desktop stuttering
Summary: Sharing window with OBS causes periodic desktop stuttering
Status: RESOLVED DUPLICATE of bug 469777
Alias: None
Product: kwin
Classification: Plasma
Component: wayland-generic (show other bugs)
Version: 5.27.6
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-06-23 06:22 UTC by deadmeu
Modified: 2023-12-20 19:34 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
UFO Screen Test With Stutter (2.54 MB, video/mp4)
2023-06-23 06:22 UTC, deadmeu
Details
pipewire connections (134.65 KB, image/png)
2023-06-25 07:29 UTC, deadmeu
Details

Note You need to log in before you can comment on or make changes to this bug.
Description deadmeu 2023-06-23 06:22:55 UTC
Created attachment 159849 [details]
UFO Screen Test With Stutter

SUMMARY
***
NOTE: If you are reporting a crash, please try to attach a backtrace with debug symbols.
See https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports
***
When sharing a window with OBS a brief stutter occurs every second, indefinitely. This stutter affects my entire desktop, including cursor movement. This issue does not occur when using a Screen Capture source.

It's worth noting that I have installed OBS as a Flatpak and so it would be using the appropriate screen sharing portals to view windows.

STEPS TO REPRODUCE
1. In OBS create a Window Capture source
2. Select a window to share from the Screen Sharing Portal and share it
3. Observe a periodic lag spike occurring every second

OBSERVED RESULT
Using a Window Capture source, when a portal is shared with OBS I begin to experience stuttering every second. If I open OBS and no portal is being actively shared I do not experience any stuttering.

Sometimes it doesn't happen though, but I have not been able to reliably reproduce this good behaviour.

EXPECTED RESULT
There should be no stuttering when sharing a window.

SOFTWARE/OS VERSIONS
Operating System: Arch Linux 
KDE Plasma Version: 5.27.6
KDE Frameworks Version: 5.107.0
Qt Version: 5.15.10
Kernel Version: 6.3.8-arch1-1 (64-bit)
Graphics Platform: Wayland
Processors: 24 × AMD Ryzen 9 3900X 12-Core Processor
Memory: 31.3 GiB of RAM
Graphics Processor: AMD Radeon RX 7900 XT
Manufacturer: ASUS

ADDITIONAL INFORMATION
This was originally reported to OBS but was requested to be upstreamed: https://github.com/obsproject/obs-studio/issues/9070
Comment 1 David Edmundson 2023-06-23 08:25:48 UTC
*** Bug 446115 has been marked as a duplicate of this bug. ***
Comment 2 deadmeu 2023-06-25 07:29:10 UTC
Created attachment 159888 [details]
pipewire connections

I've tested this issue a little more and it looks like this issue affects the Screen Capture Source as well. When you create a new Window/Screen capture source the Screen Sharing Portal dialog pops up with previews of the windows/screens to choose. This is when the stuttering begins. If you cancel out of that dialog the stuttering goes away.

Also, I tried disconnecting all of the pipewire screencast streams using qpwgraph while I had the Screen Sharing Portal preview dialog open to see if that would kill the stuttering (there are multiple win_wayland [kwin-screencast-...] sources connected to xdg-desktop-portal-kde [plasma-screencast-...], kwin_wayland [kwin-screencast-...], and plasmashell [plasma-screencast-...] sinks, see the attached screenshot) but that did not work.
Comment 3 deadmeu 2023-06-28 12:37:33 UTC
It's worth noting that this issue doesn't seem to occur when using a Game Capture source using obs-vkcapture (and obs-gstreamer).
Comment 4 toby 2023-08-14 10:21:13 UTC
I've experienced this with other apps other than OBS such as Webcord.
Comment 5 toby 2023-12-17 01:24:03 UTC
deadmeu, is one of you CPU cores pinned at 100% or close to it when you screen share? As I believe this issue is related to https://bugs.kde.org/show_bug.cgi?id=469777 as I get 100% on one core when screen sharing on Plasma, I don't experience this on other Wayland compositors.
Comment 6 deadmeu 2023-12-17 03:44:20 UTC
(In reply to toby from comment #5)
> deadmeu, is one of you CPU cores pinned at 100% or close to it when you
> screen share? As I believe this issue is related to
> https://bugs.kde.org/show_bug.cgi?id=469777 as I get 100% on one core when
> screen sharing on Plasma, I don't experience this on other Wayland
> compositors.

Thanks for commenting toby. Yes, when any window/screen sharing occurs, regardless of whether it's by the portal sharing selection dialog or a currently active source, I can see a single thread being pinned at max utilisation. I can see the kwin_wayland process maxing out at 4% utilisation which, on my CPU with 24 threads, lines up with the almost 100% utilisation I'm seeing on a single thread.
Comment 7 toby 2023-12-17 09:25:24 UTC
From the bug report I mentioned earlier Prajna Sariputra is reverting commit 226d8c0a3b464f8870c45bfe5079f042a3cd5d67 in kwin, I've just done that myself to see if it resolves this issue and from what I can tell I'm not getting any stuttering.
Comment 8 Nate Graham 2023-12-20 19:34:43 UTC

*** This bug has been marked as a duplicate of bug 469777 ***