Web-Facing Change PSA: Write `image/svg+xml` content in UTF-8 format on Windows.

186 views
Skip to first unread message

Anupam Snigdha

unread,
Jun 12, 2024, 2:43:49 PM (6 days ago) Jun 12
to blink-dev, Sanket Joshi (EDGE), Christine Hollingsworth
Contact emails

Specification

Design docs
None. See summary.

Summary
On Windows, popular native apps [1] use UTF-8 format to read/write SVG images from/to clipboard.

Proposal is to switch to UTF-8 on Windows while writing `image/svg+xml` format to the clipboard. This is similar to the HTML format where we use UTF-8 on Windows. When SVG image content is read from the clipboard, Chromium converts it into UTF-16.

In M124, support for `image/svg+xml` native format was shipped in async clipboard APIs. In Chromium, SVG image is written to the clipboard in UTF-16 format on Windows. Many popular apps [1] on Windows use UTF-8 encoding to read/write SVG images from/to clipboard. Hence, when a user tries to copy SVG images from Chromium and paste into one of these native apps, the image will be parsed incorrectly and will not render after paste.
This can be reproduced by visiting https://webdbg.com/test/svg/ or https://heathered-spotty-fin.glitch.me/ to copy `image/svg+xml` to the clipboard and paste it into native Word.
The paste succeeds but the image doesn't render because of the invalid encoding.

Proposal is to switch to UTF-8 on Windows while writing `image/svg+xml` format to the clipboard. This is similar to the HTML format where we use UTF-8 on Windows too. [2]

Alternative considered
It was attempted to add a BOM character to the UTF-16LE encoded SVG image content, but the sampled native apps [1] were unable to parse the images correctly.

[1] Here is an inventory of all the sampled native apps that read/write `image/svg+xml` format: https://docs.google.com/document/d/1ULlihA0FOJOqcyD9MgzLZrAbk0uTQPJqDPuPJ2aiuS4/edit?usp=sharing

Blink component

Search tags

TAG review
None

TAG review status
Not applicable because it doesn’t change the API surface.

Risks


Interoperability and Compatibility
If a native app expects the SVG image content to be in UTF-16 format in the clipboard, then there is risk that paste might break in those apps after this change.

However, after testing against 30 popular native Windows apps that are relevant to document editing, we’ve found no apps that relied on UTF-16. All used UTF-8 encoding scheme to read/write SVG images from/to clipboard. Therefore we evaluate that there is minimal compatibility risk associated with this change.

Currently, the SVG content is converted from UTF-8 to UTF-16 in Chromium before writing to the clipboard. With this proposal, we are just removing this conversion, so there is no negative impact to performance.


Gecko: No Signal. SVG format support is not implemented by Firefox, but they have plans to implement it in the future.

WebKit: No Signal. SVG format support is not implemented by Safari, but they have plans to implement it in the future.


Other signals:

Ergonomics
Not applicable because it doesn’t change the API surface.


Activation
Not applicable because it doesn’t change the API surface.


Security
Not applicable because it doesn’t reveal any new information.


WebView application risks
Does this intent deprecate or change behavior of existing APIs, such that it has potentially high risk for Android WebView-based applications?
None as this change only impacts Windows.


Debuggability
N/A as it is about writing UTF-8 encoded SVG image to the system clipboard. There is already support for debugging async clipboard APIs in DevTools.


Will this feature be supported on all six Blink platforms (Windows, Mac, Linux, ChromeOS, Android, and Android WebView)?
This change is only on Windows to make it consistent with other native apps that read/write UTF-8 encoded SVG images from/to the clipboard.


Is this feature fully tested by web-platform-tests?
No,the behavior change is not testable on WPT tests because it requires an interaction with a native app.


Flag name on chrome://flags
UseUtf8EncodingForSvgImage

Finch feature name
UseUtf8EncodingForSvgImage

Non-finch justification
None

Requires code in //chrome?
False

Tracking bug

Estimated milestones
Shipping on desktop
127


Anticipated spec changes
Open questions about a feature may be a source of future web compat or interop issues. Please list open issues (e.g. links to known github issues in the project for the feature specification) whose resolution may introduce web compat/interop risk (e.g., changing to naming or structure of the API in a non-backward-compatible way).
None

Link to entry on the Chrome Platform Status

This intent message was generated by Chrome Platform Status.



Thanks,
Anupam

Sent from Outlook

Jeffrey Yasskin

unread,
Jun 12, 2024, 2:57:00 PM (6 days ago) Jun 12
to Anupam Snigdha, blink-dev, Sanket Joshi (EDGE), Christine Hollingsworth
Could you add this detail to the Clipboard spec, since it seems to be needed for programs to be interoperable?

Thanks,
Jeffrey

--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/SJ0PR00MB0991689EFE2EB91B29BDFAE1CFC02%40SJ0PR00MB0991.namprd00.prod.outlook.com.

Anupam Snigdha

unread,
Jun 12, 2024, 4:58:50 PM (6 days ago) Jun 12
to Jeffrey Yasskin, blink-dev, Sanket Joshi (EDGE), Christine Hollingsworth

Thanks,
Anupam

From: Jeffrey Yasskin <jyas...@chromium.org>
Sent: Wednesday, June 12, 2024 11:56 AM
To: Anupam Snigdha <sni...@microsoft.com>
Cc: blink-dev <blin...@chromium.org>; Sanket Joshi (EDGE) <sa...@microsoft.com>; Christine Hollingsworth <chris...@google.com>
Subject: [EXTERNAL] Re: [blink-dev] Web-Facing Change PSA: Write `image/svg+xml` content in UTF-8 format on Windows.
 
You don't often get email from jyas...@chromium.org. Learn why this is important

Jeffrey Yasskin

unread,
Jun 12, 2024, 6:01:52 PM (6 days ago) Jun 12
to Anupam Snigdha, Jeffrey Yasskin, blink-dev, Sanket Joshi (EDGE), Christine Hollingsworth
The text in https://w3c.github.io/clipboard-apis/#to-write-blobs-to-clipboard says to decode from UTF-8 bytes into scalar values, and then to write those scalar values into the clipboard. My impression of the change you're announcing in this thread is that the system clipboard actually contains bytes rather than scalar values, and it matters whether those bytes are UTF-8 or UTF-16. That would imply that you should change the spec to match, unless I'm misreading something?

Jeffrey

Anupam Snigdha

unread,
Jun 13, 2024, 12:52:36 PM (5 days ago) Jun 13
to Jeffrey Yasskin, blink-dev, Sanket Joshi (EDGE), Christine Hollingsworth
Thinking about it a little more, I think we need to change the spec text to account for PNG images and other formats as well, so just having this text in the spec for all formats doesn't make sense. Also, you're right that it doesn't describe the changes being proposed here.
I filed a spec issue (https://github.com/w3c/clipboard-apis/issues/217) and discussed with the Editing WG. The consensus is to remove this text and file another issue to investigate how this needs to be addressed properly for all supported formats. I'll work on that next.
Thanks!


From: Jeffrey Yasskin <jyas...@chromium.org>
Sent: Wednesday, June 12, 2024 3:01 PM
To: Anupam Snigdha <sni...@microsoft.com>
Cc: Jeffrey Yasskin <jyas...@chromium.org>; blink-dev <blin...@chromium.org>; Sanket Joshi (EDGE) <sa...@microsoft.com>; Christine Hollingsworth <chris...@google.com>
Subject: Re: [EXTERNAL] Re: [blink-dev] Web-Facing Change PSA: Write `image/svg+xml` content in UTF-8 format on Windows.
 

Jeffrey Yasskin

unread,
Jun 13, 2024, 1:00:06 PM (5 days ago) Jun 13
to Anupam Snigdha, Jeffrey Yasskin, blink-dev, Sanket Joshi (EDGE), Christine Hollingsworth
Thanks!
Reply all
Reply to author
Forward
0 new messages