(Optimus) Artifacts and vulkan applications crashing when switching TTY


I’ve encountered a problem where some applications such as web browsers and word processors go completely blank when switching to and from a different Virtual Terminal (TTY Switching), sometimes i can get some visuals back if i scroll pages or do anything that updates the application (i guess) but the issue still persists and some sections remain blank.

I usually use the nvidia-xrun utility to create a new X session that runs completely on the nvidia card, and it runs fine but as soon as i want to switch back to another TTY, being to use the Intel Graphics Desktop or just text mode, and i swich back to the X session running Nvidia, graphical glitches and crashes ensues.

Just to make sure it wasn’t a problem with nvidia-xrun in particular i’ve tried using the official PRIME support but regardless of the method i use to actually activate and use the dGPU the same problem persists.

In terms of games, this switching TTY can consistently crash Vulkan games, most OpenGL applications in my testing do not have this issue, although they stay at a black screen for a while before resuming back to where they were left on.

If i leave vkcube running on a session using the Nvidia card in TTY1, for example, and i switch to TTY2 and then back, the vkcube window will be black, and it won’t close unless i run a command to kill it in a terminal, and the system momentarily hangs when trying to kill it, vkcube throws no errors.

Here’s the nvidia-bug-report.log.gz and a small .gif file to show what’s happening more visually.

nvidia-bug-report.log.gz (282.2 KB)

(Whenever the entire screen turns black means i’ve switched to a different TTY)

Laptop is Aspire V3-572G, with NVIDIA GeForce 840M and
Intel Graphics using Optimus technology, running Arch Linux with kernel 5.9.3-arch1-1, although i should note that this issue was also present in Ubuntu, or at least when i tried it back with 16.04.

Issue still persists from my testing despite having recently received some updates to the Nvidia drivers and vulkan packages, Any insights?