halide / Halide

a language for fast, portable data-parallel computation
https://halide-lang.org
Other
5.83k stars 1.07k forks source link

HelloWasm app is busted #8368

Open alexreinking opened 1 month ago

alexreinking commented 1 month ago

The HelloWasm app isn't working right.

The build itself is broken and only happens to work. The core.cpp file uses the headers from a Halide filter library that it doesn't depend on. This can be observed by running cmake --build build --target wasm.

Then, the threaded versions don't work in-browser. Running Chrome with the following two flags enabled:

  1. chrome://flags/#enable-javascript-experimental-shared-memory
  2. chrome://flags/#enable-experimental-webassembly-features

shows an error in the generated emscripten code along the lines of TypeError: wait.value.then is not a function.

Emscripten error ``` Uncaught (in promise) TypeError: wait.value.then is not a function at __emscripten_thread_mailbox_await (index_threads.js:1:77532) at index_threads.wasm:0x3c555 at callRuntimeCallbacks (index_threads.js:1:24660) at initRuntime (index_threads.js:1:7833) at doRun (index_threads.js:1:204130) at run (index_threads.js:1:204373) at runCaller (index_threads.js:1:203667) at removeRunDependency (index_threads.js:1:8897) at receiveInstance (index_threads.js:1:10976) at receiveInstantiationResult (index_threads.js:1:11116) __emscripten_thread_mailbox_await @ index_threads.js:1 $Kd @ index_threads.wasm:0x3c555 callRuntimeCallbacks @ index_threads.js:1 initRuntime @ index_threads.js:1 doRun @ index_threads.js:1 run @ index_threads.js:1 runCaller @ index_threads.js:1 removeRunDependency @ index_threads.js:1 receiveInstance @ index_threads.js:1 receiveInstantiationResult @ index_threads.js:1 ```

This is using the latest EMSDK, cloned from upstream as of this morning.

abadams commented 1 month ago

This threaded version works for me on linux chrome, but freezes on os x chrome: https://halide-lang.org/wasm_demo/index.html?simd&threads

It used to work on both.

alexreinking commented 1 month ago

https://halide-lang.org/wasm_demo/index.html?simd&threads

I'm sure that was compiled with an older version of EMSDK, too.

steven-johnson commented 1 month ago

Hmm, it works perfectly on my Mac using Chrome using today's EMCC and the wasm experimental features enabled in Chrome. What specific cmake configure command did you use? I did

mkdir build
cd build
Halide_DIR=~/halide-19-install/ cmake ..
ninja
steven-johnson commented 1 month ago

This can be observed by running cmake --build build --target wasm.

What's with the --target wasm part? I don't see any target of that name.

steven-johnson commented 1 month ago

FYI, I have Experimental JavaScript shared memory features set to default

steven-johnson commented 1 month ago

(I built with today's EMCC, btw... maybe there was a temporary buggy version?)