chairfull / GodotRichTextLabel2

Many more advanced features and animations for the RichTextLabel.
MIT License
86 stars 2 forks source link

instantiate time too long #12

Open aiaimimi0920 opened 1 month ago

aiaimimi0920 commented 1 month ago

The phenomenon is basically the same as this problem: https://github.com/chairfull/GodotRichTextLabel2/issues/5

This is the running time in editor:

252
198
37003
new: 0.78571428571429
ins: 146.837301587302

This is the running time in export exe:

302
295
798
new: 0.97682119205298
ins: 2.64238410596026

The 145 fold time gap seriously affects the running of test projects in the editor.

The version I am using is: Godot v4.4.dev2 - Windows 10.0.22631 - OpenGL 3 (Compatibility) - NVIDIA GeForce RTX 2080 Ti (NVIDIA; 31.0.15.4633) - 12th Gen Intel(R) Core(TM) i5-12400F (12 Threads)

aiaimimi0920 commented 1 month ago

@chairfull Is there a solution to this problem? Thanks

chairfull commented 1 month ago

I'm going to check later if caching all the Regex stuff saves some time, but at the moment this problem is not a priority for my projects.

aiaimimi0920 commented 1 month ago

ok,thanks your help

SaltyByte commented 1 month ago

I also wanted to add to this, I'm using RichTextLabel2 for floating damage. Instantiating takes about 200ms for each label.

chairfull commented 1 month ago

@aiaimimi0920 @SaltyByte one expensive feature is font_auto_setup which might be generating 3 fonts each time.

In your instanced scene try setting font_auto_setup = false, clearing Theme Overides > Fonts > Bold, Italics, Bold Italics, and then saving.

I'll try rewriting this later to save the fonts to disk.

SaltyByte commented 1 month ago

Hey @chairfull i did what you've suggested, it seems like it helps but theres still lag. From avg of 200ms delay it is now 50ms of delay, but to be fair that is still quite a lot. For reference, using regular richlabel takes about 1ms or less if you could provide me with details of why you think this happends, maybe ill have a look on it and open pr

chairfull commented 1 month ago

Caching the RegEx didn't seem to do anything.

I tried setting set_bbcode() and _set_bbcode() to do nothing, and even then it was still slow to instantiate. So that implies it's something to do with the editor.

I then tried commenting out the _get_property_list() and that actually seemed to be a big improvement. Which explains why built games don't have the problem.

Edit: Try having _get_property_list() return nothing.

func _get_property_list():
    return []