-
Notifications
You must be signed in to change notification settings - Fork 178
Description
Environment:
Windows Version: Windows 11 Education Version 23H2 (OS Build 22631.5189)
WSL2 Kernel Version (Custom Built): 6.6.87.1-microsoft-standard-WSL2+ (built from WSL2-Linux-Kernel repository to enable uvcvideo module)
WSL2 Distribution: Ubuntu 22.04 LTS
usbipd-win Version: 5.0.0-10+Branch.master.Sha.7a8c00f5603c85cfce48f0c439c7c90763f1e105
Webcam Model: Generic USB Camera (VendorID:0bda, ProductID:3035, Name from usbipd: "USB Camera, USB Audio")
Docker Version: Docker version 28.0.4, build b8034c0
SRS Version (if applicable): Tried ossrs/srs:5 and ossrs/srs:6.0-d6
Describe the bug:
After successfully building a custom WSL2 kernel with the uvcvideo module enabled and attached via usbipd-win, the webcam is recognized within the WSL2 Ubuntu distribution, and device files (/dev/video0, /dev/video1) are created.
However, applications attempting to read the video stream from these devices fail.
Symptoms:
ffmpeg Test:
Running ffmpeg -f v4l2 -i /dev/video0 -vframes 1 /tmp/test.jpg results in:
[video4linux2,v4l2 @ 0x...] ioctl(VIDIOC_STREAMON): Connection timed out
/dev/video0: Connection timed out
Use code with caution.
SRS Server (WebRTC via WHIP/RTC Publisher):
The SRS demo publisher page (whip.html or rtc_publisher.html) can sometimes briefly show a preview of the webcam feed.
However, attempts to publish the stream consistently lead to errors in the SRS server logs, such as:
RtcStreamBusy (Stream already exists or busy)
client disconnect peer. ret=1007
DTLS_HANG
The browser console for the publisher page often shows getUserMedia NotReadableError: Could not start video source when trying to access the camera stream via SRS.
dmesg Log in WSL2:
Crucially, after usbipd attach and during attempts to access the camera, dmesg frequently logs:
vhci_hcd: unlink->seqnum XX
vhci_hcd: urb->status -104
Use code with caution.
The urb->status -104 corresponds to ECONNRESET (Connection reset by peer), suggesting an issue at the USB/IP communication layer between Windows and WSL2.
To Reproduce:
Install usbipd-win on Windows.
Build a custom WSL2 kernel (e.g., based on linux-msft-wsl-6.6.y) with CONFIG_USB_VIDEO_CLASS=m (uvcvideo module) enabled in menuconfig.
Configure WSL2 to use the custom kernel via .wslconfig.
Boot WSL2 (Ubuntu 22.04/24.04).
Load the uvcvideo module (sudo modprobe uvcvideo).
On Windows PowerShell, usbipd bind --busid <webcam_busid> and then usbipd attach --wsl --busid <webcam_busid>.
Verify /dev/video* device files are created in WSL2.
Attempt to access the camera stream using ffmpeg or a WebRTC application like SRS serverpublisher demo.
Expected behavior:
Applications within WSL2 should be able to read the video stream from the attached webcam डिवाइस without Connection timed out or NotReadableError, and USB/IP communication should be stable without ECONNRESET errors.
Actual behavior:
Despite the device files being present and the uvcvideo module loaded, applications cannot reliably read the video stream. The ECONNRESET error in dmesg points to an underlying instability in the USB/IP connection when actual data transfer is attempted.
Additional context:
The issue persists across different USB ports.
Firewall rules for usbipd (port 3240) appear to be correctly configured.
Problem occurs even when the webcam is the only USB device attached via usbipd.
Detaching the webcam with usbipd detach successfully returns control to Windows, and the webcam functions normally on the Windows host.
This ECONNRESET issue seems to be the root cause preventing stable webcam operation in WSL2, even after building a custom kernel with the necessary drivers. Any insights or workarounds would be greatly appreciated.