# Resizing canvas using interactor (WASM with threading)

**URL:** https://discourse.vtk.org/t/resizing-canvas-using-interactor-wasm-with-threading/13962
**Category:** Development
**Tags:** vtkwasm
**Created:** [June 1, 2024, 7:15am UTC](https://discourse.vtk.org/t/resizing-canvas-using-interactor-wasm-with-threading/13962 "2024-06-01T07:15:12Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Jens\_Munk\_Hansen](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jens_munk_hansen/32/1215_2.png) [@Jens\_Munk\_Hansen](https://discourse.vtk.org/u/Jens_Munk_Hansen)
#### Post date: [June 1, 2024, 7:15am UTC](https://discourse.vtk.org/t/resizing-canvas-using-interactor-wasm-with-threading/13962/1 "2024-06-01T07:15:12Z")

</div>

I have replicated the setup from [vtkWasmBenchmarks](https://github.com/Kitware/vtkWasmBenchmarks), where I use `vtkRenderWindowInteractor::InteractorManagesTheEventLoop = false`. It works perfectly.

I followed the latest build instructions for VTK+WASM (updated a week ago) with threading enabled. I managed to get things to work using `SharedArrayBuffer`. Threading indeed works, but I am encountering situations where the canvas is not resized correctly (initially) and some `LeftButtonReleaseEvents` are missing. This, I will need to debug.

Short question:  
Would it be an idea to use the `vtkWebAssemblyRenderWindowInteractor.h` instead of `vtkRenderWindowInteractor`. I can see from your examples, that you can query the dimensions of the parent window using a canvas id? Also, have you @jaswantp tried a setup with `vtkWebAssemblyRenderWindowInteractor` and threading?

Thanks in advance

---

<div class="post-metadata">

### Author: ![jaswantp](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jaswantp/32/10046_2.png) [@jaswantp](https://discourse.vtk.org/u/jaswantp)
#### Post date: [June 3, 2024, 2:17pm UTC](https://discourse.vtk.org/t/resizing-canvas-using-interactor-wasm-with-threading/13962/2 "2024-06-03T14:17:33Z")

</div>

Quick answer:  
This was an issue in the way emscripten forwarded resize requests from the web worker to main thread.  
See [wasm64: html5 callbacks throw type error when proxying to pthread · Issue #21851 · emscripten-core/emscripten · GitHub](https://github.com/emscripten-core/emscripten/issues/21851). It was fixed in emsdk 3.1.60.

There is nothing to change in VTK. Please continue using `vtkRenderWindowInteractor`. The object factory mechanism automatically selects `vtkWebAssemblyRenderWindowInteractor` for you.

[https://gitlab.kitware.com/vtk/vtk/-/merge\_requests/11178](https://gitlab.kitware.com/vtk/vtk/-/merge_requests/11178) updates VTK to use emsdk 3.1.60

---

<div class="post-metadata">

### Author: ![Jens\_Munk\_Hansen](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jens_munk_hansen/32/1215_2.png) [@Jens\_Munk\_Hansen](https://discourse.vtk.org/u/Jens_Munk_Hansen)
#### Post date: [June 3, 2024, 2:27pm UTC](https://discourse.vtk.org/t/resizing-canvas-using-interactor-wasm-with-threading/13962/3 "2024-06-03T14:27:06Z")

</div>

Thank you. We are using 3.1.56. Will update to 3.1.60

---

<div class="post-metadata">

### Author: ![Jens\_Munk\_Hansen](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jens_munk_hansen/32/1215_2.png) [@Jens\_Munk\_Hansen](https://discourse.vtk.org/u/Jens_Munk_Hansen)
#### Post date: [June 4, 2024, 3:15pm UTC](https://discourse.vtk.org/t/resizing-canvas-using-interactor-wasm-with-threading/13962/4 "2024-06-04T15:15:49Z")

</div>

Also I noticed that the vtkWebAssemblyInteractor.js was not installed, but it is fixed now, I see
