Repository navigation
fix: crash on navigator.usb.requestDevice() in in-memory sessions - #54608
Merged
Merged
Conversation
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.
VerteDinde
approved these changes
Sep 30, 2026
MarshallOfSound
approved these changes
Sep 30, 2026
|
Release Notes Persisted
|
This was referenced Oct 1, 2026
Contributor
|
I have automatically backported this PR to "45-x-y", please check out #54615 |
Contributor
|
I have automatically backported this PR to "44-x-y", please check out #54616 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of Change
Fixes #52383.
Calling
navigator.usb.requestDevice()in an in-memory session (a partition without thepersist:prefix) crashed the main process. In-memory sessions are off the record, andUsbChooserContextFactoryused the default for that case, which is to create noUsbChooserContextat 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 gotconnectordisconnect. All of it, includingforget()and the session'susb-device-added,usb-device-removedandusb-device-revokedevents, 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 withSIGSEGV. 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.