Trouble following WASM tutorial (Not working)

Hi,

I am trying to follow along with the tutorial on the following page: Building using emscripten for WebAssembly - VTK documentation

I used the VTK v9.2.6 and dockcross/web-wasm:20230222-162287d, I followed all steps and was able to get the steps of the tutorial completed with everything completing without errors.

I then tried to run the code example steps documented on this page: https://gitlab.kitware.com/vtk/vtk/-/blob/master/Examples/Emscripten/Cxx/Cone/README.md, again everthing completed without errors.

When I start the server and load the page I get the following messages in the console and only a white screen is shown:
“App created”
“initialized”
“ERROR: In vtkSDL2OpenGLRenderWindow.cxx, line 284”
“vtkSDL2OpenGLRenderWindow (0x100450): Unable to create SDL2 opengl context”
“missing function: glXGetProcAddressARB”
“Aborted(-1)”

Has anyone else ran into this issue?

Hi,

Thanks for trying that tutorial! Can you please try a more recent version of VTK? Meanwhile, I’ll try those commands and see if it’s missing a flag or something.

Hi,

Thanks for taking the time to look into the issue.

Just tried with v9.3.0.rc1 downloaded from here: Download | VTK

The steps in the Building using emscripten for WebAssembly - VTK documentation guide complete but when I run the first command from the Cone example with the actual example and VTK_DIR path:
“emcmake cmake
-G Ninja
-S /path/to/vtk/Examples/Emscripten/Cxx/Cone
-B out/build
-DVTK_DIR=/path/to/where/vtk/wasm/was/built”

The results is:
“emcmake: error: ‘cmake -G Ninja -S /work/src/ -B out/build -DVTK_DIR=/install/lib/cmake/vtk-9.3/ -DCMAKE_CROSSCOMPILING_EMULATOR=/emsdk/node/14.18.2_64bit/bin/node;–experimental-wasm-bulk-memory;–experimental-wasm-threads’ failed (returned 1)”

Was that command run inside the docker container? I think it’s missing the toolchain file. Can you try this command?

cmake -DCMAKE_CROSSCOMPILING_EMULATOR=/emsdk/node/14.18.2_64bit/bin/node;–experimental-wasm-bulk-memory;–experimental-wasm-threads -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -G Ninja -S /path/to/vtk/Examples/Emscripten/Cxx/Cone -B out/build -DVTK_DIR=/install/lib/cmake/vtk-9.3

Apologies for the delay in response.

Yes, I am running all command inside the docker container. I tried to add the tool chain file and I am now getting a different error.

“Cone.js:10219 Uncaught (in promise) TypeError: entryFunction is not a function
at callMain (Cone.js:10219:13)
at doRun (Cone.js:10244:21)
at run (Cone.js:10256:3)
at runCaller (Cone.js:10203:18)
at removeRunDependency (Cone.js:373:4)
at receiveInstance (Cone.js:462:3)
at receiveInstantiationResult (Cone.js:466:3)”

This might be just an issue with the Cone project code as the other examples work, with the exception of the ConeMultiBackend WebGPU example which only shows a white screen and does not load the cones.

Ah. I see, thanks for testing the other examples. I’ll try to look at the Cone source code when I get a chance.

This might be just an issue with the Cone project code as the other examples work, with the exception of the ConeMultiBackend WebGPU example which only shows a white screen and does not load the cones.

Which browser are you using? Does it atleast show the message that WebGPU is not supported by the browser? Curious to see your developer console.

Hi, I was using Chrome.

This is the output of the developer console.
“config_webgpu.js:33 Found an adapter
config_webgpu.js:35 Obtained a device
config_base.js:16 Created 10000 cones
config_webgpu.js:42 WASM runtime initialized with arguments ./this.program,10,10,100,1”

Okay, thanks for sharing. I may be able to help better if you can also share version of chrome and what operating system. It could be the emsdk version inside that dockcross/web-wasm is too old.

The chrome version number is: Version 116.0.5845.188, Windows 11. The dockcross/web-wasm version was dockcross/web-wasm:20230222-162287d.

If will try this example again, I have a feeling I missed a flag when building VTK. I will let you know the outcome.

Thanks for the support.

No problem, let us know how it goes. I’ve followed Building using emscripten for WebAssembly - VTK documentation to the dot and all went well for me. In summary:

  1. git clone git@gitlab.kitware.com:vtk/vtk.git && cd vtk
  2. git checkout v9.2.6-2535-gc8cebe56fb
  3. docker pull dockcross/web-wasm:20230222-162287d
  4. docker run --rm -it --entrypoint /bin/bash -v$PWD:/work/src dockcross/web-wasm:20230222-162287d
  5. Configure VTK
    emcmake cmake \
    -S /work/src \
    -B /work/build-vtk-wasm \
    -GNinja \
    -DBUILD_SHARED_LIBS:BOOL=OFF \
    -DCMAKE_BUILD_TYPE:STRING=Release \
    -DVTK_ENABLE_LOGGING:BOOL=OFF \
    -DVTK_ENABLE_WRAPPING:BOOL=OFF \
    -DVTK_MODULE_ENABLE_VTK_hdf5:STRING=NO \
    -DVTK_MODULE_ENABLE_VTK_RenderingContextOpenGL2:STRING=DONT_WANT \
    -DVTK_MODULE_ENABLE_VTK_RenderingLICOpenGL2:STRING=DONT_WANT \
    -DVTK_MODULE_ENABLE_VTK_RenderingCellGrid:STRING=NO \
    -DVTK_MODULE_ENABLE_VTK_sqlite:STRING=NO \
    -DCMAKE_INSTALL_PREFIX=/install
    
  6. cd build-vtk-wasm/ && ninja
  7. ninja install
  8. cd /work/src
  9. emcmake cmake -GNinja -S ./Examples/Emscripten/Cxx/Cone -B ./out -DVTK_DIR=/install/lib/cmake/vtk-9.2/
  10. cd out/ && ninja
  11. Get out of docker (Ctrl + D)
  12. python3 -m http.server -d out

Open localhost:8000