Bug 495029

Summary: Konsole context menu appears with noticeable delay after being opened multiple times
Product: [Applications] konsole Reporter: burneddi
Component: generalAssignee: Konsole Developer <konsole-devel>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version First Reported In: 24.08.0   
Target Milestone: ---   
Platform: Fedora RPMs   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: attachment-1563219-0.html

Description burneddi 2024-10-19 08:06:42 UTC
SUMMARY
I reboot my computer my computer quite infrequently and always have an SSH session to my IRC client (Weechat) open in Konsole. As a result I often have a Konsole process that's open for up to weeks on end. When a Konsole window is open for several days like this, the right-click contextual menu eventually begins to take up to a couple of seconds to open.

I have not found a workaround or a synthetic reproducer for this. Tried disabling scrollback (for that session specifically) to no avail. It seems to have something to do with running an IRC client and therefore having lots of scrolling text, because my other long-running Konsole sessions do not have this issue. Clearing the scrollback does not help either though.

STEPS TO REPRODUCE
1. Run Weechat over SSH in Konsole for a couple of weeks
2. Right click somewhere in the text area to open the contextual menu

OBSERVED RESULT
Contextual menu has a noticeable delay before appearing

EXPECTED RESULT
Contextual menu appears immediately

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
(available in the Info Center app, or by running `kinfo` in a terminal window)
Linux/KDE Plasma: 
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION
Comment 1 burneddi 2024-10-19 12:06:32 UTC
After months of dealing with this, of course I figure out a synthetic repro hours after filing the bug report.

The bug actually has nothing to do with how long the Konsole session is open for. It's just based on how many times you open the context menu. After opening it a few dozen times in quick succession, it starts taking an increasingly long time to appear.

So here's the repro:
1. Open Konsole
2. Right-click in the text area repeatedly about a hundred times
3. Observe how the context menu starts taking longer and longer to appear

In case it matters, I have all the toolbars hidden
Comment 2 tcanabrava 2024-10-19 14:37:14 UTC
Created attachment 175025 [details]
attachment-1563219-0.html

just to add more clarification; can you check that memory also increases?
if that happens i might know what is going on.

On Sat, 19 Oct 2024 at 14:06 <bugzilla_noreply@kde.org> wrote:

> https://bugs.kde.org/show_bug.cgi?id=495029
>
> --- Comment #1 from burneddi@gmail.com ---
> After months of dealing with this, of course I figure out a synthetic repro
> hours after filing the bug report.
>
> The bug actually has nothing to do with how long the Konsole session is
> open
> for. It's just based on how many times you open the context menu. After
> opening
> it a few dozen times in quick succession, it starts taking an increasingly
> long
> time to appear.
>
> So here's the repro:
> 1. Open Konsole
> 2. Right-click in the text area repeatedly about a hundred times
> 3. Observe how the context menu starts taking longer and longer to appear
>
> In case it matters, I have all the toolbars hidden
>
> --
> You are receiving this mail because:
> You are the assignee for the bug.
Comment 3 burneddi 2024-10-19 15:39:00 UTC
Yes, memory usage does increase. It also seems that it increases in some kind of polynomial way; initially it grows quite slowly, but once the context menu gets noticeably slow to open, the memory usage starts growing by up to a couple of megabytes per right-click.
Comment 4 Bug Janitor Service 2025-02-11 13:34:02 UTC
A possibly relevant merge request was started @ https://invent.kde.org/utilities/konsole/-/merge_requests/1063
Comment 5 Kurt Hindenburg 2025-02-17 23:51:04 UTC
Git commit ab751a3b16e3da3eb8b0cd6366dea234ce74c0ac by Kurt Hindenburg, on behalf of Blaise Duszynski.
Committed on 17/02/2025 at 23:26.
Pushed by hindenburg into branch 'master'.

Add HamburgerMenu only once per instance

A new HamburgerMenu is added to the context menu each time it is opened
which causes a delay after enough invocations.  Skip adding another if
one has already been added.

M  +7    -3    src/session/SessionController.cpp
M  +2    -0    src/session/SessionController.h

https://invent.kde.org/utilities/konsole/-/commit/ab751a3b16e3da3eb8b0cd6366dea234ce74c0ac