holoviz / panel

Panel: The powerful data exploration & web app framework for Python
https://panel.holoviz.org
BSD 3-Clause "New" or "Revised" License
4.73k stars 516 forks source link

Blank vtk panel output in jupyter notebook #1805

Closed rfortiz closed 3 years ago

rfortiz commented 3 years ago

I recently encountered a lot of seemingly random problems with vtk panels: output not displayed, PyVista meshes only partially synced, holoviews dynamic map breaking when displayed along a vtk panel, etc.

Not sure if it's all connected and since it happens randomly it's hard to find a minimal example, but it starts with the vtkjs example from the doc:

import panel as pn
pn.extension('vtk')

vtk_pane = pn.pane.VTK('https://raw.githubusercontent.com/Kitware/vtk-js/master/Data/StanfordDragon.vtkjs',
                     sizing_mode='stretch_width', height=400, enable_keybindings=True, orientation_widget=True)
vtk_pane

In jupyter notebook, it randomly: 1) works 2) outputs a blank line 3) outputs a blank space the size of the panel 4) outputs an empty vtkjs panel with the orientation widget but no mesh.

I previously had a similar issue that was "fixed" by pasting the code in a new notebook but now this behavior is not consistent.

Tested with: panel 0.9.7 and 0.10.2 installed in fresh conda environments local and remote (ssh forwarding) jupyter notebook server chrome or firefox Ubuntu 20.04

jupyter core : 4.7.0 jupyter-notebook : 6.1.4 qtconsole : 4.7.7 ipython : 7.19.0 ipykernel : 5.3.4 jupyter client : 6.1.7 jupyter lab : not installed nbconvert : 6.0.7 ipywidgets : 7.5.1 nbformat : 5.0.8 traitlets : 5.0.5

The only error I see is in jupyter trace but that's not new:

[IPKernelApp] ERROR | No such comm target registered: hv-extension-comm [IPKernelApp] WARNING | No such comm: hv-extension-comm [IPKernelApp] WARNING | No such comm: hv-extension-comm

rfortiz commented 3 years ago

Just noticed this javascript error in the web console in case 3. (outputs a blank space the size of the panel):

Uncaught (in promise) TypeError: Cannot read property 'newInstance' of undefined
    at r.init_vtk_renwin (VM47 panel.min.js:99)
    at render (VM47 panel.min.js:100)
    at render (VM47 panel.min.js:99)
    at r.build (VM48 bokeh-2.2.3.min.js:449)
    at renderTo (VM48 bokeh-2.2.3.min.js:449)
    at r (VM48 bokeh-2.2.3.min.js:572)
    at async Object.t.add_document_standalone (VM48 bokeh-2.2.3.min.js:572)
VM48 bokeh-2.2.3.min.js:449 Uncaught TypeError: Cannot read property 'compute' of undefined
    at r.compute_layout (VM48 bokeh-2.2.3.min.js:449)
    at resize_layout (VM48 bokeh-2.2.3.min.js:449)
    at is_root._on_resize (VM48 bokeh-2.2.3.min.js:449)
marckassay commented 3 years ago

Using similar code (I appended .servable() to vtk_pane) as @rfortiz original posted, I'm seeing this in Chrome's DevTools console:

16:25:00.104 vtk.js:2 Uncaught TypeError: Cannot read property 'getFirstAncestorOfType' of null
    at IL.e.buildPass (vtk.js:2)
    at Object.e.apply (vtk.js:2)
    at Object.e.traverse (vtk.js:2)
    at Object.e.traverse (vtk.js:2)
    at Object.e.traverse (vtk.js:2)
    at Object.e.traverse (vtk.js:2)
    at Object.e.traverse (vtk.js:2)
    at Object.I_.e.traverseAllPasses (vtk.js:2)
    at u (vtk.js:2)
    at Object.e.render (vtk.js:2)
IL.e.buildPass @ vtk.js:2
e.apply @ vtk.js:2
e.traverse @ vtk.js:2
e.traverse @ vtk.js:2
e.traverse @ vtk.js:2
e.traverse @ vtk.js:2
e.traverse @ vtk.js:2
I_.e.traverseAllPasses @ vtk.js:2
u @ vtk.js:2
e.render @ vtk.js:2
e.render @ vtk.js:2
_set_camera_state @ panel.min.js:95
(anonymous) @ panel.min.js:95
(anonymous) @ bokeh.min.js?v=4e38fcb7a8f2989d2b1f9d55dee62dec:240
emit @ bokeh.min.js?v=4e38fcb7a8f2989d2b1f9d55dee62dec:181
emit @ bokeh.min.js?v=4e38fcb7a8f2989d2b1f9d55dee62dec:181
(anonymous) @ panel.min.js:94
c @ vtk.js:2

Just a caveat, I executed panel serve from VS Code from inside of a Docker container it launched.

I'm using the following tool versions:

panel:      0.9.7
bokeh:      2.2.1
marckassay commented 3 years ago

Updating to the following, I'm able to run @rfortiz code as-is:

panel:      0.10.2
bokeh:      2.2.3

And I'm able to run it as pn.Row(vtk_pane).show() with no severe issues (other than 404 on favicon and a few warnings listed in DevTools console). However running pn.Row(vtk_pane).servable() yields a different error than what I mentioned in my previous post. I'm receiving a couple of messages of the same subject:

bokeh.min.js?v=708688072c5bc35dc9ad32ff7573b038:164
Error rendering Bokeh items: Error: Model 'panel.models.vtk.VTKJSPlot' does not exist. This 
could be due to a widget or a custom model not being registered before first usage.
philippjfr commented 3 years ago

Suspect this was because of a Bokeh/Panel version mismatch or an old version persisting in the browser cache. Please open a new issue if the issue persists.