godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
87.39k stars 19.64k forks source link

Godot 4 for Linux runs noticeably slower with non-Latin script language than with latin script language #83688

Open traditionalgithub opened 9 months ago

traditionalgithub commented 9 months ago

Godot version

v4.1.2.stable.official [399c9dc39]

System information

Godot v4.1.2.stable - Pop!_OS 22.04 LTS - X11 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1060 (nvidia; 535.113.01) - Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz (8 Threads)

Issue description

On Godot 4 Linux runs noticeably slower with non-Latin script language (e.g. CJK, Georgian, Thai and so on) than with Latin script language (English, Spanish, Portuguese and so on). As can be compared in the two videos below (English and Traditional Chinese comparison). vokoscreenNG-2023-10-21_01-37-57.webm vokoscreenNG-2023-10-21_01-38-21.webm

The speed loss may be different for different distributions (even for those based on Ubuntu, the speed loss would be different), but is probably more significant on those with Language Support of "multiple language support at once" (the Firefox style language support that applies the translation of the topmost available language of a ordered list, as pictured below). image

The tests and comparison can be made on live-usbs and the running time and speed loss is almost the same.

The time it takes open an empty project in Fedora is around 8-9 seconds, and is about half a minute if on Zorin OS (which is also an Ubuntu-based distribution that features the Firefox style language support mentioned above).

I suspect that the cause of this situation is the same as issue #82063. Issue #82105 seems to be related too.

Steps to reproduce

Create an empty project and open it for the first run, then close the editor (the first run takes longer time for shaders). Then open the newly created empty project with English language (or other Latin script language) and a non-Latin script language (Traditional Chinese in my case), and the speed loss on the non-Latin script one is quite obvious.

This comparison can be made on Linux live-usb drives of various Linux distributions.

Minimal reproduction project

An empty project. The speed loss exists on other projects as well, just make sure to open the same project with Latin script language and a non-Latin one respectively.

Calinou commented 9 months ago

This is likely related to system font loading for fallbacks. cc @bruvzg

Lasuch69 commented 9 months ago

Reproducible on Fedora Silverblue 38 - Wayland - RX 550 - Linux 6.5.7

Changing system language to Japanese or English doesn't reproduce the bug, only changing the editor language results in ~2x slowdown (normal ~5s and with the bug ~10s).

Edit: Tested in Godot 4.1.2

traditionalgithub commented 9 months ago

Also like #82063, the flathub version on the Ubuntu-based distros runs faster than the standalone versions ( ~ 18 seconds for the flathub version and ~ 85 seconds for the standalone version) in Traditional Chinese, while both take ~ 5 seconds opening a same nearly empty project (with four 3d nodes) in English.

The system information reports of the standalone version and the flathub version are "Godot v4.1.2.stable - Ubuntu 22.04.3 LTS 22.04 - X11 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1080 Ti (nvidia; 525.125.06) - Intel(R) Core(TM) i5-7600K CPU @ 3.80GHz (4 Threads)" and "Godot v4.1.2.stable (399c9dc39) - Freedesktop SDK 23.08 (Flatpak runtime) - X11 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1080 Ti (nvidia) - Intel(R) Core(TM) i5-7600K CPU @ 3.80GHz (4 Threads)" respectively.

traditionalgithub commented 8 months ago

The problem is still relevant in v4.2.stable.official [46dc27791].

traditionalgithub commented 7 months ago

The problem is still relevant in v4.2.1.stable.official [b09f793f5]

xix-xeaon commented 6 months ago

This isn't just an editor issue. Updating text in-game with a unicode character causes huge frame freeze. v4.3.dev2.official [352434668]

Profiler says it's physics time: image

Visual profiler looks like this: image

extends Label

var i = 0

func _input(event):
    if event is InputEventMouseButton and event.pressed:
        i += 1
        text = ["あ", "a"][i % 2]
Pilvinen commented 2 weeks ago

I encountered this issue yesterday.

Seems to affect Labels and RichTextLabels. In my case I have playing cards which have 5 Labels in them. And I noticed when I added UTF-8 symbol characters to the cards like so:

kuva

I have 35 cards in a scene, 175 labels with UTF-8 in them in total. I'm also using the Godot's default Control based drag and drop system.

Here's a video where you can see what happens:

https://github.com/user-attachments/assets/2eb36988-12dd-41dc-9182-9ebc4225dbe7

(The Labels on the video are set to Visible = false in case you're wondering, but they are still there and causing the issue.)

If I delete the UTF-8 text from the labels, using only the ASCII part, the problem goes away.

Other things it affects are scene switching which you can see on this video:

https://github.com/user-attachments/assets/f8437029-8238-461b-9252-9e374f9dc4e2

It takes around full 2 seconds to switch to the simple scene with the cards with the labels with the UTF-8 in them.

Another thing that takes a long time is Godot starting up.

If I delete the UTF-8 symbols, all the problems are gone and everything works fast as lightning.

As a workaround, since this has been around for quite a while, I will likely use TextureRect instead of UTF-8 in Labels from now on.

But it would be really nice to get this fixed.