Full explainer should not be necessary; see the Summary section below for an overview of this change
https://wicg.github.io/serial/#readable-attribute
The SerialPort interface provides a ReadableStream and WritableStream for communication with the connected device. This change updates the underlying data source for the ReadableStream to make it a readable byte stream. This is how this stream should have originally been specified but at the time Chromium did not support implementing byte streams in C++. This has recently been fixed and so this change can be implemented. The change is backwards compatible because existing code calling port.readable.getReader() will continue to work while new code can detect support for BYOB readers by calling getReader({ mode: 'byob' }) and catching the TypeError thrown by older implementations.
BYOB readers allow developers to specify the buffer into which data is read instead of the stream allocating a buffer for each chunk. In addition to the potential reduction in memory pressure this allows script to control how much data is received in a chunk as the stream cannot return more than there is space for in the provided buffer.
The ability to read a particular amount of data from a port has been a frequently requested feature by developers used to programming against the Windows and POSIX APIs for serial devices, which operate on this same "bring your own buffer" principle. The current API, in contrast, requires developers to code defensively against extra unwanted data instead of receiving only what they are ready to process.
https://github.com/w3ctag/design-reviews/issues/431
https://github.com/w3ctag/design-reviews/issues/567
Not applicable, the W3C TAG has already reviewed the Web Serial and byte stream APIs independently. This change integrates them in an obvious manner.
Gecko: Harmful (https://mozilla.github.io/standards-positions/#webserial)
Mozilla is opposed to the Web Serial API in general. This incremental change is not expected to change their position.
WebKit: Negative (https://webkit.org/tracking-prevention)
Apple is opposed to the Web Serial API in general. This incremental change is not expected to change their position.
Web developers: Positive (https://github.com/WICG/serial/issues/125#issuecomment-786937083)
Multiple developers have asked for the ability to read a specific number of bytes from the port, which is enabled by using a BYOB reader.
WebView is not supported because this API is not available on Android.
This feature is debuggable using the normal DevTools JavaScript debugger.
No, the Web Serial API is only available on desktop platforms because Android does not provide a serial API. A polyfill for Android which uses WebUSB (and can be expanded using Web Bluetooth) provides an implementation of the missing platform features. An issue has been filed to update the polyfill with BYOB reader support.
Yes (in the patch)
No
https://bugs.chromium.org/p/chromium/issues/detail?id=1182905
https://googlechromelabs.github.io/serial-terminal
M-106
https://chromestatus.com/feature/6716022686482432
--
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/4c022c60-2d3e-4976-883d-80cbe6639845n%40chromium.org.
I have one question about what you get back with you call getReader(). You write that such code will continue to work. Does that mean that the return value is the same or does it mean that what you get back has the exact same API surface as what you got before?
/Daniel
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/e077fb3a-6757-589b-b240-34bf19ace508%40chromium.org.
I have one question about what you get back with you call getReader(). You write that such code will continue to work. Does that mean that the return value is the same or does it mean that what you get back has the exact same API surface as what you got before?
LGTM3
/Daniel