Bug 520175 - KRdp session freezes for several minutes on certain clipboard copies
Summary: KRdp session freezes for several minutes on certain clipboard copies
Status: RESOLVED FIXED
Alias: None
Product: KRdp
Classification: Plasma
Component: general (other bugs)
Version First Reported In: 6.6.4
Platform: Kubuntu Linux
: VHI normal
Target Milestone: ---
Assignee: Unassigned bugs
URL:
Keywords: efficiency-and-performance
Depends on:
Blocks:
 
Reported: 2026-05-15 01:37 UTC by Paul Hoskinson
Modified: 2026-05-29 18:31 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In: 6.7.0
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Hoskinson 2026-05-15 01:37:49 UTC
DESCRIPTION
When connected to a Kubuntu 26.04 wayland KRDP server using Remmina client, when I copy text or images to the clipboard from certain Wayland applications (Firefox, Remmina) the whole RDP session freezes for several minutes.

STEPS TO REPRODUCE
1. Start an RDP session to KRDP server 
2. Select text in Firefox and copy to clipboard

OBSERVED RESULT
Session instantly freezes for several minutes. Krdpserver process is unresponsive
Log contains the message: org.kde.krdp: PipeWire frame did not contain usable image data

EXPECTED RESULT
No freeze

SOFTWARE/OS VERSIONS
Operating System: Kubuntu 26.04
KDE Plasma Version: 6.6.4
KDE Frameworks Version: 6.24.0
Qt Version: 6.10.2

ADDITIONAL INFORMATION

The following patch eliminates the issue for me locally:

$ git diff -- src/PortalSession.cpp
diff --git a/src/PortalSession.cpp b/src/PortalSession.cpp
index 94d472a..54f3f87 100644
--- a/src/PortalSession.cpp
+++ b/src/PortalSession.cpp
@@ -105,14 +105,22 @@ PortalSession::PortalSession()
             return;
         }
 
+        qCDebug(KRDP) << "Clipboard formats:" << data->formats() << "hasText:" << data->hasText();
+
         // KSystemClipboard takes ownership of any QMimeData passed to it but
         // does not relinquish ownership over anything it returns. So manually
         // copy over the contents to a new instance of QMimeData so we can keep
         // the semantics the same.
+        //
+        // Only copy text data here. Fetching arbitrary clipboard MIME payloads
+        // can block for a long time on Wayland/XWayland targets such as
+        // SAVE_TARGETS, which freezes the server's main thread. The RDP
+        // clipboard implementation currently only exposes text anyway.
         auto newData = new QMimeData();
-        const auto formats = data->formats();
-        for (auto format : formats) {
-            newData->setData(format, data->data(format));
+        if (data->hasText()) {
+            newData->setText(data->text());
+        } else {
+            qCDebug(KRDP) << "Ignoring non-text clipboard update with formats" << data->formats();
         }
 
         Q_EMIT clipboardDataChanged(newData);

Summary of changes:
- clipboard owners may advertise safe text formats plus problematic side formats
- KRDP eagerly fetches everything
- after the changes, KRDP only fetches plain text when available
- that avoids the blocking format fetches and fixes the freeze
- KRDP’s current RDP clipboard implementation only advertises and transfers plain text (CF_UNICODETEXT), so fetching non-text MIME payloads provides no benefit to clients and only adds risk of blocking on expensive or problematic clipboard targets like SAVE_TARGETS.

This patch produces the following debug output when copying from applications that previously caused the freeze:

org.kde.krdp: Clipboard formats: QList("text/plain;charset=utf-8", "UTF8_STRING", "COMPOUND_TEXT", "TEXT", "text/plain", "STRING", "SAVE_TARGETS") hasText: true

org.kde.krdp: Clipboard formats: QList("text/html", "text/_moz_htmlinfo", "text/_moz_htmlcontext", "image/png", "image/avif", "image/bmp", "image/x-bmp", "image/x-MS-bmp", "image/x-icon", "image/x-ico", "image/x-win-bitmap", "image/vnd.microsoft.icon", "application/ico", "image/ico", "image/icon", "text/ico", "image/jpeg", "image/tiff", "image/webp") hasText: false

May 14 18:20:36 paul-adion krdpserver[11199]: org.kde.krdp: Ignoring non-text clipboard update with formats QList("text/html", "text/_moz_htmlinfo", "text/_moz_htmlcontext", "image/png", "image/avif", "image/bmp", "image/x-bmp", "image/x-MS-bmp", "image/x-icon", "image/x-ico", "image/x-win-bitmap", "image/vnd.microsoft.icon", "application/ico", "image/ico", "image/icon", "text/ico", "image/jpeg", "image/tiff", "image/webp")
Comment 1 David Edmundson 2026-05-15 07:51:53 UTC
>- KRDP’s current RDP clipboard implementation only advertises and transfers plain text (CF_UNICODETEXT)

Makes sense as a short term solution at least.
Comment 2 David Edmundson 2026-05-19 10:37:18 UTC
What's your full name? I should put you as the commit author.
Comment 3 Bug Janitor Service 2026-05-19 10:37:59 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/krdp/-/merge_requests/179
Comment 4 Paul Hoskinson 2026-05-19 17:31:20 UTC
(In reply to David Edmundson from comment #2)
> What's your full name? I should put you as the commit author.

Paul Hoskinson
Comment 5 David Edmundson 2026-05-27 12:19:08 UTC
Git commit ea02751b9aa11a4a201e2f9aa68a040c3375a941 by David Edmundson, on behalf of Paul Hoskinson.
Committed on 27/05/2026 at 12:14.
Pushed by davidedmundson into branch 'master'.

Ignore non-text mimetypes

Krdp has to copy the mimetype data before announcing it has a clipboard
to avoid some issues. This is potentially expensive.

We only send text at an RDP level currently, so instead only handle text
mimetypes.

M  +11   -3    src/PortalSession.cpp

https://invent.kde.org/plasma/krdp/-/commit/ea02751b9aa11a4a201e2f9aa68a040c3375a941
Comment 6 Nate Graham 2026-05-29 17:45:20 UTC
Git commit f777389591627dd8bfa10fd487a755aadcd74811 by Nate Graham.
Committed on 29/05/2026 at 17:19.
Pushed by ngraham into branch 'Plasma/6.7'.

Ignore non-text mimetypes

Krdp has to copy the mimetype data before announcing it has a clipboard
to avoid some issues. This is potentially expensive.

We only send text at an RDP level currently, so instead only handle text
mimetypes.


(cherry picked from commit ea02751b9aa11a4a201e2f9aa68a040c3375a941)

Co-authored-by: Paul Hoskinson <paul_kde@inbox.hosk.ca>

M  +11   -3    src/PortalSession.cpp

https://invent.kde.org/plasma/krdp/-/commit/f777389591627dd8bfa10fd487a755aadcd74811