Screen image distortion on resume

Periodically on resume (from suspend) I encounter a screen image distortion chaos: display is mostly blacked, shaking and blinking with fragments of windows, some windows are upside down, no chance to enter command or focusing on some window.
Had to only reboot, which helps but for me, with a programmer laptop for remote work, each reboot/restart is quite undesirable and painful: 1) all activated virtual environments are disrupted; 2) all docker containers are disrupted with lost of cached data structures (gigabytes in size) - losing extraction/loading/transformation phase in ETL workflow.
I also heard about nvidia flipping setting could potentially get in a way: but switching it on/off does not help.


Details:

$ inxi -b
System:
  Host: roman-pc Kernel: 5.16.2-3-rt19-MANJARO arch: x86_64 bits: 64
    Desktop: KDE Plasma v: 5.24.4 Distro: Manjaro Linux
Machine:
  Type: Laptop System: Dell product: G3 3579 v: N/A
    serial: <superuser required>
  Mobo: Dell model: 04R93M v: A00 serial: <superuser required> UEFI: Dell
    v: 1.2.1 date: 07/18/2018
CPU:
  Info: 6-core Intel Core i7-8750H [MT MCP] speed (MHz): avg: 800
    min/max: 800/4100
Graphics:
  Device-1: Intel CoffeeLake-H GT2 [UHD Graphics 630] driver: i915 v: kernel
  Device-2: NVIDIA GP106M [GeForce GTX 1060 Mobile] driver: nvidia
    v: 510.60.02
  Device-3: Realtek Integrated Webcam type: USB driver: uvcvideo
  Display: x11 server: X.Org v: 1.21.1.3 with: Xwayland v: 22.1.1 driver:
    X: loaded: modesetting,nvidia gpu: nvidia,nvidia-nvswitch
    resolution: 1920x1080~60Hz
  OpenGL: renderer: NVIDIA GeForce GTX 1060/PCIe/SSE2
    v: 4.6.0 NVIDIA 510.60.02

Demonstration video: https://drive.google.com/file/d/1c7KltbDYZ7n-R_2JwsFTUeFMMlT6yP8w/view?usp=sharing

disable compositor with alt + shift +f12 suspend your pc, wake it up and check if you have screen issues

Tried that. No image distortion happened; as for screen issues which I noticed - windows have lost their background transparency.

yes you can enable the compositor again, by pressing the same shortcut: alt + shift + f12 …now go to system settings/ compositor and uncheck 'allow applications to block compositing`, click apply, just in case reboot and try again

It was already turned off before I did the mentioned approach.

you can try ‘tweaks’ from this link and see
if you still have issues, try creating a new user and check with it

link is dead

try this link

After adding Device section in xconfig file and adding kwin.sh - the GUI does not load on reboot.
When switching to 2nd TTY on boot:
startx (as well as sddm) fails with Unable to connect to X server ...
startplasma_x11 fails with $DISPLAY is not set ...

Tried mhwd -a pci nonfree 0300 (with reinstalling nvidia-utils) - did not help.
The only startplasma_wayland allowed me to load GUI but that seems a limited workaround (lost/absent functionality/settings is clearly seen when opening nvidia-settings window)

$ mhwd -l
> 0000:3b:00.0 (0200:10ec:8168) Network controller Realtek Semiconductor Co., Ltd.:
--------------------------------------------------------------------------------
                  NAME               VERSION          FREEDRIVER           TYPE
--------------------------------------------------------------------------------
         network-r8168            2016.04.20                true            PCI


> 0000:01:00.0 (0302:10de:1c20) Display controller nVidia Corporation:
--------------------------------------------------------------------------------
                  NAME               VERSION          FREEDRIVER           TYPE
--------------------------------------------------------------------------------
video-hybrid-intel-nvidia-prime            2021.12.18               false            PCI
video-hybrid-intel-nvidia-470xx-prime            2021.12.18               false            PCI
video-hybrid-intel-nvidia-390xx-bumblebee            2021.12.18               false            PCI
          video-nvidia            2021.12.18               false            PCI
    video-nvidia-470xx            2021.12.18               false            PCI
    video-nvidia-390xx            2021.12.18               false            PCI
           video-linux            2018.05.04                true            PCI


> 0000:00:02.0 (0300:8086:3e9b) Display controller Intel Corporation:
--------------------------------------------------------------------------------
                  NAME               VERSION          FREEDRIVER           TYPE
--------------------------------------------------------------------------------
video-hybrid-intel-nvidia-prime            2021.12.18               false            PCI
video-hybrid-intel-nvidia-470xx-prime            2021.12.18               false            PCI
video-hybrid-intel-nvidia-390xx-bumblebee            2021.12.18               false            PCI
           video-linux            2018.05.04                true            PCI
     video-modesetting            2020.01.13                true            PCI
            video-vesa            2017.03.12                true            PCI

so delete the kwin.sh
and post output from:
find /etc/X11/ -name "*.conf"

$ find /etc/X11/ -name "*.conf"
/etc/X11/xorg.conf.d/20-nvidia.conf
/etc/X11/xorg.conf.d/90-mhwd.conf
/etc/X11/xorg.conf.d/optimus.conf
/etc/X11/xorg.conf.d/00-keyboard.conf
/etc/X11/mhwd.d/nvidia.conf
/etc/X11/xorg.conf

P.S. when messing with “device section” I was relying on NVIDIA/Troubleshooting - ArchWiki

so delete this:
sudo rm /etc/X11/xorg.conf
reboot and see if you can normally boot, if not post again output from:
find /etc/X11/ -name "*.conf"

Deleted+rebooted, did not help.
The output now is the same excluding deleted item /etc/X11/xorg.conf

so try removing also this:
sudo rm /etc/X11/xorg.conf.d/20-nvidia.conf
reboot
did you have installed optimus before you made those changes?

it’s installed automatically with mhwd
Had some troubles messing with prime and bumblebee on hybrid configuration in previous years.

i mean optimus-manager package, because theres a config from it in the x11 folder…

$ sudo pacman -Q optimus-manager
error: package 'optimus-manager' was not found

very interesting that you have it there, so remove the conf also:
sudo rm /etc/X11/xorg.conf.d/optimus.conf
reboot

Nothing helped. Strange.

so remove also this one:
sudo rm /etc/X11/mhwd.d/nvidia.conf
then reboot
did you also removed this: 20-nvidia.conf