Closed brendan-duncan closed 4 months ago
The site is doing a fetch request from a path such as '/glb/atlas.png'. Because the real worker script is being loaded from an import via a generated script, it can't resolve the paths.
The issue can be reproduced by adding
const response = await fetch('/test/triangle.html');
const text = await response.text();
console.log(text);
to test/webgpu_worker.js
I made a branch to experiment with solutions, https://github.com/brendan-duncan/webgpu_inspector/tree/web_worker_fetch.
Something that partially worked is I store the host url of the worker script. Then I hijacked "fetch", and if the URL starts with "/", I prepend the host url.
That made the modified test/worker.html test work, and it resolved the first error from that threejs site. It still has the error about the null scene.
The null scene is because it's from a Request. Guess I'll try hijacking that too.
Intercepting Request seems to work and things are loading and inspecting on that threejs site now.
Feels a bit awkward and error prone we're intercepting so many things now, but it's pretty cool that it works.
Merged into main. I'll continue poking at it to see if anything else breaks.
I suspect we'll have a few of these, off the top of my head, we'll likely need to patch:
While the scope of things that could be patch is probably quite large, I can't imagine games will be using them, so aren't an immediate concern.
yeah, might just have to patch these on a case by case basis. I did fetch already. I could wrap websocket and url. There could be others that I'm not thinking of. At least a bunch of APIs aren't available to WebWorkers, like DOM objects or WebRTC, so it could be worse.
https://2024.utsubo.com
Starting WebGPU Inspector causes the page to have the following errors and not render correctly,