Clipboard Bi-Directional Copy-Paste Issue in Linux Host and Windows Guest

Discussions related to using VirtualBox on Linux hosts.
palytoxin
Posts: 8
Joined: 18. Aug 2023, 09:47

Re: Clipboard Bi-Directional Copy-Paste Issue in Linux Host and Windows Guest

Post by palytoxin »

fth0 wrote: 22. Aug 2023, 02:23 FWIW, the VirtualBox Shared Clipboard currently handles three clipboard data formats: UNICODETEXT, BITMAP and HTML. Note that clipboard data formats are not file formats. UNICODETEXT typically is UTF-16 with CRLF on Windows and UTF-8 with LF on Linux, and VirtualBox does the necessary conversion. BITMAP is DIB on Windows and BMP on Linux. HTML is, well, HTML. ;)

Code: Select all

00:21:27.990818 Shared Clipboard: Requesting data in format 0x1 for X11 host failed with VERR_TIMEOUT
00:21:27.990869 Shared Clipboard: Converting VBox formats 'UNICODETEXT, BITMAP, HTML' to 'UTF8_STRING' for X11 (idxFmtX11=1, fmtX11=3, atomTarget='UTF8_STRING') failed, rc=VERR_TIMEOUT
The log messages above indicate that the Windows clipboard had contents in all three formats and VirtualBox failed to convert the UNICODETEXT format to UTF-8 because of a timeout.

I'd suggest to create a ticket in the Bugtracker.
thx, I will
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Clipboard Bi-Directional Copy-Paste Issue in Linux Host and Windows Guest

Post by scottgus1 »

Thanks, fth0, for the clipboard formats! That's in my list now.

Thanks, also, palytoxin, for the Save As format. I wonder if PNG counts as a compatible bitmap in the Shared Clipboard formats list? Please post the Bugtracker link when you make the ticket.
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Clipboard Bi-Directional Copy-Paste Issue in Linux Host and Windows Guest

Post by mpack »

There is no necessary correlation between image file formats and clipboard image formats.

The clipboard format will be whatever the GUI uses as it's conventional bitmap format for comms between processes. In Windows that format was CF_BITMAP or CF_DIB, also known as BMP (though technically a BMP is a DIB plus an additional header - i.e. BITMAPFILEHEADER). I think some Windows will also support PNG images, especially for 32bpp images with transparency. Though I forget how that is done... perhaps a DIB with a PNG header and encoding.

An in-memory bitmap image can be rendered to any file format you like, e.g. PNG, JPEG. The fact that a particular piece of software offers particular export formats really tells you nothing about the clipboard.
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Clipboard Bi-Directional Copy-Paste Issue in Linux Host and Windows Guest

Post by scottgus1 »

Interesting, Mpack, thanks for the clarification!
fth0
Volunteer
Posts: 5678
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: Clipboard Bi-Directional Copy-Paste Issue in Linux Host and Windows Guest

Post by fth0 »

I've created an overview of clipboard data formats supported in VirtualBox 7.0 (for myself and for you ;)):

Code: Select all

Shared Clipboard data formats
-----------------------------

Windows                   VirtualBox                        Linux/X11       (fmtX11)
------------------------  --------------------------------  ------------------------
                          VBOX_SHCL_FMT_NONE           (0)  SHCLX11FMT_INVALID   (0)  
                                                            SHCLX11FMT_TARGETS   (1)
------------------------  --------------------------------  ------------------------
CF_UNICODETEXT            VBOX_SHCL_FMT_UNICODETEXT    (1)  SHCLX11FMT_UTF8      (3)
  CF_TEXT                                                     SHCLX11FMT_TEXT    (2)
  CF_OEMTEXT
CF_DIB                    VBOX_SHCL_FMT_BITMAP         (2)  SHCLX11FMT_BMP       (4)
  CF_BITMAP
CF_HTML ("HTML Format")   VBOX_SHCL_FMT_HTML           (4)  SHCLX11FMT_HTML      (5)


X11 atom names (idxFmtX11)
--------------------------

SHCLX11FMT_INVALID:
  ( 0) "INVALID"
SHCLX11FMT_UTF8:
  ( 1) "UTF8_STRING"
  ( 2) "text/plain;charset=UTF-8"
  ( 3) "text/plain;charset=utf-8"
SHCLX11FMT_TEXT:
  ( 4) "STRING"
  ( 5) "TEXT"
  ( 6) "text/plain"
SHCLX11FMT_HTML:
  ( 7) "text/html"
  ( 8) "text/html;charset=utf-8"
  ( 9) "application/x-moz-nativehtml"
SHCLX11FMT_BMP:
  (10) "image/bmp"
  (11) "image/x-bmp"
  (12) "image/x-MS-bmp"
It's a handy reference for interpreting Shared Clipboard log messages. Some remarks:

Windows can automatically convert between related clipboard formats: When a Windows user copies some text to the Windows clipboard, VirtualBox (as a potential target application) requests the clipboard contents as CF_UNICODETEXT. If the text has one of the older CF_TEXT (ANSI) or CF_OEMTEXT (ISO) formats, Windows implicitly converts the text. The same holds true for the bitmap formats.

In Windows, CF_UNICODETEXT is UTF-16 with CRLF line endings. In Linux, SHCLX11FMT_UTF8 is UTF-8 with LF line endings. VirtualBox does the necessary conversion.
Wick4711
Posts: 1
Joined: 1. Dec 2023, 09:33

Re: Clipboard Bi-Directional Copy-Paste Issue in Linux Host and Windows Guest

Post by Wick4711 »

I have the same problem and its not an actual problem it is for a long time (years).

My setup: fedora 38 with wayland/gnome (standard setup).
Virtualbox 7 (problem also exists with VB 6) without extension.

After starting the VM the clipboard works well. After some time (maybe after copying some troublesome information) it stops working (both directions).

What i experienced was that often it stop working wen i copy formatted text from my email program (groupwise).

It also often stop when copying links from edge (i think edge copy not only the link. It adds additional information (title of the page)).

clipboard in windows is still working, but on the other side when i insert the information it stuck (System dialog for killing the app because of to much time to wait).

Disabling the shared clipboard causes a long hang of the VM and a 50:50 change of crashing.
If disabling and enabling works without crash the clipboard works again.

In the time the VM hangs also the Virtualbox Manager GUI hangs.

Same Log Messages as above:
425:51:13.228694 Shared Clipboard: Requesting data in format 0x1 for X11 host failed with VERR_TIMEOUT
425:51:13.236421 Shared Clipboard: Converting VBox formats 'UNICODETEXT, HTML' to 'UTF8_STRING' for X11 (idxFmtX11=1, fmtX11=3, atomTarget='UTF8_STRING') failed, rc=VERR_TIMEOUT
425:51:13.237165 Shared Clipboard: Signalling host about guest clipboard data failed with VERR_NOT_FOUND
425:51:43.237001 Shared Clipboard: Requesting data in format 0x1 for X11 host failed with VERR_TIMEOUT
425:51:43.237051 Shared Clipboard: Converting VBox formats 'UNICODETEXT, HTML' to 'UTF8_STRING' for X11 (idxFmtX11=1, fmtX11=3, atomTarget='UTF8_STRING') failed, rc=VERR_TIMEOUT
Post Reply