xpra icon
Bug tracker and wiki

Opened 3 weeks ago

Last modified 3 weeks ago

#2312 assigned task

clipboard images with html5 client

Reported by: Antoine Martin Owned by: Antoine Martin
Priority: major Milestone: 3.0
Component: html5 Version: 2.5.x
Keywords: Cc:

Description (last modified by Antoine Martin)

We want to transfer the pixel data as image/png and set it as best we can using setData or newer methods (#1844).

See THE DEFINITIVE GUIDE TO COPYING AND PASTING IN JAVASCRIPT

The difficulty here is that because the html5 clibpoard is greedy, we need to choose png as soon as we get the clipboard event so we can send the binary data with the token.

Some pointers in ticket:812#comment:29

Attachments (2)

clipboard.html (2.5 KB) - added by Antoine Martin 3 weeks ago.
test page that crashes the chrome tab
clipboard-html5-images.patch (11.3 KB) - added by Antoine Martin 3 weeks ago.
support for images in and out with latest chrome - almost working

Download all attachments as: .zip

Change History (10)

comment:1 Changed 3 weeks ago by Antoine Martin

Description: modified (diff)
Status: newassigned

comment:2 Changed 3 weeks ago by Antoine Martin

More pointers:

Raising #1844.

comment:3 Changed 3 weeks ago by Antoine Martin

As per Chrome Platform Status: Asynchronous Clipboard API: Support for images and other data types is still under development.

comment:4 Changed 3 weeks ago by Antoine Martin

MDN: Clipboard: only Firefox has support for read() and write. (since Firefox 63)

comment:5 Changed 3 weeks ago by Antoine Martin

Firefox only: clipboard.setImageData The image is provided as an ArrayBuffer? containing the encoded image. JPEG and PNG formats are supported.

Chrome: chrome.clipboard setImageData : Since Chrome 76. Warning: this is the current Dev channel.

comment:6 Changed 3 weeks ago by Antoine Martin

The image API is now available in chrome beta: https://bugs.chromium.org/p/chromium/issues/detail?id=150835#c118 This can also be enabled in M75 (released in stable tomorrow) through enabling the experimental flag here:
chrome://flags/#enable-experimental-web-platform-features (use this as a link)

Last edited 3 weeks ago by Antoine Martin (previous) (diff)

Changed 3 weeks ago by Antoine Martin

Attachment: clipboard.html added

test page that crashes the chrome tab

Changed 3 weeks ago by Antoine Martin

support for images in and out with latest chrome - almost working

comment:7 Changed 3 weeks ago by Antoine Martin

The patch above almost works, but there is a problem with chrome: the tabs crash... reproducer in attachment/ticket/2312/clipboard.html.

With the new read() and write() API calls, we could modify the new clipboard code to work more like the regular X11 asynchronous clipboard and return the list of data types it supports, without bundling the data with it. Saving lots of bandwidth and making it more reliable when there are multiple options: the client application can then choose the format most suitable instead of us picking one.
This would require a reversible mapping from clipboard data types to the wire ones. Tricky?

It would be useful to collect the list of mimetypes we can get from the async API so we can handle them properly rather than assuming we just get UTF8 for text and image/png for images.


Related links:

Last edited 3 weeks ago by Antoine Martin (previous) (diff)

comment:8 Changed 3 weeks ago by Antoine Martin

Merged the image transfer clipboard code (disabled by default) in r22857.
(so it won't bitrot)

Note: See TracTickets for help on using tickets.