Repository: godot
Issue: Reduced tween performance when FileDialog in tree
Labels: bug,confirmed,needs testing,topic:gui,topic:animation,performance

### Tested versions

- Reproducible in 4.3.stable, 4.1.stable

### System information

Arch Linux, Ryzen 5 5600X

### Issue description

I'm currently writing a program that uses Godot as a UI toolkit, and it has quite extensive dynamic theming. As a result, there is/was a large use of tweens between theme overrides to smoothly transition between colours on UI objects:

```gdscript
tween.tween_method(func(x): $Install.add_theme_color_override("font_color",x),base_theme.get_color("font_color","ImportantButton"),Color(pallete["light"]),0.2)
tween.tween_method(func(x): $Verify.add_theme_color_override("font_color",x),base_theme.get_color("font_color","Button"),Color(pallete["lightfg"]),0.2)
tween.tween_method(func(x): $Verify.add_theme_color_override("font_hover_color",x),base_theme.get_color("font_hover_color","Button"),Color(pallete["lightfg"]),0.2)
...
tween.tween_property($BottomPanel.get_theme_stylebox("panel"),"bg_color", Color(pallete["main"]), 0.2)
tween.tween_property($TopPanel.get_theme_stylebox("panel"),"bg_color", Color(pallete["dark"]), 0.2)
tween.tween_property($SidePanel.get_theme_stylebox("panel"),"bg_color", Color(pallete["secondary"]), 0.2)
tween.tween_property($Install.get_theme_stylebox("normal"),"bg_color", Color(pallete["accent"]), 0.2)
```
This worked fine, and was generally performant - however when I added a `FileDialog` node (not doing anything with it yet, just its presence in the tree) it seemed to drastically reduce performance. The built-in profilers weren't of much help, they said that it did take >238ms, however it said >100ms without the `FileDialog`. What I found worked was the following:
```gdscript
func test(x):
	print("%s,%s" % [x,Time.get_ticks_msec()])
	counter += 1
...
tween.tween_method(test,0.0,1.0,0.2)
```
Since all of the tweens seemed to be consistent in their poor performance, this would see what the difference in performance was more objectively - the more values printed before 1, the smoother in theory it will be.
Main project without ``FileDialog``:
```
0.05208333581686,11222
0.16564667224884,11253
0.36402332782745,11285
0.51945328712463,11316
0.67405831813812,11346
0.8277433514595,11377
0.98136335611343,11408
1,11445
```
Main project with ``FileDialog``:
```
0.10600939393044,5991
0.66442108154297,6094
1,6194
```
The amount of values passed has decreased by over half - which leads to stuttery transitions. 



### Steps to reproduce

One of the issues with this bug is that its more obvious the more complex a program is. A MRP is, ideally, the exact opposite of a complex program. What I've attached is my attempt to get as small as possible whilst still making the issue visible.  This doesn't have as pronounced performance loss, however it's still measurable by the print technique as specified above. 

1) Open the project
2) Run it. Use the two mandrill buttons on the side to switch between themes, and look at the console output.
3) Close it and add a FileDialog node.
4) Run it again and notice how there's less iterations, and that the smoothness in the logo and colour transitions is worse.

### Minimal reproduction project (MRP)

[mrp.zip](https://github.com/user-attachments/files/17069066/mrp.zip)