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

WebSerial support #12

Open
4 tasks
rrbutani opened this issue Jul 28, 2022 · 1 comment
Open
4 tasks

WebSerial support #12

rrbutani opened this issue Jul 28, 2022 · 1 comment
Assignees
Labels
enhancement New feature or request T-devices Topic: TUI interaction with devices T-wasm Topic: WASM support

Comments

@rrbutani
Copy link
Member

rrbutani commented Jul 28, 2022

what

We want to have the Web TUI support using the WebSerial API to communicate with actual devices in browsers that support it.

This is a tracking issue for this effort.


This is a large project that mostly involves making changes in external projects

Within tui this will also necessitate large changes:

  • Widget::update and Widget::render will need to become async to accommodate an async Control API. Perhaps these should become async on all platforms and not just wasm?
  • Everything above Widget will need to become async too.

open questions

@rrbutani rrbutani added enhancement New feature or request T-wasm Topic: WASM support T-devices Topic: TUI interaction with devices labels Jul 28, 2022
@rrbutani rrbutani self-assigned this Jul 28, 2022
@rrbutani
Copy link
Member Author

rrbutani commented Sep 4, 2022

It may also be worth adding WebUSB support, both to the Web TUI as well as to devices.

This would let Android users use the TUI with devices; Chrome (and friends) on Android do not support WebSerial but do support WebUSB.

usbd-webusb would let us easily have devices expose themselves to WebUSB supporting devices and from there we can have the Web TUI use the existing USB CDC-ACM via WebSerial (where supported) or via a WebUSB based serial driver (like this one).

As detailed here, Android does not ship with a USB CDC-ACM class driver which is why we can use a WebUSB based driver to claim the existing serial device class. This means that the above strategy will not support browsers/platforms that:

  • do not have WebSerial
  • do have WebUSB
  • do have a OS-level USB CDC-ACM class driver (preventing us from using WebUSB to register our own)
    • I'm assuming this is all platforms other than Android

In order to support such platforms we'd need to make our own USB class (which can be isomorphic to USB CDC-ACM) and probably have devices expose this alongside CDC-ACM so we don't drop support for existing serial based flows for the native TUI (necessitating that the native TUI use a custom USB class driver everywhere seems problematic and likely to cost us in terms of platform support).

This seems like a small niche anyways, just older Chrome/Edge/Opera versions: 61 to 88 for Chrome and Edge, 48 to 75 for Opera; ~1.25% of global usage as of this writing (as per caniuse).

Shipping our own custom USB class that we then use via WebUSB, in all browsers, while still retaining the USB CDC-ACM class for the native TUI, also doesn't seem worth the effort either (the list of platform considerations for using WebUSB are also somewhat daunting).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request T-devices Topic: TUI interaction with devices T-wasm Topic: WASM support
Projects
None yet
Development

No branches or pull requests

1 participant