[client,sdl] Wayland: client re-announces a local clipboard after every server copy, breaking copy/paste inside the session
Describe the bug
With sdl-freerdp on a GNOME Wayland session, every clipboard write on the Windows server starts a ping-pong between the server's rdpclip.exe and the client. Within about a second the server clipboard changes owner 20-35 times, and it ends with rdpclip owning a clipboard that advertises text formats but returns no data when asked.
Visible effects:
- Copying inside the Windows session breaks: Snipping Tool captures, text copied from the VS Code terminal, and programmatic writes (
Set-Clipboard,clip.exe) paste as nothing. Some plain-text copies (Notepad → Word) survive. - After some copies the clipboard stays broken in both directions, including plain text from the local desktop to the server, until the client reconnects.
- Local → server and server → local plain text work in a fresh session, until one of the failing copies happens.
The same server, same session and same local desktop work correctly with xfreerdp (running through XWayland) and with /clipboard:direction-to:remote on sdl-freerdp, which points at the SDL client's handling of its own clipboard changes.
To Reproduce
- Connect from a GNOME Wayland session:(Also reproduces with a minimal
sdl-freerdp /v:<server> /u:<user> /cert:tofu +dynamic-resolution +disp /scale-desktop:150 /gfx /clipboard /sound /multimon /monitors:3,5,6sdl-freerdp /v:<server> /clipboard ...command line and without/multimon.) - In the Windows session, open PowerShell and run a write followed by a read, while polling the clipboard sequence number:
Set-Clipboard "test-A $(Get-Date -f HH:mm:ss)" Get-Clipboard -Raw # returns empty - Or take a Snipping Tool capture (Win+Shift+S) and paste it into Word/Paint: nothing is pasted.
Expected behavior
A copy on the server stays on the server clipboard (and is offered to the local desktop once); the client should not re-announce data it received from the server back to the server as a new local clipboard.
Evidence from the server side
Measured inside the Windows session (PowerShell, -STA, GetClipboardSequenceNumber, GetClipboardOwner):
- Idle, with nothing writing, the sequence number is stable (
2129over 10 s). - One
Set-Clipboardmoves the sequence number from2108to2129(21 changes), andSet-Clipboardtakes ~1.4 s to return. - Claude Code's
/copy(a child PowerShell runningSet-Clipboard) moved it from2129to2164(35 changes). - Afterwards the clipboard owner is always
rdpclip.exe(same window handle every time); the format list containsUnicodeText,Text,OEMText, but:IsClipboardFormatAvailable(CF_UNICODETEXT) -> True OpenClipboard -> True GetClipboardData(CF_UNICODETEXT) -> handle 0 Get-Clipboard -Raw -> "" (length 0) "text" | clip.exefails withAccess is denied., and[System.Windows.Forms.Clipboard]::SetText()throwsRequested Clipboard operation did not succeed.(presumably while the loop is running).- Clipboard redirection is not disabled by policy (
fDisableClipabsent underPolicies\...\Terminal Services,0underWinStations\RDP-Tcp); clipboard history is off.
My reading: the client receives the server's Format List, takes ownership of the local Wayland clipboard, then treats that local ownership change (possibly the SDL_EVENT_CLIPBOARD_UPDATE produced by its own SDL_SetClipboardData) as a new local copy and sends a Format List back. rdpclip then takes ownership again as a delayed-render proxy, and the cycle repeats until it ends on a proxy whose data request fails. I haven't verified this in the code, so treat it as a hypothesis.
Client log (3.31.1)
Snipping Tool capture, then pasting inside Windows:
[ERROR][com.winpr.clipboard] - [ClipboardGetData]: No synthesizer for format text/plain [0x0000c000] --> image/png [0x0000c007]
[WARN][com.winpr.utils.image] - [winpr_image_bitmap_read_buffer]: pos=54, expected 66, offset=12
[ERROR][com.freerdp.client.sdl.cliprdr] - [ClipDataCb]: error retrieving clipboard data
[ERROR][com.winpr.clipboard] - [ClipboardGetData]: No synthesizer for format CF_RAW [0x00000000] --> image/png [0x0000c007]
[ERROR][com.winpr.clipboard] - [ClipboardGetData]: No synthesizer for format CF_RAW [0x00000000] --> text/plain [0x0000c000]With 3.31.0 (tested from the Fedora build) the winpr_image_bitmap_read_buffer error is gone, but the loop and the No synthesizer for format CF_RAW --> text/plain / image/png errors remain on every server-side copy; Snipping Tool and VS Code terminal copies inside Windows still fail.
Comparison
| Client | Copy inside Windows | Local → server | Server → local | Notes |
|---|---|---|---|---|
sdl-freerdp 3.31.1, /clipboard |
broken (loop) | breaks after a failing copy | text only | this report |
sdl-freerdp 3.31.0, /clipboard |
Snipping Tool / VS Code terminal fail | works | works, incl. images | loop still present |
sdl-freerdp 3.31.1, /clipboard:direction-to:remote |
works | works | disabled | no loop |
xfreerdp 3.31.1 (XWayland), /clipboard |
works | works | works, incl. images | logs the same bitmap warning but no loop |
SPICE (virt-viewer + spice-vdagent) |
works | works | works | different mechanism, for reference |
A Snipping Tool capture copied explicitly with the Copy button in the Snipping Tool window does paste; the automatic copy right after capture does not. That fits a delayed-render owner that exits before the client's request arrives.
Application details
- FreeRDP:
sdl-freerdp3.31.1 (Fedorafreerdp-3.31.1-1.fc44), also tested 3.31.0 (freerdp-3.31.0-1.fc44) - SDL3 3.4.16 (Fedora
SDL3-3.4.16-1.fc44) - Client OS: Fedora 44, kernel 7.2.7, GNOME 50 / mutter 50.5, Wayland session, fractional scaling 150%
- Server: Windows 11 Pro 25H2, build 26200.9457, running as a QEMU/KVM guest; connection over the libvirt NAT network
- Build flags of interest from
/log-level:DEBUG:WITH_CLIENT_SDL3=ON,WITH_WAYLAND=ON,WITH_FFMPEG=OFF,WITH_SWSCALE=OFF,WITH_OPENH264=TRUE
Related
- #11359 (SDL client on KDE Wayland locking up during clipboard copy; fixed in 3.15, different symptom)
- #13494 (empty server Format List dropped by the cliprdr client)
- The
pos=54, expected 66, offset=12bitmap warning looks like a separate 3.31.1 regression around #13304 ([winpr,clipboard] honor DIB header size in BMP offsets) for 32-bitBI_BITFIELDSDIBs; happy to file it separately if preferred.
Source: FreeRDP/FreeRDP