godotengine / godotengine/godot
Setting a text that contains emojis to a textedit is slow
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
- v4.2.stable.mono.official [46dc27791]
- v4.2.1.stable.mono.official [b09f793f5]
### 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 the `text` property of the `TextEdit` 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:
```gdscript
extends Control
@onready var text_edit = $TextEdit
var text:String
func _ready():
text = make_300_lines()
func _process(delta):
text_edit.text = text
func make_300_lines():
var emojis = ["🔴", "🟢", "⚡", "↪️"]
var result:String = ""
for i in 300:
# use the following line to get a text without emojis
# result += " this is a line " + "[c]" + "\n"
# this will produce a text with emojis
# comment it to use the other line
result += " this is a line " + emojis.pick_random() + "\n"
return result
```
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](https://github.com/godotengine/godot/files/14396079/emoji_reproducer.zip)
Contributor guide
Research direction
Start with the provided emoji_reproducer.zip and run the TextEdit script that assigns 300 lines every frame. Profile the emoji and non-emoji variants to identify where the extra time is spent. Done means the emoji case is measurably closer to the non-emoji case without breaking TextEdit behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- frontend, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100