I am trying to run a 4.3 project in the browser and it is throwing an error loading my GDExtension. I can see other projects are doing this (including one on github) but haven’t been able to figure out what I am missing.
The error is:
USER ERROR: Can't open dynamic library: bin/web/libsutler.web.template_debug.wasm32.wasm. Error: Could not load dynamic lib: libsutler.web.template_debug.wasm32.wasm ChatHunt.js:474:18
Error: libsutler.web.template_debug.wasm32.wasm: file not found, and synchronous loading of external files is not available. ChatHunt.js:474:18
at: open_dynamic_library (platform/web/os_web.cpp:253) ChatHunt.js:474:18
USER ERROR: Can't open GDExtension dynamic library: bin/web/libsutler.web.template_debug.wasm32.wasm ChatHunt.js:474:18
at: open_library (core/extension/gdextension.cpp:802) ChatHunt.js:474:18
USER ERROR: Failed loading resource: res://bin/libsutler.gdextension. Make sure resources have been imported by opening the project in the editor at least once. ChatHunt.js:474:18
at: _load (core/io/resource_loader.cpp:284) ChatHunt.js:474:18
USER ERROR: Error loading extension: res://bin/libsutler.gdextension ChatHunt.js:474:18
at: load_extensions (core/extension/gdextension_manager.cpp:234)
Things that seem relevant:
The GDExtension works correctly for linux export
The project is being exported with variant/extension_support On
The correct path is in the .gdextension file for web. When I add a typo to it, I get an error.
I’ve tried exporting with both the default templates and building templates myself with scons platform=web dlink_enabled=yes target=template_debug threads=no
I’ve been over the documentation for exporting projects and compiling for the web multiple times.
I’m brand new to Godot and struggling to figure this out. Any help or even advice on where to look would be really appreciated!
If you were to just copy paste the plugin wasm, and gdextension, from addons/ into the exported game directory, and it works, we could narrow down the focus. ( Or at least confirm the wasm, and the bin/libsutler.gdextension, is in the export folder )
I guess the second half of the error and synchronous loading of external files is not available seems suspicious, but also bad to have an error with two problems at once. ( Is one problem actually a lie?)
I’ll see if I can find a plugin to replicate issue.
Do you use the dlink_nothread default template? You may need to manually select it from the export install. I had to go into AppData/Roaming/Godot/… On windows to select it. (You should try this first)
Also you may need a wasm version of your pluggin. Does that exist? I used Rapier Physics 3D plugin, from the asset library for testing, and it had a wasm library version that was exported with no fuss, as long as I used the default dlink export template.
Here is a link to compile the gdextension into wasm.
At least from the docs you may need to go into the export template and enable gdextension export?
Thanks so much for the responses. It’s very nice being new to the community and getting some help when I was stuck. Unfortunately I haven’t been able make it work. As far as I can figure out the wasm for the library isn’t being bundled correctly.
For now I’ve made it work by switching to an engine module. It’s not ideal (iteration is slower) but it works.