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

Experimenting with threading #5

Closed
wants to merge 7 commits into from

Conversation

JensMunkHansen
Copy link

I tried building VTK with pthreads enabled. I got your example to build in development mode. One thing that is puzzling me is that the windows is not properly resized. Also, if I start adding widgets it seems like we have a lot of data races in the JS code.

I could try add a plane widget also in this branch to demonstrate this.

Please don't merge this. It was just to my way to show you the problems that I am facing.

It only runs using npx run dev. Vite is crashing during the production build

@jspanchu
Copy link
Member

jspanchu commented Jul 1, 2024

Hey! Sorry for the very late response here. I was working on enabling threads in a separate branch https://github.com/Kitware/vtkWasmBenchmarks/tree/conesviewer-web-worker but I see you've enabled it here.

@jspanchu
Copy link
Member

jspanchu commented Jul 1, 2024

-sPROXY_TO_PTHREAD and -lembind will not work. Proxying to pthread is only to be used when there is a int main(int, char**) function which performs a long running task. Your best bet is to reorganize the application to create separate threads for rendering and data processing and communicate things from JS to that thread. I don't have a complete example on how to achieve it, but the emscripten tests may have some clues - https://github.com/emscripten-core/emscripten/blob/main/test/gl_in_pthread.cpp

@jspanchu
Copy link
Member

Repo has been renamed to vtk-wasm-demos.

And if you're still interested in enabling threads, please take a look at the new async examples in VTK repository. They illustrate both usecases when you use embind and without embind.

  1. AsyncClipper - https://gitlab.kitware.com/vtk/vtk/-/tree/master/Examples/Emscripten/Cxx/AsyncClipper
  2. WrappedAsyncClipper - https://gitlab.kitware.com/vtk/vtk/-/tree/master/Examples/Emscripten/Cxx/WrappedAsyncClipper

@jspanchu jspanchu closed this Aug 23, 2024
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

Successfully merging this pull request may close these issues.

2 participants