-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Enabling WASM workers breaks WebGPU writeTexture on Firefox #23149
Comments
Sounds like a Firefox-specific bug, which is worth filing there? Though if we can find a workaround here, that may also be worth looking into. |
Well it's here because the fundamental question I have is: why does Emscripten's compiled output change for My expectation is that adding |
When you enable wasm workers (or pthreads) the wasm memory becomes backed by a SharedArrayBuffer. I see on place in emscripten/src/library_webgpu.js Lines 1575 to 1580 in 1092ec3
Its likely the same thing might been to be done in emscripten/src/library_webgpu.js Line 1669 in 1092ec3
It also seems like we should be using |
We can do that, but it would be really ideal to avoid because it's very costly (makes an extra copy of an often-large chunk of memory). The case you pointed to in We certainly could add a workaround for Firefox, but given the high cost, I really think it should be fixed in Firefox instead. Otherwise any projects that get compiled with the workaround will keep using it until they recompile after it's removed. I guess we could do:
if we really want to. I looked for a Firefox bug report but I'm surprised not to find one.
That sounds right.
I thought we had compile tests... I guess we don't, though I don't think that wouldn't catch this anyway. That said I'm pretty sure we have customers using |
Hang on, though. My main problem, these Firefox issues aside, is that the behaviour of WebGPU code changes when I enable The current switch is on emscripten/src/library_webgpu.js Lines 1575 to 1580 in 1092ec3
But in my example, |
These changes in behaviour are because of the underlying memory being a |
Oh I see, so enabling WASM_WORKERS necessarily affects the entire heap and hence everything that uses it? In that case what you're saying makes a lot of sense. Thanks for taking the time to explain. Looks like Firefox needs to fix the bug on their end for this to be resolved, then. |
Yes, that is correct, WASM_WORKERS effect the type of the memory itself which effects all users of the memory. We likely need to change |
Tested with version 3.1.73.
I am playing with WASM audio worklets, and in the process of enabling various compile and link flags, noticed an unexpected change in behaviour of WebGPU.
The initial code works under Firefox Nightly and Chromium, live demo here: https://armchair-software.github.io/webgpu-demo2/ (source).
Adding the following compile commands:
-mbulk-memory
-matomics
And the following link commands:
-sWASM_WORKERS
-sENVIRONMENT=web,worker
(previously-sENVIRONMENT=web
)...causes WebGPU code that was previously working to break on Firefox Nightly only. The code continues to work under Chromium. Firefox produces the following error, triggered by
queue.writeTexture
:Live demo of the broken variant: https://armchair-software.github.io/emscripten-sound-demo/ (source - this one's built in release mode so has no debugging symbols in the console, unlike the dump above).
I presume that some WebGPU behaviour changes when it detects that workers are available, but I've looked at
library_webgpu.js
and don't see any obvious branching that could cause this. Note thatpthreads
are not enabled for this project.Whatever behaviour switch this is, it would be good to be able to control it explicitly, rather than having it turn on automatically when workers are enabled.
The text was updated successfully, but these errors were encountered: