-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Delayed clipboard rendering API shape. #423
Comments
It looks like we still need a resolution for this issue. There are mainly three different API shapes for delay rendering support:
This provides a callback for the formats being delay rendered. It's ergonomical to the web authors and doesn't have any race issue when formats are written to the clipboard as the browsers can check which formats have callback associated with them and which ones have data already populated during
This has several issues:
Issues with this approach:
We would like to propose the first option:
|
RESOLUTION: Option 1 with the callback approach is the resolution for delay rendering |
Hmm, I was not fully understanding this issue back in the meeting, as my focus was on a different issue. To reiterate what @smaug---- said with some code, can this be: navigator.clipboard.write(new ClipboardItem({
'text/html': new ReadableStream({
pull(controller) {
// This will only be called when the consumer reads it, so this is still about "have callback".
controller.enqueue(bytes);
},
type: "bytes",
}, { highWaterMark: 0 }),
})); I think this can coexist with callback, though. |
To coexist with callbacks, if I understand the union issue correctly, that would have to be:
No? |
I'm not sure why promise would be needed there? |
My understanding is that we can't have a union of |
Having Promise in Web IDL doesn't mean that the user needs to explicitly pass Promise, the IDL layer will automatically wrap it with a promise. |
Oh, that's great! |
What would the IDL look like? Can Blob APIs be used to stream data instead? Basically, in the callback, can the web authors use the streaming APIs to write data into the Blob? If so, then I'm not sure if this option would be helpful to add to the ClipboardItem IDL -- creates complexity in how the different chunks of data get written to the clipboard when the format is being requested during paste. |
One can convert blobs into streams and streams into blobs, but a blob itself is by design a readonly snapshot object that does not change after its construction. Not sure that's the proper answer for your question, could you provide some example in your mind if not?
One cannot "write data into the (existing) blob" in any way as Blob is designed to be constant. But you can create a new blob from a stream: |
Right, that is why I'm confused if a
Sorry for the confusion, but that is what I meant in |
Using a stream could let implementations to optimize memory usage, as an example. |
Having to get a memory blob (which is what you get when converting from stream) means potentially having to consume huge memory. Having stream can reduce that. And also the consumer can get the first chunk of bytes earlier without waiting for the complete data. I think another important question is, though: does any OS support reading from clipboard progressively? |
Even if OSes didn't support that, streaming from the content/renderer process to the process which would then interact with the OS could save quite a bit memory in many cases. |
Tagging few people who would be interested in this discussion. |
From #417 There are few comments about the shape of the new delayed rendering API in the async clipboard API. Creating this issue to continue the discussion here.
Explainer: https://github.com/MicrosoftEdge/MSEdgeExplainers/blob/main/DelayedClipboard/DelayedClipboardRenderingExplainer.md
Proposed solution: Add a callback to ClipboardItemData
Discussions related to this:
@annevk asked:
This led to the following discussions about the shape of the API:
@evanstade @sanketj @tilgovi @inexorabletash @anaskim @whsieh
The text was updated successfully, but these errors were encountered: