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

Changed nothing, deployed new build, wasm lib throws internal errors now #23239

Open
Unreal-Dan opened this issue Dec 19, 2024 · 3 comments
Open

Comments

@Unreal-Dan
Copy link

Unreal-Dan commented Dec 19, 2024

I have an automated build which uses webassembly to build another project and uses the js/wasm it produces.

I changed some JS code unrelated to the wasm module, the original C++ that produces the wasm was unchanged.

I ran another deployment and github built the wasm module and deployed it and now I see these errors:

VortexLib.js:9 wasm streaming compile failed: LinkError: WebAssembly.instantiate(): Import #31 "env" "_emscripten_get_now_is_monotonic": function import requires a callable
instantiateAsync @ VortexLib.js:9
await in instantiateAsync
createWasm @ VortexLib.js:9
(anonymous) @ VortexLib.js:9
(anonymous) @ Main.js:13Understand this errorAI
VortexLib.js:9 falling back to ArrayBuffer instantiation
instantiateAsync @ VortexLib.js:9
await in instantiateAsync
createWasm @ VortexLib.js:9
(anonymous) @ VortexLib.js:9
(anonymous) @ Main.js:13Understand this errorAI
VortexLib.js:9 failed to asynchronously prepare wasm: LinkError: WebAssembly.instantiate(): Import #31 "env" "_emscripten_get_now_is_monotonic": function import requires a callable
instantiateArrayBuffer @ VortexLib.js:9
await in instantiateArrayBuffer
instantiateAsync @ VortexLib.js:9
await in instantiateAsync
createWasm @ VortexLib.js:9
(anonymous) @ VortexLib.js:9
(anonymous) @ Main.js:13Understand this errorAI
VortexLib.js:9 Aborted(LinkError: WebAssembly.instantiate(): Import #31 "env" "_emscripten_get_now_is_monotonic": function import requires a callable)
abort @ VortexLib.js:9
instantiateArrayBuffer @ VortexLib.js:9
await in instantiateArrayBuffer
instantiateAsync @ VortexLib.js:9
await in instantiateAsync
createWasm @ VortexLib.js:9
(anonymous) @ VortexLib.js:9
(anonymous) @ Main.js:13Understand this errorAI
VortexLib.js:9 Uncaught (in promise) RuntimeError: Aborted(LinkError: WebAssembly.instantiate(): Import #31 "env" "_emscripten_get_now_is_monotonic": function import requires a callable). Build with -sASSERTIONS for more info.
    at abort (VortexLib.js:9:4918)
    at instantiateArrayBuffer (VortexLib.js:9:5969)
    at async createWasm (VortexLib.js:9:7304)

image

The YML that builds webassembly in github actions and deploys it can be found here:

https://github.com/Unreal-Dan/lightshow.lol/blob/main/.github/workflows/deploy.yml#L34

    # Install Emscripten
    - name: Install Emscripten
      run: |
        git clone https://github.com/emscripten-core/emsdk.git
        cd emsdk
        ./emsdk install latest
        ./emsdk activate latest
        source ./emsdk_env.sh

    # Build using Emscripten
    - name: Build WebAssembly with Emscripten
      run: |
        source emsdk/emsdk_env.sh
        cd VortexEngine/VortexEngine/VortexLib
        make clean
        make -j wasm

It runs make wasm which invokes this makefile and causes it to use em++ and WASM compile flags:

https://github.com/StoneOrbits/VortexEngine/blob/desktop/VortexEngine/VortexLib/Makefile#L46

A typical wasm compile looks like this (See step 6 :

https://github.com/Unreal-Dan/lightshow.lol/actions/runs/12422510581/job/34684315399

The key thing here is I didn't change anything in the C++ code I just re-deployed the EXACT same version number of 'VortexLib' webassembly build (1.4.34). I track version numbers by counting commits, so I KNOW that 1.4.34 is the exact same commit I was using for the past two weeks.

I haven't changed how the build works at all, I just redeployed the website that uses the WASM module with some new JS changes.

Let me know if there's any more details or information I can provide, in the meantime I have reverted to an older build of the exact same version and it is working fine.

@kripken
Copy link
Member

kripken commented Dec 19, 2024

"_emscripten_get_now_is_monotonic": function import requires a callable

That error suggests something is out of sync, like using JS with the wrong wasm (say if the new wasm wasn't copied over, or the old wasm is cached somehow).

It may also be due to linking with object files from older compiler versions. Rebuilding everything from source would fix it in that case.

It may also be that this is an unknown compiler bug that you've run into. If so, you can bisect on emscripten changes to find when it began:

https://emscripten.org/docs/contributing/developers_guide.html#bisecting

Another option is to reduce this to a small standalone testcase you can submit for us to look at.

@Unreal-Dan
Copy link
Author

Unreal-Dan commented Dec 20, 2024

Thanks for the quick response, I will double check all of those things and get back to you, the odd part is that it only started happening now.

I've done the same thing many many times (re-deploy with a few new JS-only changes but same C++) and it never has caused a problem in the past.

As long as it's not a known issue then I will double check all of my processes and try to re-create a minimally reproducible example.

Edit: Also, I did deployments exactly like this only a day or two ago. Was emscripten updated on ubuntu 20.04 in the past few days?

@Unreal-Dan
Copy link
Author

Unreal-Dan commented Dec 21, 2024

When reviewing my builds I noticed that the emsdk install latest gave 3.1.73 2 weeks ago, and 3.1.74 2 days ago when I encountered the issue.

I can confirm switching from latest (3.1.74) to 3.1.73 and using this hash solved my problem:

    ./emsdk install b363a836e75a245c548b7a6a021822d8c9e4c6df
    ./emsdk activate b363a836e75a245c548b7a6a021822d8c9e4c6df

There's definitely something between 3.1.73 and latest causing issues for me... but I'm not sure what or exactly where.

I will revert to this hash for now and look into it later

Edit: I also tried re-deploying my other website that uses the same wasm build but for different purposes, when I did that my other website slowed to a crawl and was completely unusable. Also switching that one back to 3.1.73 fixed things.

Unfortunately I don't have the time to track down what the problem is, but I guarantee it's not my builds I've been using the same system for years and it's been working amazing -- this is the first time something like this has ever happened and switching versions clearly fixes it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants