https://bugs.kde.org/show_bug.cgi?id=520175

            Bug ID: 520175
           Summary: KRdp session freezes for several minutes on certain
                    clipboard copies
    Classification: Plasma
           Product: KRdp
      Version First 6.6.4
       Reported In:
          Platform: Kubuntu
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: general
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
  Target Milestone: ---

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")

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to