godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.15k stars 21.19k forks source link

Input lag after switching between multiple game instances #92954

Closed MichaelDawe closed 5 months ago

MichaelDawe commented 5 months ago

Tested versions

Reproducible in 4.3.beta1 Not reproducible in 4.3.dev6, 4.2.2.stable

System information

Godot v4.3.beta1 - Windows 10.0.22000 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3060 Ti (NVIDIA; 31.0.15.5222) - 11th Gen Intel(R) Core(TM) i5-11400 @ 2.60GHz (12 Threads)

Issue description

When running heavy code in a node's _process() function the input response is lagging well below FPS after switching between multiple local instances. This applies to all input methods, both those captured in custom code and built-in systems.

Expected behavior: Input should not lag significantly below FPS.

Notes: Exporting the project and running the executables reduces the effect but it is still present. This is not affected by the renderer used. The issue may be affected by the power of the system its run on, change the loopmax variable in the script and experiment. While this won't be an issue for most users, those who are developing and testing multiplayer games on local machines will be affected.

Steps to reproduce

Create a project with any form of input and feedback to the user, UI buttons will suffice. Add heavy code to the _process() function, a loop will suffice. Launch 2 instances (open a second editor instance and run the game from the launcher, just launching a second instance of the editor will suffice). Hover over the buttons, then switch between windows and hover over them again, now there is significant lag.

Minimal reproduction project (MRP)

new-game-project.zip

Avantir-Chaosfire commented 5 months ago

Do you know how long the code in your _process loop is taking? A measurement in milliseconds would be helpful.

MichaelDawe commented 5 months ago

Do you know how long the code in your _process loop is taking? A measurement in milliseconds would be helpful.

Barely noticeable at 10ms, UI becomes basically unusable at 20ms.

Replace the while loop in the script with OS.delay_msec(15) and change the value.

This is a much better approach than my original while loop in any case, thanks for your comment!

matheusmdx commented 5 months ago

This looks very similar to #92759 and #92307. Can you download the artifacts from pr #92742 and confirm if your issue is already solved?

image

MichaelDawe commented 5 months ago

Yes, the issue doesn't occur in that version!

matheusmdx commented 5 months ago

Great, in this case you can close the issue, the 4.3 beta 2 will come with this fix applied