-
Notifications
You must be signed in to change notification settings - Fork 54
updated instructions on exporting for web #56
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,6 +74,7 @@ rustflags = [ | |
"-C", "link-args=-sSIDE_MODULE=2", | ||
"-C", "link-args=-pthread", # was -sUSE_PTHREADS=1 in earlier emscripten versions | ||
"-C", "target-feature=+atomics,+bulk-memory,+mutable-globals", | ||
"-Cllvm-args=-enable-emscripten-cxx-exceptions=0", | ||
"-Zlink-native-libraries=no" | ||
] | ||
``` | ||
|
@@ -112,6 +113,7 @@ cargo +nightly build -Zbuild-std --target wasm32-unknown-emscripten | |
|
||
Add a web export in the Godot Editor. In the top menu bar, go to `Project > Export...` and configure it there. | ||
Make sure to turn on the `Extensions Support` checkbox. | ||
In Godot 4.3 or above, make sure to turn on the `Thread Support` checkbox. | ||
|
||
 | ||
|
||
|
@@ -143,6 +145,12 @@ and open it in a supported browser such as Google Chrome or Microsoft Edge. | |
|
||
[godot-export-templates]: https://docs.godotengine.org/en/stable/tutorials/export/exporting_projects.html#export-menu | ||
|
||
## Troubleshooting | ||
|
||
1. Make sure both `Extensions Support` and `Thread Support` (in Godot 4.3+) are turned on. | ||
2. Make sure the webserver you're running supports Cross-Origin Isolation (I used `sfz --coi`). | ||
3. Make sure your rust library and godot project are named differently, as sometimes `.wasm` files are overwritten. | ||
4. Make sure you're using the `emcc` version in the guide. | ||
Comment on lines
+148
to
+153
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For For In addition, the main reason why support for non-threaded builds was added was precisely to work in environments without Cross-Origin Isolation IIRC, so that may be worth mentioning too. Otherwise, good advice. |
||
|
||
## Debugging | ||
|
||
|
@@ -155,9 +163,8 @@ for Chrome. It adds support for breakpoints and a memory viewer into the F12 men | |
|
||
--- | ||
|
||
[^1]: Note: Due to a bug with `emscripten`, the maximum version of `emcc`[^2] that can one compile `Godot` with is `3.1.39`. gdext itself should be able to support the latest version of `emcc`, however, it may be a safer bet to stick to version `3.1.39`. | ||
[^1]: Note: Due to a bug with `emscripten`, the maximum version of `emcc`[^2] that can one compile `Godot` with is `3.1.39`. gdext itself should be able to support the latest version of `emcc`, however, it may be a safer bet to stick to version `3.1.39`. Anecdotally, `emcc-3.1.47` has also worked with `Godot 4.3`. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The info regarding the |
||
|
||
[^2]: `emcc` is the name of Emscripten's compiler. | ||
|
||
[^3]: The primary reason for this is it is necessary to compile with `-sSHARED_MEMORY` enabled. The shipped `std` does not, so building `std` is a requirement. Related info on about WASM support can be found [here](https://github.com/rust-lang/rust/issues/77839). | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do support builds without threads, but besides the Thread Support toggle in the editor, there are two steps:
-pthread
flag (the line with"-C", "link-args=-pthread"
) from.cargo/config.toml
(it is necessary for thread support = on, and must be absent for thread support = off)experimental-wasm-nothreads
gdext feature flag.Conversely, for Wasm binaries with thread support, you must have
-pthread
and compile without the nothreads feature.This means that Wasm binaries with and without thread support must be compiled separately. Then, you can add paths to both, allowing you to pick between the two by simply using the editor toggle, by modifying your
.gdextension
file like so (per godotengine/godot-cpp#1451 ):(Those paths may be changed to be more Rust-friendly, e.g. use
target/debug/whatever
. But note that, by default, Rust will produce the binaries at the exact same path regardless of the nothreads feature. We don't know yet how to solve that, so renaming will have to be manual.)Then, once you compile both and place them in those paths within your project, toggling
Thread Support
on and off in the editor should work.We should then mention both build modes in the manual, noting that builds without threads have better browser compatibility and don't require Cross-Origin Isolation support, while threaded builds have more limited compatibility and do require Cross-Origin Isolation support but may be more suitable if you depend on threading for your tasks.