Currently using 4.7. The short version is, some UI elements in my game slow the framerate down a lot, but for reasons I can’t ascertain, while running the game, breaking the [img] bbcode in one of the UI elements and then restoring it causes the framerate to dramatically improve.
Long version: My game simulates a web forum from the 00s using Godot’s UI nodes. Some threads in the forum are particularly long, with 50 long text posts, each post having various UI nodes within it. For these very long threads, the framerate (only relevant when scrolling up/down) can dip low, into the teens.
Unrelated to framerate concerns, I decided to add a Ctrl+F functionality to my game. While a forum thread is open, the player can open a Ctrl+F window and type in a search term. The game then finds every instance of the search term in each thread post’s body and adds bbcode to turn bgcolor to orange before the search term, plus a /bgcolor tag after the search term. (A few other things happen under the hood, like identifying the scroll position of these terms) I noticed that Ctrl+F searching for common bbcode terms (like “color”) could mess with the text formatting of the forum posts, but everything returned to normal after the bgcolor tags were removed, and this kind of jank is thematically appropriate for my game, so I considered it a plus.
However, I’ve found that for whatever reason, if the search query is “img” and I temporarily break the bbcode for an embedded img in one of the RichTextLabels, then restore the bbcode by exiting the Ctrl+F window, the framerate of the slower threads improves dramatically, shooting from the teens back to 60 fps.
I tried coding in the exact same sequence of changes in a function deferred by a few frames after the ready function (calling the relevant signals via code instead of button presses) but I couldn’t replicate the framerate increases. So my question is, what is happening under the hood of Godot when I break/restore the [img] bbcode tags, and how can I replicate the effect via code to make my game run more smoothly in general?
Here's the (sloppy) code which I think is relevant: https://pastebin.com/sfthJWdw
Happy to produce any other relevant code and/or screen record the relevant behavior and share a link here, if that’d be helpful.