Skip to content

restore selectAlternateInterface in camera worker#13

Merged
turbocrime merged 5 commits into
mainfrom
11-linux-iso-transfers-crash-chromium-with-invalid-argument-22-missing-selectalternateinterface-after-claiminterface
Apr 30, 2026
Merged

restore selectAlternateInterface in camera worker#13
turbocrime merged 5 commits into
mainfrom
11-linux-iso-transfers-crash-chromium-with-invalid-argument-22-missing-selectalternateinterface-after-claiminterface

Conversation

@turbocrime
Copy link
Copy Markdown
Owner

@turbocrime turbocrime commented Apr 29, 2026

Closes #11.

Summary

  • Restore selectAlternateInterface after claimInterface in the camera worker. The call was dropped in major refactor #4 (Oct 2025 refactor), which made Camera.setMode({ depth: ... }) crash the Chromium USB utility process on Linux with usb_device_handle_usbfs.cc Invalid argument (22). Linux usbfs needs an explicit SET_INTERFACE ioctl to reserve iso bandwidth before iso URB submission; macOS IOUSBLib was permissive enough to hide the regression.
  • Alt setting is read from iface.alternate.alternateSetting (matches pre-refactor behavior; defensive against SKU/firmware variants vs. hard-coding 0).
  • Extracted prepareCamDevice out of worker.ts so the claim → select-alt sequence is unit-testable in isolation (worker.ts has top-level self.addEventListener side effects that make direct import awkward). New tests pin the call ordering and descriptor-driven alt forwarding so this can't silently regress again.

Test plan

  • pnpm --filter @webnect/driver build clean (tsc)
  • pnpm --filter @webnect/driver test — 11/11 passing, 5 new under driver/test/prepare-cam-device.test.ts
  • biome clean on changed files
  • Manual: Linux Chromium + Kinect, Camera.setMode({ depth: ... }) streams depth without crashing the USB utility process; chromium-browser.log clean of Invalid argument (22)
  • Manual: macOS Chromium smoke — depth + video still streaming (no regression from the helper extraction)

🤖 Generated with Claude Code

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 29, 2026

🦋 Changeset detected

Latest commit: cdd9ac6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@webnect/driver Patch
demo Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@turbocrime turbocrime force-pushed the 11-linux-iso-transfers-crash-chromium-with-invalid-argument-22-missing-selectalternateinterface-after-claiminterface branch from c27527a to cdd9ac6 Compare April 30, 2026 00:35
@turbocrime turbocrime merged commit f6a7d4e into main Apr 30, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Linux iso transfers crash Chromium with Invalid argument (22) — missing selectAlternateInterface after claimInterface

1 participant