Hangs/Freezes when Vulkan v-sync (VK_PRESENT_MODE_FIFO_KHR) is enabled

I think there is a problem between using PRIME Synchronization (I use a laptop) and the v-sync mode of Vulkan (by using VK_PRESENT_MODE_FIFO_KHR as far as I understand: https://github.com/SaschaWillems/Vulkan/blob/master/base/VulkanSwapChain.hpp#L279).

Reproduction steps:

  1. Install the latest NVIDIA driver on a Intel+NVIDIA (Optimus) laptop.
  2. Enable DRM KMS support (eg. with "nvidia-drm.modeset=1" kernel boot parameter).
  3. Make sure that PRIME Synchronization is enabled (eg. "xrandr –-output --set "PRIME Synchronization" 1")
  4. Launch a Vulkan-based demo or game with v-sync enabled. You can use a very simple demo from this repo: https://github.com/SaschaWillems/Vulkan Just use the "-vsync" option.

Here are two little benchmarks.
One without v-sync:

 leeo   master  ~  git  Vulkan  bin  130  __GL_SHOW_GRAPHICS_OSD=1 ./gears -b
Benchmark finished
device : GeForce GTX 1050 (driver version: 1740931072)
runtime: 10.000
frames : 32517
fps    : 3251.653

And one with v-sync:

 leeo   master  ~  git  Vulkan  bin  __GL_SHOW_GRAPHICS_OSD=1 ./gears -b -vsync
Benchmark finished
device : GeForce GTX 1050 (driver version: 1740931072)
runtime: 10.193
frames : 2
fps    : 0.196

As you can see, a lot of frame are skipped when v-sync is enabled. In fact, the display freezes a lot when I launch a game or a simple demo like this with v-sync enabled.
This happens only when PRIME Synchronization is enabled. I have also tried to use other distribution like Ubuntu, and there is no difference.
The problem is here since several versions of the driver, and I don’t know when it started.

Here is a nvidia-bug-report.log.gz file generated few seconds after the last benchmark: https://framadrop.org/r/Y0TtjckOos#wBH4KYl3i2k32e26oPraFjRiVUk/SFiVqvYThD5vpBE=
nvidia-bug-report.log.gz (1.03 MB)

I tried with other present modes listed here: https://harrylovescode.gitbooks.io/vulkan-api/content/chap06/chap06.html#get-physical-device-surface-present-modes
And the hangs/freezes only occur with the two FIFO modes, namely: VK_PRESENT_MODE_FIFO_KHR and VK_PRESENT_MODE_FIFO_RELAXED_KHR.

If you want to test, you just have to edit the line 319 in the base/VulkanSwapChain.hpp file: https://github.com/SaschaWillems/Vulkan/blob/ef68d59a0b57e8f708e6e93a92daac0c1a4d6cd5/base/VulkanSwapChain.hpp#L319
Don’t forget to recompile and launch a demo without forgetting the “-vsync” option.

amrits of nvidia asked for reproduction steps like yours:
https://devtalk.nvidia.com/default/topic/957814/linux/prime-and-prime-synchronization/post/5298068/#5298068
Maybe send a pm pointing to your info.

Oh, shame on me for not having seen that before! Thanks.
I will send it ASAP.

Using the 415.27 version of the driver, the problem persists. Also, I can reproduce it on a MSI GL63 8RC laptop.

What could I do to help you investigate?

Also happening for me. I’m using my own demo for testing. https://github.com/turol/smaaDemo
It works fine on desktop GPUs (GTX 960, GTX 1060 and AMD RADV) which don’t use PRIME sync.
With PRIME sync enabled trying to move the window, resize it, switch vsync mode (recreating the swap chain) or switch to fullscreen results in temporary system hang. After 20 or so seconds it recovers because a wait for a submit fence times out and my program throws an exception and quits.
Does not happen if using non-FIFO present mode (–novsync option to my program).
Does not happen with PRIME sync disabled.

Asus FX505 laptop.
Driver: 415.27
Distro: Debian Buster (testing)
Kernel: 4.20.0-trunk-amd64 #1 SMP Debian 4.20-1~exp1 (2018-12-24) x86_64 GNU/Linux

lspci |grep VGA
00:02.0 VGA compatible controller: Intel Corporation UHD Graphics 630 (Mobile)
01:00.0 VGA compatible controller: NVIDIA Corporation GP106M [GeForce GTX 1060] (rev a1)

Is the Vulkan fix in the new driver release related to that issue?

“Fixed a bug which could sometimes cause Vulkan applications to lock up the GPU when freeing large chunks of memory on systems with PRIME enabled.”

https://devtalk.nvidia.com/default/topic/1048767/announcements-and-news/-linux-solaris-and-freebsd-driver-418-56-long-lived-branch-release-/post/5322490/#5322490

EDIT: I tested it and apparently not…

Any updates on this bug? I’m experiencing constant GPU hangs (freeze for 5-10 seconds, working for a second, rinse and repeat) with many Vulkan applications.

During a hang I am unable to move the mouse, switch TTYs, nor use SysRq functions. Sound sometimes works, but tends to freeze as well.

After disabling PRIME synchronization the issue is no longer present, but this introduces heavy screen tearing. Disabling vsync also helps, but not every application/game lets you do this.

Applications confirmed to cause the issue:

  • vkcube from the vulkan-tools package
  • Battle.net Launcher (works fine without DXVK, as expected, as then Vulkan isn't being used)
  • Crash Bandicoot N-Sane Trilogy (works fine without DXVK, just disabling Vsync within the game helps, but then it still hangs for a few seconds when minimizing/Alt-tabbing/changing workspaces)

lspci output: https://pastebin.com/UYzZmb92

My specs:

  • Laptop: Clevo N850HK1 with a 1050 Ti Mobile
  • Distro: Manjaro
  • Kernel: 5.1.15-1-MANJARO #1 SMP PREEMPT Wed Jun 26 23:48:19 UTC 2019 x86_64 GNU/Linux
  • Driver: 430.26
  • Displays: Two external monitors, HDMI-1-1 and DP-1-2, both connected through Reverse PRIME

EDIT: Providing an nvidia-bug-report file
nvidia-bug-report.log.gz (1.14 MB)

Sorry for the delay. I’ve been able to reproduce it instantly with my setup. I’ll escalate this bug.

I’m experiencing this too. PPSSPP made me notice that issue is also present on my end

same problem here, but only 430.xx and earlier drivers dont seem to have this issue which for me started with the introduction of the 435.xx series and still happening on 440.xx

prime sync + vulkan = 5 seconds frozen, 1 second not frozen, on a constant loop (not just the app/game but everything is unresponsive)

I’m also having the same issue on 435.21. I see that the bug has been escalated, but that was almost two months ago. Has there been any update?

I’m experiencing this issue as well on driver 440.31. Commenting here so I can get notified of updates.

It is being worked on. We are currently tracking it under bug 200545409.

1 Like

Thanks wpierce that’s great news!

Depending on the vsync level set in EveOnline (interval 1 through to 4 available) with vulkan/dxvk + prime sync + DX11, the higher the internal I set the lower the FPS is limited (good for limiting the impact on gaming laptops and running multiple instances of the game)

However makes the freezing persist for longer depending on the interval level, especially bad when Alt+Tabbing out of the game or switching workspaces in Gnome.

Current setup:

Arch Linux
nvidia-dkms 440.31-3
nvidia-drm.modeset=1 kernel setting added to bootctl
wine-staging
vulkan
dx11
dxvk
prime sync on
eveonline with 64bit client enabled and dx11

Only really became an issue when I purchased this current setup with a 144hz screen:

  • Without vsync the FPS goes to over 300 and heats the laptop up to very high temps with only one game client running (not really an option)
  • With vsync but vulkan disabled the FPS limits to 144 to match the panel but still too much for multiple clients running all at 144 FPS in a laptop environment
  • With vsync + vulkan the FPS limits down depending on interval correctly (1=>144, 2=>~70, 3=>~35, 4=>~19) however long freezing without any response from the system, no TTY switching, everything frozen when switching

I’ve got multiple wine prefixes setup with DX11/DX9 with and without DXVK/Vulkan so please let me know if there is anything I can test or help with.

This is still a problem in the 440 series. Fortunately most DXVK applications can have this issue mitigated by forcing vsync off with a config file, and letting a compositor like picom do vsync. But any pure Vulkan applications that force vsync on are going to cause a bad time.

The main reason for me to use a setup with PRIME driving the entire X server is because outputs wired to the nvidia card are inaccessible using a PRIME Offload configuration. If that were fixed, this issue might not be as important.

@TiZ_EX1 How do I disable vsync in DXVK? I can disable PRIME sync entirely, but that causes awful screen tearing.

Create a file with the contents:

dxgi.syncInterval = 0
d3d9.presentInterval = 0

I like to put it in $XDG_CONFIG_HOME/dxvk.conf. Then in your ~/.profile, export DXVK_CONFIG_FILE="/path/to/your/dxvk.conf"

Hello. has there been any updates on this bug? Thank you

I’m seeing this as well when I’m running anything with wine. Is there any movement on this? Is there a known driver version I can downgrade to or something?