Skip to content
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

HTML5: this.rtenv.callMain is not a function when using latest-upstream backend #31297

Closed
LinuxUserGD opened this issue Aug 11, 2019 · 10 comments · Fixed by #31330
Closed

HTML5: this.rtenv.callMain is not a function when using latest-upstream backend #31297

LinuxUserGD opened this issue Aug 11, 2019 · 10 comments · Fixed by #31330

Comments

@LinuxUserGD
Copy link
Contributor

Godot version:
master (3418f76)

OS/device including version:
Arch Linux

Issue description:
This error shows when loading the .pck with Chromium
console log:

test.html:246 this.rtenv.callMain is not a function
displayFailureNotice @ test.html:246

Steps to reproduce:

scons p=x11 bits=64 target=release_debug tools=yes use_llvm=yes use_lld=yes use_thinlto=yes -j 8
./emsdk install latest       OR:      ./emsdk install latest-upstream
./emsdk activate latest               ./emsdk activate latest-upstream
source ./emsdk_env.sh
scons p=javascript target=release_debug tools=no -j 8
python3 -m http.server
http://localhost:8000/test.html

Tested projects: Solus Sphere (https://github.com/HugeGameArtGD/Solus-Sphere) and material demo (both GLES2)

@Mellondill
Copy link

Mellondill commented Aug 12, 2019

Same with me, but I've tried it on macOS.
As I've understood new versions of Emscripten doesn't export callMain function in Module["callMain"] and this is the main problem.
Maybe someone knows how to resolve this problem?
@kripken if you would be so kind, maybe you can tell us what we can do, to enable exporting of callMain function with Emscripten?
Currently we are using 1.38.41 this version of emsdk

@akien-mga akien-mga changed the title HTML5: this.rtenv.callMain is not a function HTML5: this.rtenv.callMain is not a function when using latest-upstream backend Aug 12, 2019
@akien-mga akien-mga added this to the 3.2 milestone Aug 12, 2019
@Mellondill
Copy link

I've found the problem. Due to Emscriptens changlog :

callMain is no longer exported by default on Module, to allow better JS minification. You must add it to EXTRA_EXPORTED_RUNTIME_METHODS if you want to call it on Module. (In assertions builds, an error with an explanation is shown.)

@kripken
Copy link
Contributor

kripken commented Aug 12, 2019

Correct, yes, as the error says we no longer export it by default. You can add the flag to export it.

Sorry for this annoyance, but we sometimes need to make a breaking change like this in order to make progress. We do try to always document it in the changelog, and to make builds with assertions show a clear error, to minimize the annoyance.

@Mellondill
Copy link

@akien-mga , think this issue could be closed

@LinuxUserGD
Copy link
Contributor Author

LinuxUserGD commented Aug 12, 2019

@Mellondill I think there should be a PR in Godot to make the flag the default option.

@Mellondill
Copy link

@LinuxUserGD ah, sorry forgot about PR

Mellondill pushed a commit to Mellondill/godot that referenced this issue Aug 12, 2019
… using latest-upstream backend

Added needed changed for normal compiling with emscripten 1.38.41 and later
@Mellondill
Copy link

@LinuxUserGD created PR with needed changes

@Calinou
Copy link
Member

Calinou commented Aug 12, 2019

@kripken Do you know which changes would be required for Godot to work without callMain? This way, we could benefit from better JavaScript minification as stated by the changelog 🙂

@kripken
Copy link
Contributor

kripken commented Aug 12, 2019

@Calinou in general you shouldn't need callMain - main will be called automatically by the emscripten runtime, when everything is ready. But if godot has special logic for when to start, then using callMain is reasonable (and the downside isn't big, it's just a few JS strings of "callMain" in the final JS file).

@Mellondill
Copy link

Mellondill commented Aug 12, 2019

@Calinou As I understand, initial resource package must be synced in internal filesystem before main function could be called in Godot, so that's why we need such changes

akien-mga pushed a commit that referenced this issue Aug 21, 2019
…st-upstream backend

Added needed changed for normal compiling with emscripten 1.38.41 and later

(cherry picked from commit 3c17682)
myhalibobo pushed a commit to myhalibobo/godot that referenced this issue Sep 3, 2019
… using latest-upstream backend

Added needed changed for normal compiling with emscripten 1.38.41 and later
akien-mga pushed a commit to akien-mga/godot that referenced this issue Sep 24, 2019
… using latest-upstream backend

Added needed changed for normal compiling with emscripten 1.38.41 and later

(cherry picked from commit 3c17682)
pchasco pushed a commit to pchasco/godot that referenced this issue Oct 23, 2019
… using latest-upstream backend

Added needed changed for normal compiling with emscripten 1.38.41 and later
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants