godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.23k stars 21.04k forks source link

Godot generating export templates for web gives an console error in browser. #85160

Closed surendra019 closed 11 months ago

surendra019 commented 11 months ago

Godot version

3.3.1

System information

Windows 11, Godot 3.3.1, Intel iris Xe graphics

Issue description

I first compiled Godot 3.3.1 from source code for windows editor, then I want to generate the export templates for web, I do so for release one using scons p=javascript target=release, this don't give any error while generation and the size of the release template .zip come out to be about 15MB, when I apply that template and exported my project using it, it gives a console error. When I make templates for debug, the templates were generated but the .wasm file in the template has a size of about 180MB, which is too large. And when I use optimize=size flag while generating the export templates for debug, here is the final command which I've used scons p=javascript target=debug optimize=size, this gives a debug template .zip which has a size of about 19MB (normal) but as a fact it is giving the same error as the template which I generated before for release. Meanwhile the official export templates provided by Godot have the normal size but they not give any console error. I want to generate that size of templates for my compiled Godot editor and also want the exported project using them is working just like the official templates. Screenshot 2023-11-21 084912

Steps to reproduce

generate web export templates using - scons p=javascript target=release. or follow the docs - https://docs.godotengine.org/en/3.1/development/compiling/compiling_for_web.html

Minimal reproduction project

godot.javascript.opt.zip

the above file is the export templates for web for release build.

akien-mga commented 11 months ago

Godot 3.3 is no longer supported since multiple years. Please try with Godot 3.5.3.

surendra019 commented 11 months ago

in 3.5.3 the error is Screenshot 2023-11-21 144809

akien-mga commented 11 months ago

Right, I need to fix that error.

You can temporarily work it around with a change like this:

diff --git a/platform/javascript/detect.py b/platform/javascript/detect.py
index a8e34b0c2c..d97044db54 100644
--- a/platform/javascript/detect.py
+++ b/platform/javascript/detect.py
@@ -186,7 +186,7 @@ def configure(env):
         env.Append(CPPDEFINES=["NO_THREADS"])

     # Get version info for checks below.
-    cc_semver = tuple(get_compiler_version(env))
+    cc_semver = (3, 1, 14)

     if env["use_thinlto"] or env["use_lto"]:
         # Workaround https://github.com/emscripten-core/emscripten/issues/19781.

Replace (3, 1, 14) with the numbers matching your Emscripten version (3.1.14 is what is used for official 3.x builds).

surendra019 commented 11 months ago

can I use Emsripten v3.1.49 for this?

akien-mga commented 11 months ago

Any version should work, but I recommend 3.1.14 for the 3.x branch. But you can try 3.1.49, as long as you don't need gdnative, it should be fine.

surendra019 commented 11 months ago

I made export templates for godot v3.5.3 but when i exported my project using them, the console has an error memory is out of bounds, i made release export template.

Screenshot 2023-11-21 161454

surendra019 commented 11 months ago

please help I am working on same thing since 10 days

akien-mga commented 11 months ago

Which Emscripten version did you use?

Please try 3.1.14 as recommended.

surendra019 commented 11 months ago

3.1.14

surendra019 commented 11 months ago

as you recommended.

surendra019 commented 11 months ago

please reply

akien-mga commented 11 months ago

I already replied 4 times in 2 hours, please be patient.

This is not a user support platform, but a tracker for bug reports. If you need immediate help, you can try on other platforms where users might be willing to spend time debugging what doesn't work on your system specifically.

Official templates work, so the problem must be a configuration issue on your end.

Here's how official templates are built: https://github.com/godotengine/godot-build-scripts/blob/3.5/build-javascript/build.sh#L24-L25

Which expands to:

scons verbose=yes warnings=no progress=no production=yes target=release_debug tools=no
scons verbose=yes warnings=no progress=no production=yes target=release tools=no

I see in the original post that you're trying to build with target=debug. This isn't something we test frequently, it might simply be too big with debug symbols for browsers to handle. Why do you need a debug custom build?

surendra019 commented 11 months ago

actually i integrated a custom module in it, which is working fine in editor, but when generate a web export template for it then it give the error null function or function signature mismatch. this error won't come when i remove the custom module from the source code and then make export templates. Any solution?

surendra019 commented 11 months ago

the error is in browser's console. https://github.com/funexpected/godot-flash-module

this is the module i integrated

YuriSizov commented 11 months ago

@surendra019 Please edit your previous comment if you want to add new information. Every time you reply with a new comment it pings a lot of people who are subscribed to this repository.

akien-mga commented 11 months ago

If it works without the custom module, and fails with that custom module, then it's a bug of that module. You should report it to https://github.com/funexpected/godot-flash-module so they can investigate.