Repository: godot
Issue: System hangs when using Godot 4.1.2 / 4.2 or when stopping / restarting the game
Labels: platform:linuxbsd,topic:editor,needs testing

### Tested versions

- 4.1.2 stable
- 4.2 stable

### System information

Linux - Kernel 5.19 - Ubuntu 22.10 - Godot 4.1.2 stable / 4.2 stable - Forward+

### Issue description

When starting Godot 4.2 or 4.1.2, after a while, the system hangs although the mouse still moves (but it's managed by the GPU so that would be expected) although it moves only within the first screen and it doesn't get on the second one.]
It also hangs randomly in the same way when, after starting the game I work on, I stop it or restart it.

This happens even faster when Google Chrome is opened, but happens anyway without it.

This is my HW configuration
- AMD Ryzen 5900X (recently upgraded but was happening with my previous AMD Ryzen 3700X as well)
- 128GB @ 3200mhz of ram
- ASRock Rack X470D4U
- Nvidia Geforce 4070
- PSU 800w
- 2 monitors (1 4K over DP and 1 Full HD over HDMI)
- No overcloking

No relevant logs before the crash about being spammed by these 2 particolar messages
```
Dec  6 22:48:56 daalbano-lnx-pc gnome-shell[3360]: Window manager warning: Buggy client sent a _NET_ACTIVE_WINDOW message with a timestamp of 0 for 0x5a00004
Dec  6 22:48:57 daalbano-lnx-pc gnome-shell[3360]: Window manager warning: Invalid WM_TRANSIENT_FOR window 0x0 specified for 0x5a0028f.
```

Happens much more often with Godot 4.2 than with 4.1.2, with Godot 4.2, with Google Chrome opened it happens after 5 / 10 minutes of working with it, otherwise it might take 30 minutes or more.

My machine is running Ubuntu 22.10 with the latest kernel available and the latest GPU modules available from NVIDIA.

```
$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 22.10
Release:	22.10
Codename:	kinetic

$ uname -a
Linux daalbano-lnx-pc 5.19.0-46-generic #47-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 16 13:30:11 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

$ dpkg -l | grep " nvidia-" | awk '{ print $2 }' | grep -e "^nvidia"
nvidia-compute-utils-535
nvidia-driver-535
nvidia-firmware-535-535.54.03
nvidia-kernel-common-535
nvidia-kernel-source-535
nvidia-opencl-dev:amd64
nvidia-prime
nvidia-settings
nvidia-utils-535

$ nvidia-smi  # without godot running
Thu Dec  6 22:58:27 2023       
+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 535.54.03              Driver Version: 535.54.03    CUDA Version: 12.2     |
|-----------------------------------------+----------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |         Memory-Usage | GPU-Util  Compute M. |
|                                         |                      |               MIG M. |
|=========================================+======================+======================|
|   0  NVIDIA GeForce RTX 4070        Off | 00000000:2B:00.0  On |                  N/A |
|  0%   44C    P5              16W / 215W |    657MiB / 12282MiB |      7%      Default |
|                                         |                      |                  N/A |
+-----------------------------------------+----------------------+----------------------+
                                                                                         
+---------------------------------------------------------------------------------------+
| Processes:                                                                            |
|  GPU   GI   CI        PID   Type   Process name                            GPU Memory |
|        ID   ID                                                             Usage      |
|=======================================================================================|
|    0   N/A  N/A      4956      G   /usr/lib/xorg/Xorg                          428MiB |
|    0   N/A  N/A      5081      G   /usr/bin/gnome-shell                         79MiB |
|    0   N/A  N/A      7753    C+G   ...349955957,603834613571911190,262144      107MiB |
+---------------------------------------------------------------------------------------+

$ nvidia-smi  # with godot running
Thu Dec  6 22:59:15 2023       
+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 535.54.03              Driver Version: 535.54.03    CUDA Version: 12.2     |
|-----------------------------------------+----------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |         Memory-Usage | GPU-Util  Compute M. |
|                                         |                      |               MIG M. |
|=========================================+======================+======================|
|   0  NVIDIA GeForce RTX 4070        Off | 00000000:2B:00.0  On |                  N/A |
|  0%   48C    P5              21W / 215W |   3415MiB / 12282MiB |      5%      Default |
|                                         |                      |                  N/A |
+-----------------------------------------+----------------------+----------------------+
                                                                                         
+---------------------------------------------------------------------------------------+
| Processes:                                                                            |
|  GPU   GI   CI        PID   Type   Process name                            GPU Memory |
|        ID   ID                                                             Usage      |
|=======================================================================================|
|    0   N/A  N/A      4956      G   /usr/lib/xorg/Xorg                          557MiB |
|    0   N/A  N/A      5081      G   /usr/bin/gnome-shell                         87MiB |
|    0   N/A  N/A      7753    C+G   ...349955957,603834613571911190,262144       91MiB |
|    0   N/A  N/A     29487    C+G   ...odot/Godot_v4.2-stable_linux.x86_64     2628MiB |
+---------------------------------------------------------------------------------------+

$ nvidia-smi  # with godot running and the game running
Thu Dec  6 23:02:27 2023       
+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 535.54.03              Driver Version: 535.54.03    CUDA Version: 12.2     |
|-----------------------------------------+----------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |         Memory-Usage | GPU-Util  Compute M. |
|                                         |                      |               MIG M. |
|=========================================+======================+======================|
|   0  NVIDIA GeForce RTX 4070        Off | 00000000:2B:00.0  On |                  N/A |
|  0%   49C    P3              37W / 215W |   4758MiB / 12282MiB |     36%      Default |
|                                         |                      |                  N/A |
+-----------------------------------------+----------------------+----------------------+
                                                                                         
+---------------------------------------------------------------------------------------+
| Processes:                                                                            |
|  GPU   GI   CI        PID   Type   Process name                            GPU Memory |
|        ID   ID                                                             Usage      |
|=======================================================================================|
|    0   N/A  N/A      4956      G   /usr/lib/xorg/Xorg                          596MiB |
|    0   N/A  N/A      5081      G   /usr/bin/gnome-shell                         92MiB |
|    0   N/A  N/A      7753    C+G   ...349955957,603834613571911190,262144      140MiB |
|    0   N/A  N/A     29487    C+G   ...odot/Godot_v4.2-stable_linux.x86_64     2301MiB |
|    0   N/A  N/A     29775    C+G   ...odot/Godot_v4.2-stable_linux.x86_64     1570MiB |
+---------------------------------------------------------------------------------------+

```

### Steps to reproduce

- Open Godot 4.2
- Open Chrome (lots of tabs)
- Use Godot 4.2

### Minimal reproduction project (MRP)

I tried with a blank project as well and the issue is triggered anyway therefore I am not attaching anything.