-
-
Notifications
You must be signed in to change notification settings - Fork 20.2k
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
Setting a text that contains emojis to a textedit is slow #88809
Comments
Can you please test this with 4.2.1 or 4.2.2.rc1? Your version is no longer supported and this might already have been fixed |
I'm using 4.2.1 and the issue exists there, I'll double check 4.2.2.rc1 and report back. |
Added a reference to 4.2.1 to the top. |
Same issue in 4.2.2.rc1. (In case it matters, I tested the standard, non-.net versions.) |
Have not tested anything, but the test without emojis is a bit skewed since |
The function to create the text is only called a single time during ready. What is slow is the setting of the text in |
Ok, that's silly then. Since the text remains unchanged, setting it every |
extends Node
func _generate_text(characters:Array, amount = 200):
var result = ""
for i in amount:
result += characters.pick_random()
return result
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
_set_with_emojis()
_set_without_emojis()
_set_with_emojis_no_newline()
_set_without_emojis_no_newline()
func _set_with_emojis():
%TextEdit.text = _generate_text(["🔴\n", "🟢\n", "⚡\n", "↪️\n"])
func _set_without_emojis():
%TextEdit.text = _generate_text(["AAA\n", "BBB\n", "CCC\n", "DDD\n"])
func _set_with_emojis_no_newline():
%TextEdit.text = _generate_text(["🔴", "🟢", "⚡", "↪️"])
func _set_without_emojis_no_newline():
%TextEdit.text = _generate_text(["AAA", "BBB", "CCC", "DDD"]) |
Interesting how just adding newlines makes it an order of magnitude slower... |
Can you test a build that uses the fallback text server instead of the advanced text server? To do so, compile from source with the This disables support for right-to-left typesetting and complex scripts, but emoji support should remain intact. |
Built with I profiled a bit with VS, and a large amount of time is spent here, regardless of which text server is used: godot/platform/windows/os_windows.cpp Line 1114 in bb6b06c
~33% of all CPU time is spent on line 1191 |
This is likely due to the same cause as #83688. |
Tested versions
System information
Godot v4.2.stable.mono - Windows 10.0.22631 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 4080 (NVIDIA; 31.0.15.5123) - AMD Ryzen 9 7950X3D 16-Core Processor (32 Threads)
Issue description
I have a
TextEdit
node that I pre-fill with some text that contains a range of emojis. In my example I set about 300 lines of text each line containing an emoji. Setting this text of 300 lines with emojis to thetext
property of theTextEdit
takes about 16-18ms on my machine. If I remove the emojis from the text, the same operation only takes about 2-3ms on my machine.Steps to reproduce
In the example project I have this script which will produce a text at the start and then try to set it every frame:
You can use the alternative line to produce a text without emojis. Profile each variant to see the difference in performance.
Minimal reproduction project (MRP)
emoji_reproducer.zip
The text was updated successfully, but these errors were encountered: