-
-
Notifications
You must be signed in to change notification settings - Fork 211
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
[WASM-Export] Unable to use multiple rust GDExtensions at the same time #968
Comments
Thanks a lot for the detailed report and the kind words 🙂
Yes, this is a known behavior, I had the same experience (Discord thread). It should be correct without those. Looking at your stack trace, problem seems to come from here: gdext/godot-ffi/src/binding/single_threaded.rs Lines 72 to 92 in 4bc92e8
I don't know which panic is exactly triggered, is there maybe a way to log/debug the message and/or line number? Since this is also about threading, one check is to make sure your threading settings are in sync.
Another few points you can try that have caused problems in the past:
There is also quite a bit of knowledge in #438. Unfortunately it's still quite scattered, there's some work to be done in improving the web-export page in the book. |
Hi, Thank you so much for the quick reply and the helpful links!
This is how I've been doing it when I submitted the projects, so I guess this isn't it.
This also causes the same error, however, exporting using Release now gives me the error: For both approaches, removing the second
A couple things that I find interesting in the stacktrace is:
I'm browsing the source code of the Kind regards, |
Your use case of combining multiple extensions is quite new and this setup isn't well-tested yet. We recently discussed a similar dependency model (but outside Wasm) in #951. godot-rust generally assumes there's only one instance in its address space -- which may no longer be true in your case. Since it panics near some initialization routines in gdext/godot-ffi/src/binding/single_threaded.rs Lines 72 to 92 in 4bc92e8
, it might just be that the "singleton" responsible for loading the library is instantiated more than once (in one address space), and the assertion Maybe you could clone the repo, point to the dependency locally and try changing this part -- so that instead of panicking on 2nd initialization, it would return and skip this part? Calling this only once is a safety precondition, so you'd likely need some further changes or run into UB, but it could already be a start to test the hypothesis. In your #[gdextension]
unsafe impl ExtensionLibrary for ClientExtension {} And you mentioned that leaving this only once (in the library |
Thank you so much again for the quick reply! You got me tinkering...! I'm unable to finish the research tonight but I've learned quite a bit already. For one thing, I'm almost certain that I don't really understand the impact of this yet, but I'm sure it's not a good thing :P. I suspect it certainly has to do something with the errors I'm getting, now to find the culprit of how to fix it. I'm sure I don't have enough knowledge to really fix it, but I hope I could make a proposal and with you're help, refine it into a nice fix. Thanks again for your work, I really appreciate it. I'll see if I can get a hacky fix, and I'll let you know. I'd be really happy if you'd be able to help me along then too! Edit: Just a quick comment; I'm thinking that some errors occur because it's using the Shared Memory feature of WASM? It might be that the second initialization overwrites some stuff... Food for thought.. Lemme get into it. |
I think a proper fix would be to add an attribute to the #[gdextension(dependency)]
unsafe impl ExtensionLibrary for ClientExtension {} And based on that, certain initialization code would not be generated and/or not run. In case you want to tinker, you could search for |
Hi,
Lately I've been working on a bigger game, and completed the refactor from C# to C++ and then I found this amazing library so I switched one more time to Rust.
Now, what I've had in mind was that I'd create a Shared, Client and Server project in Rust. Shared would have the Nodes that both projects need and Client and Server would be implementing the multiplayer features.
I created the following setup:
Note: The
client
norserver
projects do not depend onshared
inCargo.toml
.This setup is working terrific! I'm able to implement client specific features, and server specific features which will be connected using the shared nodes.
I can run this on my Linux machine, and confirm that it is working. However, I also target
wasm
so I tried getting that to work. Now, this isn't really working out.I compile the workspace with
cargo +nightly build -Zbuild-std --target wasm32-unknown-emscripten
to WebAssembly, and this is going really well. But when I run the project, on Firefox I get anout of memory
emscripten error (which it also does with a single Rust project, but only on Debug builds). When I run it on Chromium however, I get a big list of errors:I've tried using different entry point names using
Which doesn't work. As soon as I remove the other extensions (so I leave
shared.gdextension
) it starts working again.I use these Emscripten compile flags:
I also created two projects to recreate the issue:
single-rust-project.zip
multiple-rust-project.zip
I'm really eager to help this project move forward, and I would say I'm quite well-versed in WebAssembly, however I have no idea where to get started. I tried enabling
-sASSERTIONS
and-sASSERTIONS=2
but this gives me aresolved is not a function error
so no dice...Any tips are very welcome, and if you need more information please let me know!
Thank you for the amazing work on this library, it's awesome!
Kind regards,
The text was updated successfully, but these errors were encountered: