Re: [w3c/FileAPI] Reslove Blob to an existing ArrayBuffer (#143)

> > You can message a `File` object to a worker.
> 
> Oops, didn't know of that. Thanks for pointing out.
> 
> After checking [the definition of File](https://w3c.github.io/FileAPI/#dfn-file), and [structuredserializeinternal in the HTML spec](https://html.spec.whatwg.org/multipage/structured-data.html#structuredserializeinternal), I realised I had misunderstood `File`.
> 
> > If that's not sufficient for some reason it might be best to open a separate issue for that as it seems different from reading a blob into an existing buffer.
> 
> Since it's still connected to the topic "read Blob into an allocated ArrayBuffer", just a special case of it. So I decided to post it in the same issue.

Would someone be willing to confirm that the following line doesn't copy the underlying file contents?

```js
    ctx.postMessage(file);
```

If I understand @Zhang-Junzhi's comments correctly, then they conclude that a file's contents isn't copied into another buffer as it is passed via `postMessage()`.  

I read the two documents linked to above and don't understand them well enough to come to the same conclusion.

Context: People like to drop huge files (~1GB) into my web application, and I need to post them to workers.  Copying buffers exceeds Chrome's memory limits:

```
DataCloneError
Failed to execute 'postMessage' on 'Worker': Data cannot be cloned, out of memory.
```

-- 
Reply to this email directly or view it on GitHub:
https://github.com/w3c/FileAPI/issues/143#issuecomment-1133231523
You are receiving this because you are subscribed to this thread.

Message ID: <w3c/FileAPI/issues/143/1133231523@github.com>

Received on Friday, 20 May 2022 19:14:55 UTC