Huge frame drops when recording/screensharing

Hey, guys
Recently I have switched to GNOME 40 from KDE and I liked it more, but I have one major issue with it - when I record with OBS, or share my screen in Discord there are huge frame drops that are pain in the @ss :frowning:
What I have done so far is updating the kernel to the latest 5.13 (it made a difference in performance overall but didnā€™t solve the issue). Iā€™m using NVIDIA 470.52 drivers with the NVIDIA GPU enabled only, no PRIME.

https://i.ibb.co/myrkZkc/Screenshot-from-2021-08-05-09-22-05.png

Here is a screenshot from the FPS in OBS, the ingame one is constantly above 130-140 FPS (I tried windowed mode even in the screenshot just to see - the ingame FPS is locked to 200, hovewer the stuttering is massive, as you can see the real FPS is around 30).
These are my machine specs.

https://i.ibb.co/6PpJDm5/Screenshot-from-2021-08-05-09-25-20.png

inxi -Fx

System:
  Host: nitro5-ryzen7 Kernel: 5.13.5-1-MANJARO x86_64 bits: 64 compiler: gcc 
  v: 11.1.0 Desktop: GNOME 40.3 Distro: Manjaro Linux base: Arch Linux 
Machine:
  Type: Laptop System: Acer product: Nitro AN515-44 v: V1.01 
  serial: <superuser required> 
  Mobo: RO model: Stonic_RNS v: V1.01 serial: <superuser required> 
  UEFI: Insyde v: 1.01 date: 04/16/2020 
Battery:
  ID-1: BAT1 charge: 48.5 Wh (100.0%) condition: 48.5/57.5 Wh (84.4%) 
  volts: 16.6 min: 15.4 model: LGC AP18E8M status: Unknown 
CPU:
  Info: 8-Core model: AMD Ryzen 7 4800H with Radeon Graphics bits: 64 
  type: MT MCP arch: Zen 2 rev: 1 cache: L2: 4 MiB 
  flags: avx avx2 lm nx pae sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3 svm 
  bogomips: 92664 
  Speed: 1558 MHz min/max: 1400/2900 MHz boost: enabled Core speeds (MHz): 
  1: 1558 2: 1523 3: 1427 4: 1654 5: 1408 6: 1397 7: 1899 8: 1648 9: 1479 
  10: 1424 11: 2260 12: 2405 13: 1664 14: 1411 15: 1397 16: 1397 
Graphics:
  Device-1: NVIDIA TU117M [GeForce GTX 1650 Ti Mobile] 
  vendor: Acer Incorporated ALI driver: nvidia v: 470.57.02 bus-ID: 01:00.0 
  Device-2: AMD Renoir vendor: Acer Incorporated ALI driver: amdgpu 
  v: kernel bus-ID: 05:00.0 
  Device-3: Chicony HD User Facing type: USB driver: uvcvideo bus-ID: 3-3:3 
  Display: x11 server: X.org 1.20.11 driver: loaded: modesetting,nvidia 
  resolution: <missing: xdpyinfo> 
  OpenGL: renderer: NVIDIA GeForce GTX 1650 Ti/PCIe/SSE2 
  v: 4.6.0 NVIDIA 470.57.02 direct render: Yes 
Audio:
  Device-1: NVIDIA vendor: Acer Incorporated ALI driver: snd_hda_intel 
  v: kernel bus-ID: 01:00.1 
  Device-2: AMD Raven/Raven2/FireFlight/Renoir Audio Processor 
  vendor: Acer Incorporated ALI driver: N/A bus-ID: 05:00.5 
  Device-3: AMD Family 17h HD Audio vendor: Acer Incorporated ALI 
  driver: snd_hda_intel v: kernel bus-ID: 05:00.6 
  Sound Server-1: ALSA v: k5.13.5-1-MANJARO running: yes 
  Sound Server-2: JACK v: 1.9.19 running: no 
  Sound Server-3: PulseAudio v: 14.2 running: yes 
  Sound Server-4: PipeWire v: 0.3.32 running: yes 
Network:
  Device-1: Realtek vendor: Acer Incorporated ALI driver: r8169 v: kernel 
  port: 2000 bus-ID: 03:00.0 
  IF: enp3s0 state: down mac: 08:97:98:b0:c4:9b 
  Device-2: Intel Wi-Fi 6 AX200 driver: iwlwifi v: kernel port: 2000 
  bus-ID: 04:00.0 
  IF: wlp4s0 state: up mac: ac:12:03:9a:d4:77 
  IF-ID-1: vmnet1 state: unknown speed: N/A duplex: N/A 
  mac: 00:50:56:c0:00:01 
  IF-ID-2: vmnet8 state: unknown speed: N/A duplex: N/A 
  mac: 00:50:56:c0:00:08 
Bluetooth:
  Device-1: Intel AX200 Bluetooth type: USB driver: btusb v: 0.8 
  bus-ID: 1-4:3 
  Report: rfkill ID: hci0 rfk-id: 3 state: up address: see --recommends 
Drives:
  Local Storage: total: 2.27 TiB used: 1.51 TiB (66.6%) 
  ID-1: /dev/nvme0n1 vendor: Kingston model: SA2000M8500G size: 465.76 GiB 
  temp: 29.9 C 
  ID-2: /dev/sda vendor: Western Digital model: WD20SPZX-21UA7T0 
  size: 1.82 TiB 
Partition:
  ID-1: / size: 444.12 GiB used: 192.66 GiB (43.4%) fs: xfs 
  dev: /dev/nvme0n1p2 
  ID-2: /boot/efi size: 2 GiB used: 288 KiB (0.0%) fs: vfat 
  dev: /dev/nvme0n1p1 
Swap:
  ID-1: swap-1 type: partition size: 19.42 GiB used: 4.2 MiB (0.0%) 
  dev: /dev/nvme0n1p3 
Sensors:
  System Temperatures: cpu: 57.4 C mobo: N/A 
  Fan Speeds (RPM): N/A 
  GPU: device: nvidia screen: :1.0 temp: 46 C device: amdgpu temp: 44.0 C 
Info:
  Processes: 429 Uptime: 37m Memory: 30.74 GiB used: 3.58 GiB (11.6%) 
  Init: systemd Compilers: gcc: 11.1.0 Packages: 1279 Shell: Zsh v: 5.8 
  inxi: 3.3.06 

Note - copy the links, for some reason the forum does not allow me to post neither links, nor attaching the pictures :frowning:
Another note - the issue was present in Ubuntu 20.04 GNOME with 5.11 kernel and the same GPU setup.

If you are a tinker, maybe this could be solution for you:

NVFBC
Captures the framebuffer (front buffer) without any involvement from OpenGL or Direct3D.
Effectively a direct copy of the framebuffer irrespective of which application(s) drew it.
It generally only works sensibly in fullscreen mode. If you render in windowed mode and use NVFBC, it is going to capture the entire screen including your desktop and other unrelated windows.

  1. FBC Patch: GitHub - keylase/nvidia-patch: This patch removes restriction on maximum number of simultaneous NVENC video encoding sessions imposed by Nvidia to consumer-grade GPUs.
  2. OBS FBC Plugin: Files Ā· master Ā· Florian Zwoch / obs-nvfbc Ā· GitLab

I think the framerate in obs will always the fps of a normal video. So 30 fps is quite normal for a video, 60 fps for HD.

1 Like

Thanks @megavolt for the response.
Yes, the OBS states the video FPS and there is the problem, my settings are for 60FPS HD video, but as soon as I start recording DOOM the FPS drops substantially - this problem does not occur on Windows or KDE for example.
Iā€™ll try the solution later in my lunch break, now letā€™s go back to writing some javascript :smiley:

Maybe it is the problem that gnome doesnā€™t use ā€œtriple bufferā€ ? Maybe add this to your xorg.conf:

    Option         "MetaModes" "nvidia-auto-select +0+0 {ForceFullCompositionPipeline=On}"
    Option         "AllowIndirectGLXProtocol" "off"
    Option         "TripleBuffer" "on"
1 Like

The patches broke my nvidia driver and the GUI stopped working, had to enter a new terminal session to revert the changes from the patch.
Then I tried the TripleBuffer option - it didnā€™t make any difference and also DOOM stopped launching :smiley:
I donā€™t know what to do else.
Also just a mention - the issue is still present in discord, so it must be something related to mutter probably?
Edit: I have managed to run DOOM with these settings - no change whatsoever.

okā€¦ maybe it is because you have a hybrid gpu? I patched it without problems and FBC is working.

Graphics:
  Device-1: NVIDIA GP107 [GeForce GTX 1050 Ti] vendor: ZOTAC driver: nvidia 
  v: 470.57.02 alternate: nouveau,nvidia_drm bus-ID: 01:00.0 
  chip-ID: 10de:1c82 class-ID: 0300 
  Display: server: X.Org 1.20.13 compositor: picom v: git-dac85 driver: 
  loaded: nvidia display-ID: :0 screens: 1 
  Screen-1: 0 s-res: 1920x1200 s-dpi: 93 s-size: 524x321mm (20.6x12.6") 
  s-diag: 615mm (24.2") 
  Monitor-1: DP-0 res: 1920x1200 hz: 60 dpi: 94 size: 518x324mm (20.4x12.8") 
  diag: 611mm (24.1") 
  OpenGL: renderer: NVIDIA GeForce GTX 1050 Ti/PCIe/SSE2 
  v: 4.6.0 NVIDIA 470.57.02 direct render: Yes 

I fear also the problem is Mutter. I use DWM as my Main atm and everything works great: https://dwm.suckless.org/ (okok it is a lot of manual configuration, but at the end it works rock stable)

I was kinda annoyed by all these complicated stuff and unforeseen changes fo the DEs GNOME and XFCE which breaks my desktop (i believe it would be same on KDE). Now it is static and just one binary. xD

About Discord: I guess it is because Discord uses Software Encoding on Linuxā€¦