Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scene editing is slow in complex projects #60127

Closed
KoBeWi opened this issue Apr 11, 2022 · 11 comments · Fixed by #60789
Closed

Scene editing is slow in complex projects #60127

KoBeWi opened this issue Apr 11, 2022 · 11 comments · Fixed by #60789

Comments

@KoBeWi
Copy link
Member

KoBeWi commented Apr 11, 2022

Godot version

3.5 beta3

System information

Windows 10 x64

Issue description

I recently noticed that the scene editing is much less smooth than it used to be. The difference is so noticeable that I was able to record it.

Here's removing and adding a node in 3.4 beta6
Godot_v3 4-beta6_win64_EUxHzV4cwV
Literally instant.

And the same operation in 3.5 beta3:
godot_z60H39d09A
The 1 second lag after every action is so visible that it hurts.

I didn't test between which versions exactly this started happening.
Also doesn't seem to happen in 4.0 alpha6.

Steps to reproduce

  1. Have a relatively big scene
  2. Do anything that changes scene tree, like reparenting a node or changing name

Minimal reproduction project

No response

@Listwon
Copy link
Contributor

Listwon commented Apr 11, 2022

Will you have some time to test it at least in beta1 and beta2? https://downloads.tuxfamily.org/godotengine/3.5/

@KoBeWi
Copy link
Member Author

KoBeWi commented Apr 11, 2022

Same issue in beta1.

@Torguen
Copy link

Torguen commented Apr 12, 2022

The action consists simply of deleting and a node and then clicking on "undo"?.
I can't reproduce that in beta 3.

2022-04-12.11-14-05.mp4

However, I did notice that when a script has many features.
So you select the script and it takes a second to load, but I don't know if that's normal.
In this video you can see when I select the "personaje" script, the other scripts are instant but the "personaje" takes 1 second to open.

2022-04-12.11-18-11.mp4

@KoBeWi
Copy link
Member Author

KoBeWi commented Apr 12, 2022

The issue happens on big scenes. Also I think it might be related to instances. When you have tens of instances, the performance is abysmal. But I have a GUI scene with over a hundred of nodes, without any instance, and there is 0 delay (just like in 3.4).

@lawnjelly
Copy link
Member

Probably needs an MRP to bisect / profile (unless a contributor knows they have worked on something that might have been a likely suspect).

@KoBeWi
Copy link
Member Author

KoBeWi commented Apr 16, 2022

I tried to make an MRP, but obviously (bruh) the issue doesn't in a minimal project. I created a KinematicBody2D scene with a few sprites and an Area2D child, which is similar to what I typically use and no freezes even with a few hundred instances.

Maybe it's related to complexity of the project, like number of class names etc.

@Calinou
Copy link
Member

Calinou commented Apr 16, 2022

Maybe it's related to complexity of the project, like number of class names etc.

You can use a shell script to create a lot of named classes: #27333 (comment)

@KoBeWi
Copy link
Member Author

KoBeWi commented Apr 16, 2022

Still no luck. I created a bunch of classes, with multiple levels of inheritance, and extended one of them in the scene. Then multiplied the number of instances on my test scene and also made it very deep. After that switching scenes became very slow and the editor started lagging, but duplicating nodes was still instant.

So instead I went to my main project and created empty scene with a few instances. The issue appeared with just 10 of them. So I started stripping the instanced scene. It was still causing freezes after removing everything except the root node. So I removed script from the root node and it helped. So then I restored the scene and tinkered with the script. I cleared it completely and removed a few levels of inheritance, leaving just extends KinematicBody2D as a sole line. The issue was still noticeable (i.e. duplicating it on the test scene was still slow). So I removed the script and created a new one, exactly the same, and there was no slowdown. So likely something was cached in the script instance (maybe preloads? singleton references?). I'm lost ;_;

EDIT:
Also this makes me think that the issue might exist in 4.0 too. The project I tested with was rather average than "complex".

@KoBeWi
Copy link
Member Author

KoBeWi commented Apr 28, 2022

Bisected to #54614
CC @aaronfranke

EDIT:
The PR adds limit_length() method, so previous commits might break some script and mask the issue. Still testing.

EDIT2:
Yes, it's unrelated. Also I after changing limit_length() back to clamped() in all scripts I can reproduce the issue in 3.4, so...

EDIT3:
Went back to 3.2.3 and still the same issue. Looks like it's not a regression :/

@KoBeWi KoBeWi removed the regression label Apr 29, 2022
@KoBeWi KoBeWi changed the title Performance degradation in scene editing between 3.4 and 3.5 Scene editing is slow in complex projects Apr 29, 2022
@KoBeWi
Copy link
Member Author

KoBeWi commented May 4, 2022

Found a potential culprit. This is caused by updating scene tree. The editor has to set icon for every node. In case of scripts, the script is parsed in search of icon. I don't know how it works internally, but seems like each script is parsed every time the editor needs to get the icon and in case of references between scripts, preloads etc, this becomes extremely slow.

Here:

String GDScriptLanguage::get_global_class_name(const String &p_path, String *r_base_type, String *r_icon_path) const {

I added return ""; after this line and the issue disappears.

We should cache the icons, so they can be easily accessed without parsing the script more than once.

@Torguen
Copy link

Torguen commented May 4, 2022

Everything that is done to optimize that will be good.
I have a small scene and when I switch scene tabs to open this scene there is an absurd delay as the scene is quite small.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants