Editing the subject in the composer causes the contents of the whole tab to redraw

I think commands/account/compose.go calls tab.content.Invalidate() every time you type a character in the subject header. That causes the whole tab to be redrawn rather than just the tab strip. On a very slow machine, this takes a long time and there is a noticeable lag - ~750ms per character on a RaspberryPi 1 - giving a poor experience. Commenting out the Invalidate() line doesn't seem to break anything (tab strip and subject line update OK), although I've not tested it thoroughly. Is that line needed?

Incidentally, the reason it take so long to refresh the screen seems to be that it invalidates the whole of the editor area. This necessitates many calls to term.styleFromCell(cell) from /widgets/terminal.go which takes majority of the time. But that's probably a performance bug for go-libvterm.

Assigned to
1 year, 18 days ago
2 months ago
No labels applied.

bdju@tilde.team 10 months ago · edit

I just ran into this as well, I think. Especially bad if you paste in a line of text all at once. Pasting into the body of the email seems slow as well, but not comically slow the way it is with the subject line. I'm using aerc over ssh in tmux which may or may not affect term drawing and such, although the plain typing seems plenty fast.

~craftyguy 2 months ago

I also ran into this on my laptop, the lag was something like ~200ms between characters being printed in 'subject' as I typed them. Applying the workaround mentioned above resolved the issue, but I don't know whether there are implications with doing this. I didn't notice any downside in the limited testing I've done with this change so far.

diff --git a/commands/account/compose.go b/commands/account/compose.go
index b33acf5..f0e2c19 100644
--- a/commands/account/compose.go
+++ b/commands/account/compose.go
@@ -44,7 +44,6 @@ func (Compose) Execute(aerc *widgets.Aerc, args []string) error {
                } else {
                        tab.Name = subject
-               tab.Content.Invalidate()
        go composer.AppendContents(strings.NewReader(body))
        return nil
Register here or Log in to comment, or comment via email.