Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some workers are created with the wrong urls #17

Open
jespertheend opened this issue Jul 12, 2024 · 5 comments
Open

Some workers are created with the wrong urls #17

jespertheend opened this issue Jul 12, 2024 · 5 comments

Comments

@jespertheend
Copy link

One of my applications creates a worker using something like this:

const workerUrl = new URL("./assets/worker/main.js", import.meta.url);
const worker = new Worker(workerUrl.href, { type: "module" });

Normally this works fine and the url resolves to http://localhost:8080/client/src/assets/worker/main.js. But once I start inspecting, workerUrl.href is turned into blob://http://localhost:8080/./assets/worker/main.js and the creation of the worker fails.

This particular worker doesn't touch WebGPU so I wouldn't mind if this particular worker wasn't intercepted.

@brendan-duncan
Copy link
Owner

Yeah, sorry, in order to inspect workers that do use WebGPU it has to intercept all workers. Normally it does this without issue, but the interception process interferes with paths. The compensate for that it tries to fix up paths. Obviously it's failing in this case. I'll investigate as soon as I get a chance.

@brendan-duncan
Copy link
Owner

I finally have a chance to look into this.

Can you let me know how you have your files laid out, or even a repo? I'm trying to make a repo myself but not having much success.

Also, are you using the Trusted Types API (https://developer.mozilla.org/en-US/docs/Web/API/Trusted_Types_API)?

@jespertheend
Copy link
Author

Thanks for looking into this!

I'm not using the Trusted Types API.
I don't have a public repo unfortunately. The bug seems to be reproducible on https://pelicanparty.games/ferry but it's all heavily minified so I'll try to get a reduced test case going.

@jespertheend
Copy link
Author

Ok well this makes a lot of sense now. I'm using a polyfill to make new Worker('..', {type:'module'}) work. When I remove it, it fixes this particular error.

I made a reduced test case on https://webgpu-inspector-with-module-worker-polyfill.glitch.me in case you want to fix it. But I reckon this is pretty uncommon and in my case I can easily work around the issue by disabling the polyfill. Which I probably should do anyway since it's now supported in all browsers.

I am running into another issue though, but I'll create a new ticket for that. Feel free to close this if you like.

@brendan-duncan
Copy link
Owner

Thanks for the extra info and the repo! I'll definitely be looking into it. I was sure there would be cases where the hacky module interception and path fixing would break, and it's good to find an example.

I'll look at the fetch issue too, which is really the same issue but another good example of it. Might take a couple days, trying to catch up with work after some vacation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants