Re: [whatwg/streams] Allow other specifications to create readable byte streams (#1121)

> To accomplish this today I guess you would _not_ pass autoAllocateChunkSize, and then you'd branch:
> 
> * If there's a BYOB request, try to fill the BYOB request's buffer, and even if it's not filled, give them back the full buffer. (In this scenario, does options["bufferSize"] just get ignored?)

That's an interesting question. As currently implemented in Chromium there is a shared memory buffer between the browser process and renderer process and the size of the buffer is options["bufferSize"]. Reading from the serial port occurs in the browser process so no matter how large the BYOB request's buffer is there will never be more than options["bufferSize"] bytes available to copy into it. The fetch() API uses a similar architecture, but with the fixed 64k buffer @MattiasBuelens mentioned.

BYOB definitely introduces more opportunities for implementation details like this to be visible to developers.

> * If there's no BYOB request, then use options["bufferSize"] to request bytes from the OS, and enqueue the resulting buffer (which might be smaller than options["bufferSize"]).

The Web Serial API pull steps currently say to read up to options["bufferSize"] bytes and then put them into a new ArrayBuffer whose length is the number of bytes read. I think it would be reasonable to add a note that the constructed ArrayBuffer _can_ be up to options["bufferSize"] bytes long (or any length) and it is up to the implementation to decide which is more efficient to implement.



-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/issues/1121#issuecomment-815369371

Received on Thursday, 8 April 2021 00:55:25 UTC