-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
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
Labels with lots of text very slow in Godot 4 #77268
Comments
cc @bruvzg ? |
Can you check this when using the fallback text server? To do so, compile the editor with the |
Can you compare it to using multiple labels totalling the same amount of text? (Both to pinpoint some details and for workarounds) |
The size keeps growing to contain all visible text. Increase the height of one line each time. Lines 275 to 277 in 809a982
Lines 405 to 407 in 809a982
There seems to be a logic bug in the following code, it's not clear to me why there is a break, it doesn't seem necessary. Lines 291 to 296 in 809a982
|
I hava a similar problem. It takes a lot of time when add_child a scene with labels. |
This issue does not occur if the initial |
This is a great catch! I can confirm that it fixes the speed issue. It can be expanded to more complex cases as well. In my case I need the label to be inside a ScrollContainer, and I'm reading the text from files so I don't know exactly how large the label will be.
I managed to find this solution, expanding off of yours:
Step 1 and 2 go in the Label's _ready function, step 3 goes in the CreditsScene's _ready. If you do it all in the same _ready function you don't get the performance improvement. The Label's _ready looks like this:
and the CreditsScene's _ready looks like this:
|
I can't reproduce this on both 4.0.3 and 4.1.dev 33957ae with the linked MRP for Godot 4 (Linux). The label already appears to be sized to contain all lines of text, so it starts very fast. |
Maybe your computer is too powerful. 😄 |
I mean, I don't even see a difference of 0.1 seconds between |
diff --git a/game.tscn b/game.tscn
index 1953d25..9d20ed0 100644
--- a/game.tscn
+++ b/game.tscn
@@ -13,7 +13,7 @@ layout_mode = 0
offset_left = 16.0
offset_top = 13.0
offset_right = 1133.0
-offset_bottom = 623.0
+offset_bottom = 15639.0
text = "Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/ I'm guessing the file might have been modified. If it is modified as above, there is no difference. |
This was indeed the issue. If I ensure this change isn't made to the scene file, I can reproduce this issue. See #77280 (comment) for results. Apologies for the false alarm 🙂 |
Godot version
4.0.3 stable
System information
Windows 10, i5 8600, RTX3060, 64 GB ram
Issue description
In Godot 4, labels with lots of text cause scenes to load extremely slowly, both in the editor and in-game.
I measured a few game starts with different amounts of text in a label:
In Godot 3, the startup times for all test lengths was almost instantaneous.
The text I used was multiple copies of the license agreement for Google's Roboto font. A "credits" page on a game could easily get well above this length.
Looking at a scatter plot with a best fit, it's pretty clearly increasing at around n^2:
Results are the same whether I'm using the built-in font or a custom font, and results are similar across all renderers. Settings like text wrapping don't seem to affect it either.
Steps to reproduce
Create a scene, add a label to that scene, and fill the label with a large amount of text. Try to launch the game and load that scene.
Minimal reproduction project
Godot3LargeLabel.zip
Godot4LargeLabel.zip
The text was updated successfully, but these errors were encountered: