Hi Stanislav, Additionally, regarding your error of "`Failed to execute 'requestDevice' on 'HID': Script context has shut down.` error :\" I assumed you hit this by invoking navigator.hid.requestDevice(...) in service worker context. The requestDevice API isn't available to service workers context per design. You could refer to the sample <https://github.com/chengweih001/chrome-extension-v3-starter> I provided earlier to know how to grant permission to HID devices for the extension with service workers.
FYI, thank you for reporting this issue and we found we shouldn't even reveal requestDevice API in service worker context so we have https://bugs.chromium.org/p/chromium/issues/detail?id=1374919 to fix this. Hope with this fix it will be more clear requestDevice isn't available in service worker context. Best Regards Jack On Mon, Oct 17, 2022 at 12:37 AM Stanislav Titenko <[email protected]> wrote: > Cool, thanks! Will try > > On Friday, October 14, 2022 at 7:50:37 PM UTC+2 [email protected] wrote: > >> Hi Stanislav, >> >> You can try to use the prototype in >> https://github.com/chengweih001/chrome-extension-v3-starter, this is a >> very simple and raw prototype but it should work for demo purposes. >> >> Please be aware HID access on service workers is required >> explicitly enabling >> chrome://flags#enable-web-hid-on-extension-service-worker to have this >> feature (by default it is disabled). >> >> If you still have an issue then please open a bug in crbug.com against >> component *blink>HID. *I will follow up further there for you. >> >> Best Regards >> Jack >> >> >> On Fri, Oct 14, 2022 at 9:48 AM Stanislav Titenko <[email protected]> wrote: >> >>> Hey! >>> >>> Is there any prototype for this? I'm trying to connect from my manifest >>> v3 extension to HID device. Currently just trying to send message from >>> popup in response for user action, and handle this message in service >>> worker, creating request for devices. >>> Unfortunately for now I only have `Failed to execute 'requestDevice' on >>> 'HID': Script context has shut down.` error :\ >>> >>> Would appreciate any help on this >>> >>> On Thursday, June 30, 2022 at 7:05:40 PM UTC+2 [email protected] wrote: >>> >>>> + telbahnasawy (device-api team TPM) >>>> >>>> On Wednesday, June 22, 2022 at 10:39:17 AM UTC-7 Jack Hsieh wrote: >>>> >>>>> Contact emails >>>>> >>>>> >>>>> *[email protected], [email protected]*Explainer >>>>> >>>>> >>>>> *https://github.com/WICG/webhid/blob/main/WEBHID_IN_EXTENSION_SERVICE_WORKERS_EXPLAINER.md >>>>> <https://github.com/WICG/webhid/blob/main/WEBHID_IN_EXTENSION_SERVICE_WORKERS_EXPLAINER.md>* >>>>> Specification >>>>> >>>>> >>>>> *https://wicg.github.io/webhid/ <https://wicg.github.io/webhid/>* >>>>> Summary >>>>> >>>>> >>>>> >>>>> *Allows web developers to use WebHID API when responding to extension >>>>> events by exposing WebHID API to Service Workers registered by browser >>>>> extensions. This API will not yet be exposed to Service Workers registered >>>>> by sites but the implementation experience gained by supporting the API >>>>> for >>>>> extensions will be valuable for such a future project.*Blink component >>>>> >>>>> >>>>> *Blink >>>>> <https://bugs.chromium.org/p/chromium/issues/list?q=component:Blink>>HID* >>>>> Motivation >>>>> >>>>> >>>>> *As Chrome Apps APIs chrome.hid will soon be deprecated >>>>> <https://developer.chrome.com/docs/apps/migration/>, developers are >>>>> encouraged to migrate to web apps or Chrome Extensions. For the Chrome >>>>> Extension case, Manifest V3 deprecates the background page and requires >>>>> developers to migrate to service workers >>>>> <https://developer.chrome.com/docs/extensions/mv3/migrating_to_service_workers/>. >>>>> As a result, it is required to support WebHID in Extension Service >>>>> Workers.* >>>>> Risks >>>>> Interoperability and Compatibility >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> *Gecko: No signal, we have asked for a position on WebHID in >>>>> extensions >>>>> (https://github.com/mozilla/standards-positions/issues/459#issuecomment-1162459878 >>>>> <https://github.com/mozilla/standards-positions/issues/459#issuecomment-1162459878>).WebKit: >>>>> No signal, opposed to the Web Serial API in general.Web developers: >>>>> Extension developers previously used WebHID and other device APIs from the >>>>> background page and have requested that it continues to be available after >>>>> migrating to Manifest V3.Other signals: Extension team approves of >>>>> exposing >>>>> these APIs to extension service workers. >>>>> (https://docs.google.com/document/d/1s01BVkz-mb18p-gwXmzhM6DdioOh0JMzx_kCJzsLd7U/edit >>>>> <https://docs.google.com/document/d/1s01BVkz-mb18p-gwXmzhM6DdioOh0JMzx_kCJzsLd7U/edit?usp=sharing>, >>>>> internal-only)*WebView application risks >>>>> >>>>> >>>>> >>>>> *N/A. WebHID isn’t available on Android.*Debuggability >>>>> >>>>> >>>>> >>>>> *Devtools*Is this feature fully tested by web-platform-tests >>>>> <https://chromium.googlesource.com/chromium/src/+/main/docs/testing/web_platform_tests.md> >>>>> ? >>>>> >>>>> >>>>> *No*Flag name >>>>> >>>>> >>>>> >>>>> *chrome://flags/#enable-web-hid-on-extension-service-worker*Requires >>>>> code in //chrome? >>>>> >>>>> >>>>> *Yes*Tracking bug >>>>> >>>>> >>>>> *https://bugs.chromium.org/p/chromium/issues/detail?id=1303195 >>>>> <https://bugs.chromium.org/p/chromium/issues/detail?id=1303195>*Launch >>>>> bug >>>>> >>>>> >>>>> *https://bugs.chromium.org/p/chromium/issues/detail?id=1322258 >>>>> <https://bugs.chromium.org/p/chromium/issues/detail?id=1322258>*Estimated >>>>> milestones >>>>> >>>>> >>>>> >>>>> *106*Link to entry on the Chrome Platform Status >>>>> >>>>> https://chromestatus.com/feature/6305751386554368 >>>>> >>>>> -- You received this message because you are subscribed to the Google Groups "blink-dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CADQ2FkRLh76XLACORqyBYo4dyXpz%3DyCZ1qjuxpGwcRYUMghzkw%40mail.gmail.com.
