WebGPU API not accessible in service_worker

381 views
Skip to first unread message

Alex Nahas

unread,
Jun 15, 2023, 10:00:40 PM6/15/23
to Chromium Extensions
I am trying to generate embeddings in a background script however I cannot access webGPU. I was also not able to find any permissions regarding enabling webGPU. WebGL is still accessible in the service worker so I see no reason why webGPU wouldn't be

Patrick Kettner

unread,
Jun 15, 2023, 10:02:59 PM6/15/23
to Alex Nahas, Chromium Extensions
There isn’t a permission for it. You would need to use the navigator object inside of an offscreenDocument, i believe. 

On Thu, 15 Jun 2023 at 10:00 PM Alex Nahas <alexm...@gmail.com> wrote:
I am trying to generate embeddings in a background script however I cannot access webGPU. I was also not able to find any permissions regarding enabling webGPU. WebGL is still accessible in the service worker so I see no reason why webGPU wouldn't be

--
You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/7a3b1984-2762-475d-8346-143b706dea23n%40chromium.org.

Alex Nahas

unread,
Jun 15, 2023, 10:11:41 PM6/15/23
to Chromium Extensions, Patrick Kettner, Chromium Extensions, Alex Nahas
Ah, well, that's annoying. I appreciate the quick answer though. 

Hopefully they add direct support for it. Any idea if that's in the books? 

Patrick Kettner

unread,
Jun 15, 2023, 10:14:48 PM6/15/23
to Alex Nahas, Chromium Extensions
To be clear, I am a part of “they” - I work at Google on chrome extensions. 

there not being a permission isn’t bad. It just means you can use it without a permission. I believe it is available in an extension service workers via an offscreenDocument. 

Jackie Han

unread,
Jun 15, 2023, 10:49:57 PM6/15/23
to Alex Nahas, Chromium Extensions
Yes, WebGPU is only available in Window and DedicatedWorker (web worker) for now, so it is not available in service worker.

I think supporting WebGPU in service worker should not be a problem. To make it available in SW, I suggest you do the following things:

1. Add a new issue in the WebGPU community for WebGPU in Service Worker. There was an issue for WebGPU in DedicatedWorker.
If standard web support it, then it will be available in browser extensions automatically.

2. You can also add a new issue in WECG. Because extension service worker can do more things than standard service worker.


On Fri, Jun 16, 2023 at 10:00 AM Alex Nahas <alexm...@gmail.com> wrote:
I am trying to generate embeddings in a background script however I cannot access webGPU. I was also not able to find any permissions regarding enabling webGPU. WebGL is still accessible in the service worker so I see no reason why webGPU wouldn't be

--

Alex Nahas

unread,
Jun 26, 2023, 6:59:50 PM6/26/23
to Chromium Extensions, Jackie Han, Chromium Extensions, Alex Nahas, patrick...@google.com
Thank you both! Service Workers as well as the remaining unsupported workers are on track to be exposed to the WebGPU API as a web standard. 

Reference:
https://github.com/gpuweb/gpuweb/issues/4197

Jackie Han

unread,
Apr 12, 2024, 5:18:05 AMApr 12
to Alex Nahas, Chromium Extensions, patrick...@google.com
This is a great example of improving extension functionality by improving the functionality of web standards.
  1. In the past, WebGPU was not available in Service Worker (but available in Web Worker).
  2. Alex Nahas asked this question here (chrome extensions community).
  3. Then he requested this feature in the WebGPU Community Group.
  4. Now, Chrome 124 supports WebGPU in Service Worker and Shared Worker.

I am surprised that it happened within 9 months (from added issue to implementation). Usually, issues I reported can take years to be resolved. You are so lucky.

Reply all
Reply to author
Forward
0 new messages