Bug 431673 - Plasmashell freezes when accessing very long clipboard text with Klipper
Summary: Plasmashell freezes when accessing very long clipboard text with Klipper
Status: RESOLVED FIXED
Alias: None
Product: klipper
Classification: Unmaintained
Component: general (show other bugs)
Version: 5.21.1
Platform: Neon Linux
: NOR major
Target Milestone: ---
Assignee: Plasma Bugs List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-01-16 08:50 UTC by Ferenc Lutischan
Modified: 2022-01-19 00:54 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.23
Sentry Crash Report:


Attachments
Klipper history file (3.76 MB, application/zip)
2021-01-16 08:50 UTC, Ferenc Lutischan
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ferenc Lutischan 2021-01-16 08:50:18 UTC
Created attachment 134918 [details]
Klipper history file

SUMMARY

Full desktop will frozen ~30 sec if you use attached clipboard history (~/.local/share/klipper/history2.lst).

STEPS TO REPRODUCE
1. Switch off Klipper
2. Overwrite your own history file with the attached file (I suggest a backup first your own history).
3. Switch on Klipper
4. Set a hotkey in Klipper settings: "Open Klipper at Mouse Position"
5. Press hotkey


OBSERVED RESULT
The desktop will be frozen ~ 30 sec (only mouse cursor can be move)
Does Klipper tries to calculate history window size on large, multiple lines of text??

EXPECTED RESULT
Works without freezing as click on Klipper systray icon
Possible solutions:
- Not calculate full-text size. Calculate only with the first x chars.
- Fixed-size of the showed text. E.g. 20 char length (configurable?)
- Fixed-size of the history window. E.g. 150px. (configurable?) - I prefer this solution

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: KDE Neon user
KDE Plasma Version: 5.20.5
KDE Frameworks Version: 5.78.0
Qt Version: 5.15.2
Comment 1 Nate Graham 2021-04-01 20:33:13 UTC

*** This bug has been marked as a duplicate of bug 360262 ***
Comment 2 valdikss 2021-08-22 12:53:44 UTC
Your history file contains a very long text of 8 307 895 characters, which Plasma tries to render in a text field.

plasmashell call graph is as follows:

80.56%     0.00%  plasmashell      libQt5Gui.so.5.15.2                [.] QTextDocumentLayout::documentChanged
        |
        ---QTextDocumentLayout::documentChanged
            0x7f5e6a605ae7
            QTextDocumentLayout::doLayout
            0x7f5e6a605430
            0x7f5e6a604e72
            |          
            --80.56%--0x7f5e6a5febae
                        0x7f5e6a605430
                        0x7f5e6a604ca8
                        0x7f5e6a60124e
                        0x7f5e6a600689
                        0x7f5e6a5fe92c
                        |          
                        --80.34%--0x7f5e6a5fd87c
                                    QTextLine::layout_helper
                                    |          
                                    |--67.11%--QTextEngine::shapeText
                                    |          |          
                                    |          |--63.35%--QTextEngine::shapeTextWithHarfbuzzNG
                                    |          |          |          
                                    |          |          |--60.15%--hb_shape_full
                                    |          |          |          |          
                                    |          |          |           --60.07%--hb_shape_plan_execute
Comment 3 valdikss 2021-08-22 13:06:24 UTC
(In reply to Nate Graham from comment #1)
> 
> *** This bug has been marked as a duplicate of bug 360262 ***

Doesn't seem like a duplicate for me.
Comment 4 Bug Janitor Service 2021-08-22 15:36:27 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/1015
Comment 5 David Edmundson 2021-08-27 21:09:35 UTC
Git commit f9669af2cfa6afdf6567ded5159c45ea8ab6c947 by David Edmundson, on behalf of ValdikSS ValdikSS.
Committed on 27/08/2021 at 20:44.
Pushed by ngraham into branch 'master'.

Trim very long text strings in Klipper history view

Klipper may freeze the whole plasmashell for tens of seconds trying
to render very long text string from history in the popup.

Trim very large strings to 200 characters (tooltip default) to prevent this.

M  +6    -0    klipper/historystringitem.cpp
M  +0    -5    klipper/historystringitem.h
M  +1    -1    klipper/klipper.cpp

https://invent.kde.org/plasma/plasma-workspace/commit/f9669af2cfa6afdf6567ded5159c45ea8ab6c947
Comment 6 Kurtsjunkacc 2021-12-05 06:48:58 UTC
Has this fix caused this bug

https://bugs.kde.org/show_bug.cgi?id=444365
Comment 7 Nate Graham 2021-12-05 14:34:30 UTC
Thanks for reporting; looks like a fix is in progress.
Comment 8 popov895 2022-01-18 16:49:24 UTC
The MR above resulted in a lot of bugs. Instead, we should avoid adding too long text to the clipboard history.
Comment 9 Nate Graham 2022-01-18 17:01:56 UTC
No, that's even worse. We can't destroy user data.

Let's not re-open the bug report unless it's found to be not actually fixed. This bug is fixed, ergo it stays closed. If it caused other bugs, we need to trash those with new bug reports.
Comment 10 popov895 2022-01-18 17:07:21 UTC
> No, that's even worse. We can't destroy user data.
Try to edit item with very long text (e.g. from the attachment 134918 [details]).
Comment 11 Nate Graham 2022-01-18 17:09:03 UTC
Yes, I've seen. We can fix that by using fullText there rather than just text, no?
Comment 12 popov895 2022-01-18 17:18:35 UTC
You may be using a lot of RAM, but in my case (8 GB) the system just hung.
Comment 13 Fushan Wen 2022-01-19 00:54:45 UTC
It should be a known QTBUG.