Huge lag spikes on 2D scene with Godot 4.0

godot 4.1 & 4.3

Hello,

Since we upgraded our 2D project from Godot 3.0 to 4.0, when we run it we get frequent fps drops, with the screen freezing about every second, even if the game basically does nothing : the scene in question just consists in an interface with various sprites and control nodes.

The problem does not occur on every machine : on a machine with recent specs, everything runs fine, it happens on a relatively old machine (Nvidia GTX 970, intel i7-8700K, 32G ram). Also, it only happens on forward+ mode, on compatibility mode, everything runs fine at 60 fps, but we cannot just set the project to compatibility mode as we would like to use particles effects that are only available on forward+ mode. The editor itself also runs fine, the lag spikes only happen when running the game.

The profiler is quite unhelpful : it shows the spikes with process time taking a very long time, but I did not manage to get more information about what might cause the spikes:

The visual profiler does not seem to show any issue:

Where it gets strange, is that I tried to isolate the problem by deleting nodes from the scene until I found which ones might cause the issue, but here the behavior gets inconsistent.

Basically what I did was removing nodes from the scene one by one, until I found a node, let’s call it node A, whose removal makes the spikes disappear. It is always binary : with node A → huge lag spikes, without node A → perfect 60 fps.
But when restarting the editor, or changing the scene (by restoring other deleted nodes), node A might no longer cause any issue, and it is now another node whose removal fixes the lag spikes.

Also, each of these “culprit” nodes are nothing special, sometimes it is an animated sprite that is not even visible, or a script node that is not doing anything intensive, so it is not something whose removal should cause such a drastic performance change, but just removing it may cause the game to go from laggy to crisp 60 fps.

Do you have any suggestion about anything else I could try to find the source of the problem?

English is not my first language, so do let me know if my message is unclear or you need more information, and thanks in advance for any help!