Skip to content

fix: crash on navigator.usb.requestDevice() in in-memory sessions - #54608

Merged
codebytere merged 1 commit into
mainfrom
fix-usb-in-memory-crash
Oct 1, 2026
Merged

codebytere merged 1 commit into
mainfrom
fix-usb-in-memory-crash

Conversation

@codebytere

Copy link
Copy Markdown
Member

Description of Change

Fixes #52383.

Calling navigator.usb.requestDevice() in an in-memory session (a partition without the persist: prefix) crashed the main process. In-memory sessions are off the record, and UsbChooserContextFactory used the default for that case, which is to create no UsbChooserContext at all, so the chooser dereferenced null.

In-memory sessions now get their own UsbChooserContext, as they already do for WebHID and Web Serial. Apart from the crash, WebUSB could not be used in these sessions at all: getDevices() always resolved with an empty list, even when the device permission handler allowed the device, and the page never got connect or disconnect. All of it, including forget() and the session's usb-device-added, usb-device-removed and usb-device-revoked events, now works as in a persistent session. Access is still decided per session by the same handlers.

The existing in-memory spec queried the default session's window by mistake. It now uses the in-memory window and covers requestDevice(); without the fix it takes the test runner down with SIGSEGV. Tested on Linux with no USB device attached, so the paths that need a device are untested.

#53657 has the same fix inside a larger feature. This takes it out on its own so that it can be backported.

Checklist

Release Notes

Notes: Fixed a crash on navigator.usb.requestDevice() in in-memory sessions.

UsbChooserContextFactory did not override GetBrowserContextToUse(), so
off-the-record contexts got no UsbChooserContext and the chooser
controller dereferenced null. Give in-memory sessions their own context,
as the HID and serial factories do.
@codebytere codebytere added semver/patch backwards-compatible bug fixes target/44-x-y PR should also be added to the "44-x-y" branch. target/45-x-y PR should also be added to the "45-x-y" branch. labels Sep 30, 2026
@codebytere
codebytere merged commit df79406 into main Oct 1, 2026
138 of 140 checks passed
@codebytere
codebytere deleted the fix-usb-in-memory-crash branch October 1, 2026 07:42
@release-clerk

release-clerk Bot commented Oct 1, 2026

Copy link
Copy Markdown

Release Notes Persisted

Fixed a crash on navigator.usb.requestDevice() in in-memory sessions.

@trop

trop Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "45-x-y", please check out #54615

@trop trop Bot added the in-flight/45-x-y label Oct 1, 2026
@trop

trop Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "44-x-y", please check out #54616

@trop trop Bot added in-flight/44-x-y merged/45-x-y PR was merged to the "45-x-y" branch. merged/44-x-y PR was merged to the "44-x-y" branch. and removed target/45-x-y PR should also be added to the "45-x-y" branch. target/44-x-y PR should also be added to the "44-x-y" branch. in-flight/45-x-y in-flight/44-x-y labels Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

46-x-y merged/44-x-y PR was merged to the "44-x-y" branch. merged/45-x-y PR was merged to the "45-x-y" branch. semver/patch backwards-compatible bug fixes

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

[Bug]: navigator.usb.requestDevice() crashes the browser process (SIGSEGV) on a named session partition

3 participants