Skip to content
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

Consider Blob for access to raw buffers #65

Open
sandersdan opened this issue Jun 19, 2020 · 5 comments
Open

Consider Blob for access to raw buffers #65

sandersdan opened this issue Jun 19, 2020 · 5 comments
Labels
extension Interface changes that extend without breaking.

Comments

@sandersdan
Copy link
Contributor

Due to the lack of read-only ArrayBuffers, extra copying may be necessary to make some WebCodecs APIs safe.

Blobs however can be read-only. We should investigate whether supporting Blobs in some APIs would be beneficial.

@chcunningham
Copy link
Collaborator

IIUC, this still entails copying. When you construct the blob from an ArrayBuffer, the spec says you copy those bytes. When you get an ArrayBuffer via arrayBuffer(), I think this is again a copy (spec is less clear to me here).

@sandersdan
Copy link
Contributor Author

There is also the opposite case, where we decode a VideoFrame and then want to expose the contents. We can do so as a Blob without copying.

There is a proposal to be able to mmap Blobs in WASM, if that lands it could be very helpful.

@padenot
Copy link
Collaborator

padenot commented May 5, 2021

https://github.com/Jack-Works/proposal-readonly-arraybuffer
https://github.com/Jack-Works/proposal-arraybuffer-fixed-view

are two recent proposals in ES that would be helpful for this.

@chcunningham
Copy link
Collaborator

triage note: marking 'extension' as proposals above involve new methods/attributes without breaking.

@chcunningham chcunningham added the extension Interface changes that extend without breaking. label May 12, 2021
@surma
Copy link
Member

surma commented May 17, 2021

Related: It would be really nice from a developer experience standpoint if these APIs also consumed File and Blob, as that’s what you get from an <input type="file"> element.

Workaround for now is to do

const decoder = new ImageDecoder({
  type: file.type,
  data: new Response(file).body
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extension Interface changes that extend without breaking.
Projects
None yet
Development

No branches or pull requests

4 participants