InsightSoftwareConsortium / itkwidgets

An elegant Python interface for visualization on the web platform to interactively generate insights into multidimensional images, point sets, and geometry.
https://itkwidgets.readthedocs.io/
Apache License 2.0
582 stars 83 forks source link

"Viewer 1" updates/requests fail once "Viewer 2" is created #708

Open bnmajor opened 9 months ago

bnmajor commented 9 months ago

When there are multiple viewers within one notebook only calls to the most recently created viewer succeed. For example:

viewer_1 = view(image)
viewer.set_rotate(True)  # succeeds
viewer_2 = view(image)
viewer.set_rotate(False)  # fails
viewer_2.set_rotate(True)  # succeeds

Originally this seemed to be related to the major updates now available in v1.0a41 - For example, the cells

annotations = viewer.get_annotations_enabled
annotations

return

TypeError: Cannot read properties of undefined (reading 'getAnnotationsEnabled')

Testing with previous releases shows that this is actually a long-standing issue. It seems that the reference to the window object returned from api.createWindow no longer has the ImJoyPluginAPI available after another window is created.

@oeway Have you seen behavior like this before?

thewtex commented 9 months ago

I like the improvement @oeway made with hypha -- it is more functional, passing a reference to all objects used in the API, like the viewer in this case. Maybe need a version of that with the imjoy rpc?

oeway commented 9 months ago

Hi, guys, yeah, I will need to investigate it a bit to see how to fix! Or maybe a more sustainable plan is to migrate to hypha RPC in ImJoy.

Unfortunately, I am a bit overloaded at the moment, will have to look into this in 2024!