My old CPlusPlus project which uses VTK to display 3D scene worked on web page as wasm file.

But after upgrading emsdk and compiling the multithreaded version of VTK, I always get the following error on the web page.

Uncaught (in promise) RuntimeError: table index is out of bounds
    at vtkInteractorStartCallBack.wasm:0x397bc5
    at vtkInteractorStartCallBack.wasm:0x2d2000
    at vtkInteractorStartCallBack.wasm:0x1a2309
    at vtkInteractorStartCallBack.wasm:0x1a2560
    at vtkInteractorStartCallBack.wasm:0x14fd3
    at callRuntimeCallbacks (vtkInteractorStartCallBack.js:8:28371)
    at initRuntime (vtkInteractorStartCallBack.js:8:10858)
    at doRun (vtkInteractorStartCallBack.js:8:328969)
    at run (vtkInteractorStartCallBack.js:8:329367)
    at runCaller (vtkInteractorStartCallBack.js:8:328654)
:4001/favicon.ico:1     Failed to load resource: the server responded with a status of 404 (File not found)

I test VTK example at vtk/src/Examples/Emscripten/Cxx/Cone from GitHub.

But the similar error showed after I run it on browser.

Cone.wasm:0x34443d Uncaught (in promise) RuntimeError: table index is out of bounds
    at vtkBuffer<int>::Reallocate(int) (Cone.wasm:0x34443d)
    at vtkAOSDataArrayTemplate<int>::ReallocateTuples(int) (Cone.wasm:0x344306)
    at vtkGenericDataArray<vtkAOSDataArrayTemplate<int>, int>::Resize(int) (Cone.wasm:0x287e47)
    at vtkCellArray::VisitState<vtkTypeInt32Array>::VisitState() (Cone.wasm:0x138a6b)
    at vtkCellArray::New() (Cone.wasm:0x138c1c)
    at _GLOBAL__sub_I_vtkPolyData.cxx (Cone.wasm:0x1e593c)
    at __wasm_call_ctors (Cone.wasm:0x16930)
    at callRuntimeCallbacks (Cone.js:727:26)
    at initRuntime (Cone.js:350:3)
    at doRun (Cone.js:11331:5)

I modified the file CMakeLists.txt and tried many times, but the result is same.

Finally, I changed the VTK_DIR from the multithreaded version path to the normal version one because my project has not threads setting. It works!

➜  build_wasm git:(v9.1.0) ✗ emcmake cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DVTK_DIR=/mnt/d/Libs/vtk/build_thread  ../
(crash!)


➜  build_wasm git:(v9.1.0) ✗ emcmake cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DVTK_DIR=/mnt/d/Libs/vtk/build_wasm  ../
(good!)

Test project had been uploaded to GitHub:

https://github.com/theArcticOcean/tutorials/tree/main/learnWebAssembly/vtkInteractorStartCallBack

Categories: VTKWeb

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments

Tex To PDF
: convert the Latex file which suffix is tex to a PDF file

X
0
Would love your thoughts, please comment.x
()
x