Bug 527555 - RemoteAccess mode: some connections never get a picture because the portal session never starts
Summary: RemoteAccess mode: some connections never get a picture because the portal se...
Status: RESOLVED FIXED
Alias: None
Product: KRdp
Classification: Plasma
Component: general (other bugs)
Version First Reported In: 6.8.0
Platform: Other Other
: HI normal
Target Milestone: ---
Assignee: Unassigned bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2026-10-21 20:27 UTC by Matteo
Modified: 2026-10-30 16:16 UTC (History)
3 users (show)

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


Attachments
journal of one failing connection (10.59 KB, text/plain)
2026-10-21 20:27 UTC, Matteo
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Matteo 2026-10-21 20:27:37 UTC
Created attachment 197477 [details]
journal of one failing connection

With krdpserver in RemoteAccess mode (portal path, no --plasma), about one connection in six never gets a picture. The client authenticates and stays connected, but no frame is ever sent. Disconnecting and connecting again works.

In every failing connection the log shows "Initializing Freedesktop Portal Session" and "Switched to greeter successfully", but never "Started Freedesktop Portal session". In working connections that line follows 300-400 ms later and the PipeWire stream starts.

Switching the seat to the greeter makes the user session's KWin lose DRM access ("Failed to find a working output layer configuration: EACCESS"), and every client then logs "There are no outputs - creating placeholder screen", xdg-desktop-portal-kde included. In working connections that happens within a few ms of "Switched to greeter". In the failing one it came about 200 ms later, while the portal request was already in flight, and the portal session never started.

My guess (not verified in the code): krdpserver asks for SwitchToGreeter before its portal session has started. If the outputs go away at the wrong moment, the portal request never completes. Starting the portal session, or at least the virtual monitor stream, before switching to the greeter might avoid it.

"Tried to make uncreated stream active" (KPipeWire) is logged on every connection, including working ones, so it doesn't seem to be the cause.

STEPS TO REPRODUCE
1. Plasma Login Manager with autologin (Relogin=false), Plasma Wayland session.
2. krdpserver --mode RemoteAccess --certificate ... --certificate-key ... (KRDP_DISABLE_H264=1, PAM users), portal remote-desktop permission granted for org.kde.krdpserver.
3. Connect with FreeRDP (xfreerdp3 /size:1600x900), wait 20 s, disconnect. Before the next try, hand the seat back to the user session (loginctl activate + unlock-session; without it the session stays locked on the greeter).
4. Repeat. 4 of 23 connections got no picture; the first connection after a pause failed more often.

OBSERVED RESULT
Client connected, no picture; krdpserver never logs "Started Freedesktop Portal session".

EXPECTED RESULT
Every connection gets the desktop on the virtual monitor.

SOFTWARE/OS VERSIONS
Arch Linux ARM (aarch64), Raspberry Pi 5, headless (HDMI-A-1 forced on with video=...D)
KDE Plasma 6.8.0, KWin 6.8.0, KRdp 6.8.0, KPipeWire 6.8.0
xdg-desktop-portal 1.22.1, xdg-desktop-portal-kde 6.8.0, plasma-login-manager 6.8.0
PipeWire 1.6.9, FreeRDP 3.32.2 (server), client FreeRDP 3.15 (Linux) and Royal TSX (macOS)
Kernel 6.18.57 (linux-rpi)

ADDITIONAL INFORMATION
Attached: journal of one failing connection (21:00:17) followed by a working one (21:01:00), with QT_LOGGING_RULES=org.kde.krdp*.debug=true;kpipewire*.debug=true.
Comment 1 Bug Janitor Service 2026-10-23 15:38:27 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/krdp/-/merge_requests/282
Comment 2 Matteo 2026-10-23 15:40:38 UTC
Root cause found: a race in KRdp's PortalRequest, not in the greeter switch.

PortalRequest connects to the portal's Response signal only after the method
call has returned. The portal sometimes sends Response before that, and the
signal is dropped, so the session never starts. dbus-monitor on a Raspberry
Pi 5 (Plasma 6.8.0, RemoteAccess mode) shows it in every failed connection:
the Response for CreateSession or SelectDevices arrives 1-13 ms before
krdpserver's AddMatch for the request path. On good connections the AddMatch
wins by only 2-4 ms. The "Tried to make uncreated stream active" warning
also shows on good connections; it is not related.

Automated test (xfreerdp3 connecting from localhost): 9 of 45 connections
without picture before the fix, 0 of 40 with it (krdp 6.8.1 + patch).

Fix: listen on the request path derived from handle_token before making the
call, as the portal documentation recommends.
MR: https://invent.kde.org/plasma/krdp/-/merge_requests/282
Comment 3 Bug Janitor Service 2026-10-24 08:28:16 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/krdp/-/merge_requests/283
Comment 4 David Edmundson 2026-10-24 15:07:49 UTC
Git commit 36ab49470da552c76f651838aaee4d7032610041 by David Edmundson.
Committed on 24/10/2026 at 08:28.
Pushed by davidedmundson into branch 'Plasma/6.8'.

PortalSession: listen for the portal response before making the request

PortalRequest connected to the Response signal only after the method
call returned. The portal can send Response before that, and the
signal is then dropped: the session never starts and the client sees
no picture. On a Raspberry Pi 5 in RemoteAccess mode this happened in
about one connection out of five, at CreateSession or SelectDevices.

Listen on the request path derived from the handle token before the
call, as the portal documentation recommends, and pass a handle token
to SelectSources too. Fall back to the returned path for portals that
don't derive it from the token.


(cherry picked from commit 07dc3d12894e131dcfafcf2a846073e8a5ce7d98)

Co-authored-by: Matteo Beretta <matteo@trendupgraphic.com>

M  +44   -13   src/PortalSession.cpp
M  +15   -7    src/PortalSession_p.h

https://invent.kde.org/plasma/krdp/-/commit/36ab49470da552c76f651838aaee4d7032610041