Kitware / vtk-js

Visualization Toolkit for the Web
https://kitware.github.io/vtk-js/
BSD 3-Clause "New" or "Revised" License
1.23k stars 371 forks source link

Tab main thread freezes when using multiple renderers with widget manager #2435

Open bourdaisj opened 2 years ago

bourdaisj commented 2 years ago

High-level description

This is about a tab crash when using WidgetManager with multiple renderers. (one instance of widgetmanager per renderer). It was working fine before this commit: https://github.com/kitware/vtk-js/commit/5e32d4a0738dde13ef1a69a5893e9cac47f6a749 I'm not familiar with the widget infrastructure so maybe I'm doing something stupid in which case please accept my apologies.

Steps to reproduce

A repo to reproduce the problem: https://github.com/Julesdevops/custom-vtkjs-app-template/tree/sphere-widget Basically using a sphere widget with an InteractionOrientationWidget alongside with an OrientationMarkerWidget (legacy). I'm basically just mixing two examples:

Detailed behavior

The tab just freezes/crash, UI is blocked forever. I've tried investigating but this is just too complex for me. handleEvent seems to be re triggering the event over and over again: https://github.com/Kitware/vtk-js/blob/77ee125ae14a4fdfbc0e4f04727aec2ec4253fbf/Sources/Widgets/Core/WidgetManager/index.js#L317

Expected behavior

We should be able to observe the behavior that existed before 5e32d4a0738dde13ef1a69a5893e9cac47f6a749 which is: no crash, working good.

Environment

floryst commented 2 years ago

This is an issue with how we handle touch with widgets and how the WidgetManager has to interrupt the event chain in order to issue a picking operation. I have a better approach sketched out, but it means that the event callData should ideally be annotated with the pointing device, so we can handle touch in a special case and leave the mouse case as-is.