godot-console
godot-console copied to clipboard
If the RichTextBox Text gets too full it really slows down performance.
If the console output text box gets really full godot will eventually slow to a crawl. Potentially we should just trim from the top to avoid issues.
Hey, sorry to hear that. Is that issue appearing for you during a command that outputs lots of text or after you run multiple commands? Reason I'm asking is that I don't have much time currently to fix this issue properly and if it happens after you ran several commands you can always use clear
command. It should remove all the text from RichTextBox.
Hey,
Yeah I've just been calling clear over and over again once it fills up. Was thinking of a more elegant way to fix it. Like perhaps trying to just remove a line from the text box once it hits a certain scrollback buffer threshold. Maybe even expand that to holding the output text in a buffer then only using the richtextbox to render the section of the output. That all said, clear every few thousand commands work. (I also print to console on logging which is probably outside of the scope of this plugin.)
On Mon, Sep 6, 2021 at 4:17 AM Sergei ZH @.***> wrote:
Hey, sorry to hear that. Is that issue appearing for you during a command that outputs lots of text or after you run multiple commands? Reason I'm asking is that I don't have much time currently to fix this issue properly and if it happens after you ran several commands you can always use clear command. It should remove all the text from RichTextBox.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/quentincaffeino/godot-console/issues/70#issuecomment-913567500, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADGR2CTLHAAZRHL3J56DTLUASPLPANCNFSM5DNW6J4Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
The easiest solution for now, yes, is to just have some counter (or maybe rich text box has one) of lines and remove lines that exceed a certain threshold.
I like the idea of the buffer but that might be too advanced for now. Since holding full buffer in memory is still too much it will need to be persisted on disk and there should be optimisations such as chunking because writing and reading every second will kill performance and ssd.
Maybe Console.Log is out of scope (or I think at least it should not be a part of the core) but Console.print is made exactly for printing even outside the console.
Hi @quentincaffeino
After several hours of testing, I believe this issue is related to the write_line()
function:
https://github.com/quentincaffeino/godot-console/blob/4a88966f70ad2b509275cda3b03020ca027a1761/addons/quentincaffeino/console/src/Console.gd#L143-L149
The Godot engine isn't handling set_bbcode()
and get_bbcode()
correctly, from 3.2.3 ~ 3.3.4.
According to the documentation, probably we should use append_bbcode()
instead, as it doesn't rebuild the whole BBCode every time we write a line, see: RichTextLabel
Hey, @Zhwt. Thanks for spending time looking for solution. Seems legit, could you open a pr?
Hi, @quentincaffeino
I opened a pr but I haven't got enough time to check the clear() function, and it's already 1 AM in my current location... I'm not sure whether I should use self.Text.clear()
or set_bbcode('')
. I'll look into this tomorrow.
@Zhwt, sure, thanks a lot)
Hi @quentincaffeino
After several hours of testing, I believe this issue is related to the
write_line()
function:https://github.com/quentincaffeino/godot-console/blob/4a88966f70ad2b509275cda3b03020ca027a1761/addons/quentincaffeino/console/src/Console.gd#L143-L149
The Godot engine isn't handling
set_bbcode()
andget_bbcode()
correctly, from 3.2.3 ~ 3.3.4.According to the documentation, probably we should use
append_bbcode()
instead, as it doesn't rebuild the whole BBCode every time we write a line, see: RichTextLabel
This is a great catch! way to go.
Hi, @quentincaffeino
Sorry for the late reply, I didn't have too much time these days. And during my test, I found out there's one problem with this change: the engine itself has some bugs related to append_bbcode()
(#18413). So after this change, we'll be unable to get console output string, that is, after replacing set_bbcode()
with append_bbcode()
, all self.Text.get_bbcode()
will return "" instead of its display content. I'm not sure if there is anything rely on console output string.
Hi, @MJBrune
In my case, the append_bbcode()
fix can improve performance, but if there are too many lines, the game still lags. Personally I uses the following solution to limit console output:
Change write_line
function in res://addons/quentincaffeino/console/src/Console.gd
file to:
# Maximum output line count
var output_buffer_lines = 2000
func write_line(message = ''):
message = str(message)
if self.Text:
self.Text.append_bbcode(message + '\n')
# Removes oldest line
while self.Text.get_line_count() > output_buffer_lines:
self.Text.remove_line(0)
print(self._erase_bb_tags_regex.sub(message, '', true))
This solution isn't perfect, it still lags the game when there are already 2000 lines and still print large pieces of text, but if you only print 2~10 lines everytime this should be done quickly. Originally I want to use set_bbcode()
to set last 5000 lines everytime when there are 8000 or 10000 lines, but then I encountered that bug, so...
Hey, @Zhwt, no worries. Thank you for pr and testing. I will check it in upcoming days. Regarding get_bbcode: console does not use this internally and I think there is no reason to use this in the future so we should be fine.
I consider this fixed in #73 so closing. If there are other improvements ideas or performance problems please open a ticket :)