godotengine / godotengine/godot
Alt-tabbing on X11 is very slow when a Godot editor or project is open
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
- Reproducible in: 4.0.stable, 4.3.stable, 4.4.beta 93d270693
### System information
Godot v4.4.beta (93d270693) - Fedora Linux 41 (KDE Plasma) on X11 - X11 display driver, Multi-window, 1 monitor - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 4090 (nvidia; 565.77) - 13th Gen Intel(R) Core(TM) i9-13900K (32 threads)
### Issue description
Alt-tabbing on X11 is very slow when a Godot editor or project is open.
This occurs regardless of whether compositing is enabled or not, and affects all rendering methods (although Forward+/Mobile seems to be more heavily affected than Compatibility). This affects any project as long as it renders at a high enough framerate.
In this video, I start alt-tabbing as soon as the previous dialog is gone. Notice how alt-tabbing is much faster near the end of the video after I close the empty project:
https://github.com/user-attachments/assets/7f79ece4-3370-487b-be32-1fa7414e5f0e
Some things that improve the situation:
- Disabling V-Sync (even if you cap FPS to the monitor refresh rate).
- Using a low **Max FPS** cap in the project settings like `10`.
- Enabling low-processor mode and ensuring nothing causes unnecessary redrawing in the project. (This is not viable in most games.)
I suspect X11 is getting spammed with API calls when Godot is open, which leads to these performance issues. I haven't tested this on Wayland yet.
Godot 3.x is also affected (and is less affected with low-processor mode or V-Sync off), but much less so than 4.x. It's affected to a similar rate as various games I've tested like Cube 2: Sauerbraten, so I expect this to be par of the course for KDE's task switcher.
Note that if you intend to test this locally, KDE's task switcher has an intentional delay that means it'll only appear after holding Alt + Tab for long enough. This is why it never appears instantly, but switching between the last two tasks can be done quickly as it doesn't need to spawn the task switcher dialog for this to happen. This is different to Windows's task switcher which appears instantly.
### Steps to reproduce
- Run any project and try to alt-tab on Linux/X11.
### Minimal reproduction project (MRP)
[test_empty_project.zip](https://github.com/user-attachments/files/18897018/test_empty_project.zip)
Contributor guide
Research direction
Reproduce the issue with the provided empty project on Fedora Linux 41 using the X11 display driver, then compare Alt-Tab behavior across V-Sync, Max FPS, low-processor mode, and rendering methods. Trace the high-framerate path responsible for repeated X11-related work; done means Alt-Tab becomes responsive without requiring users to disable V-Sync or cap projects to 10 FPS.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, linux
- Domain
- desktop-dev, operating-systems, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100