Open Bug 2053974 Opened 4 months ago Updated 12 days ago

Firefox 152 + PL2303 работает. Firefox 152 + CH340 (VID 0x1A86 PID 0x7523) немедленно закрывает ReadableStream (done:true, value:undefined) даже без подключённого UART-устройства.

Categories

(Core :: DOM: Web Serial, defect)

Firefox 152
defect

Tracking

()

UNCONFIRMED

People

(Reporter: tk-3107, Unassigned)

Details

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Safari/537.36

Steps to reproduce:

Firefox 152 + PL2303 работает.
Firefox 152 + CH340 (VID 0x1A86 PID 0x7523) немедленно закрывает ReadableStream (done:true, value:undefined) даже без подключённого UART-устройства.

  1. Connect a WCH CH340 USB-UART device (VID 0x1A86, PID 0x7523) to the computer.
  2. Open a web page using Firefox Web Serial API.
  3. Request and open the serial port:
const port = await navigator.serial.requestPort();

await port.open({
    baudRate: 57600
});
  1. Create a reader:
const reader = port.readable.getReader();
  1. Call:
const result = await reader.read();
console.log(result);
  1. Observe that Firefox immediately returns:
{
    value: undefined,
    done: true
}

The issue is reproducible even when no external UART device is connected to the CH340 TX/RX pins.

Actual results:

Firefox Web Serial API opens the CH340 device successfully, but the RX readable stream is closed immediately.

After calling reader.read(), it returns:

{ value: undefined, done: true }

No exception is thrown and no disconnect event is generated.

This happens even with no external device connected to the CH340 UART pins. The writable stream works correctly, but the readable stream terminates immediately.

The same code works correctly with Chromium-based browsers (Chrome, Opera, Yandex) and also works in Firefox with a PL2303 USB-UART adapter.

Expected results:

The ReadableStream should remain open after the serial port is opened.

reader.read() should wait for incoming serial data and resolve only when bytes are received, or when the port is explicitly closed.

The absence of incoming RX data should not cause the stream to finish with:

{ value: undefined, done: true }

The behavior should be the same as with other USB-UART adapters (for example PL2303) and Chromium-based browsers.

The Bugbug bot thinks this bug should belong to the 'Core::DOM: Device Interfaces' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → DOM: Device Interfaces
Product: Firefox → Core

Not sure if this is related to changes in bug 2021345, but pinging gstoll jic.

Flags: needinfo?(gstoll)

Thanks for the report!

Unfortunately this will be hard to reproduce without that hardware. As a first step, can you try using mozregression to see if this ever worked in the past? (I do think that it's possible bug 2021345 broke this)

Flags: needinfo?(gstoll) → needinfo?(tk-3107)
Component: DOM: Device Interfaces → DOM: Web Serial

After bashing my head against the wall for 2 hours, I found this bug report... So yes, can confirm the exact same issue - CH340 works in Chrome, but the readable stream is immediately closed in Firefox. I can try mozregression, but what would be a good starting date?

It's probably safest to go back to Fx 151 (so before bug 2021345 landed); probably 2026-04-15 would work.

No, it didn't work with the release version of Fx 151 either. So I've went through the betas:

  • 151.0b1: serial doesn't work meaningfully at all, the RX bytes are always echo of the TX bytes (?)
  • 151.0b2: works!
  • 151.0b3: works!
  • 151.0b4: worked once. Didn't work anymore after that.
  • 151.0b5 and later: doesn't work, as described in this report

Redirect a needinfo that is pending on an inactive user to the triage owner.
:gstoll, since the bug has recent activity, could you please find another way to get the information or close the bug as INCOMPLETE if it is not actionable?

For more information, please visit BugBot documentation.

Flags: needinfo?(tk-3107) → needinfo?(gstoll)

Yeah, I'm guessing 151.0b1 was missing some important fixes. This timeline is helpful, thanks!

Flags: needinfo?(gstoll)

I am having this same bug on usbVendorId: 0x1A86, usbProductId: 0x7523. I'll catch up and see if I can help with more details in a bit. I'm on a somewhat tight timeline, I'm hoping to see this bug fixed in 7 days (otherwise we might only have chrome support for however long it takes to fix).

Bottom line: Older drivers are supported on chrome, not firefox. Latest CH340 driver from https://www.wch-ic.com/downloads/CH341SER_ZIP.html functions.

(To my previous post: I see firefox release cadence makes it unlikely to be out when I need it, oh well)

Complex hardware is not needed, I am getting this same bug on a super cheap (~$2) Arduino Nano clone (most clones use CH430 as it is cheaper than the FTDI FT232RL).

If someone with a CH340 arduino wants to reproduce this, upload this code:

void setup() { Serial.begin(115200); }
void loop() { Serial.println("HELLO FROM NANO"); delay(500); }

Go to any web terminal (https://googlechromelabs.github.io/serial-terminal/) and you won't get anything from it. Chrome works.

I am having this issue on v3.9.2024.9 of the CH340 driver from WCH.

However, it turns out that 4.0.2026.02, the latest version, does work on firefox. This seems more like firefox is incompatible with specific versions of the driver (something chrome handles just fine), because v3.9.2024.9 did not work with firefox v151.0 for me.

In case it helps, I recall a similar bug with the go-serial library losing support for reading serial messages past a 2025 update, the PR that fixed that is here https://github.com/bugst/go-serial/commit/f0e4a45720a879803364f829e5e633e6f8f1be9b. Could be something related to this change in the driver.

The severity field is not set for this bug.
:gstoll, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(gstoll)
Severity: -- → S3
Flags: needinfo?(gstoll)

Confirming on Firefox 160.0, Windows (64-bit), with an Arduino Nano clone using a CH340C (usbVendorId 0x1A86 / 6790, usbProductId 0x7523 / 29987), Windows CH340 driver.

After port.open() (115200, 57600 and 19200 baud tried), reader.read() resolves with {done: true} at once. Each new port.readable also ends immediately, every time the page gets a new reader. Writes succeed and setSignals() works (the board restarts on the DTR pulse), but no byte is ever received. The same page, device and port work in Chrome 157 and in the Arduino IDE on the same computer.

Log from the page:
serial: signals after open: {"clearToSend":false,"dataCarrierDetect":false,"dataSetReady":false,"ringIndicator":false}
serial: read stream ended, reading on (repeats about every 20 ms)
serial: wrote 4 bytes (x6)
connect: no answer at 115200

Page: https://jonsolberg.se:8080/MidiMuppet/
Source: https://github.com/jonsolberg/midi_muppet_multi_4btn (editor/editor.src.html, pedal.readLoop)

You need to log in before you can comment on or make changes to this bug.