Skip to content

cross-pthread creation and destruction of WebGPU objects #19645

@mannkdev

Description

@mannkdev

Please include the following in your bug report:

Version of emscripten/emsdk:
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.28 (f11d619)
clang version 16.0.0 (https://github.com/llvm/llvm-project ea4be70cea8509520db8638bb17bcd7b5d8d60ac)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /home/kangm/code/emsdk/upstream/bin

Failing command line in full:
If this is compile or link-time failure please include the full failing command
along with its entire output.

Full link command and output with -v appended:
Even for runtime issues it helps a lot if you can include the full link command.
Adding -v to the link command will show all of the sub-commands run which
can help us diagnose your issue.

Because the "manager" objects like WebGPU.mgrBuffer are not synchronized across pthreads/web workers, an object that's created on one thread (e.g. via wgpuDeviceCreateBuffer) cannot be destroyed (e.g. via wgpuBufferDestroy) on another, as the destroying thread cannot find the given object id in its manager map.

Is there any workaround or fix planned for this? I came across this explainer (https://gpuweb.github.io/gpuweb/explainer/#multithreading-transfer) but it seems like none of the proposed solutions are very satisfying,

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions