> You can enable all of node in a BrowserWindow with `nodeIntegration: true` and then you don't need to IPC over to the main process.
> I should add, even if you do want to use online resources, you can spawn 2 BrowserWindows, one with node integrated (for doing GPU work with all the node APIs available), one without (for a UI).
I appreciate the suggestions! I can rewrite the application to make use of a second BrowserWindow for GPU work if other fixes do not work out. However this still seems like a workaround, spawning an essentially otherwise empty complete browser window just to do GPU work. Using the same window for UI and compute also is still an option, but would tie all the backend logic to the UI performance, which is why I would also consider this a non optimal workaround. My preferred solution is still to be able to use WebGPU headlessly, even in electron applications.
> I think the only way we could do things without support for external buffers would involve large memory copies. It might be somewhat self-defeating, but probably not too bad. Certainly it would at least paper over the issue.
I'm afraid that's the only way too. I think most users would still prefer that when running dawn in electron, it would fallback to making these large memory copies, as opposed to not working at all ;)
I will file an issue for this with instructions. I can completely understand it not being a priority though, but I appreciate it being looked at.
For others running into this, my (pretty bad) patch for now has been to replace the culprit in GPUBuffer.cpp:
auto array_buffer = Napi::ArrayBuffer::New(env, ptr, s);
with the following:
auto array_buffer = Napi::ArrayBuffer::New(env, s);
std::memcpy(array_buffer.Data(), ptr, s);
This is not a proper solution, as it breaks some previously working code regarding the creation of buffers with initial data, but this is easily worked around in a few lines of JS. Other than that, it seems this small patch results in otherwise perfectly working dawn.node in Electron.