VTK update problem

I am trying to use a vtk window. I have expected behavior when using this

@param.depends('refresh_views')
def view_vtk(self):
     return pn.pane.VTK('https://raw.githubusercontent.com/Kitware/vtk-js/master/Data/StanfordDragon.vtkjs')

Then I use my own vtk plot:

@param.depends('refresh_views')
def view_vtk(self):
    return pn.pane.VTK(self.get_3dplot().plotter.ren_win)

But this plot isn’t updated, even though view_vtk() is called for sure. When I refresh the page with F5, I do get the updated plot, but also the error message below, which I find quite puzzling (and doesn’t really seems to break anything).

The vtk plot is fine as it can be viewed natively with pyvista using the show() method.

Any clues what I am doing wrong?

ERROR:tornado.application:Exception in callback functools.partial(<bound method IOLoop._discard_future_result of <tornado.platform.asyncio.AsyncIOMainLoop object at 0x0000027CC286A5B0>>, <Task finished name='Task-128' coro=<_needs_document_lock.<locals>._needs_document_lock_wrapper() done, defined at C:\Users\Leon\anaconda3\envs\sigx\lib\site-packages\bokeh\server\session.py:51> exception=RuntimeError("Models must be owned by only a single document, LinearColorMapper(id='2767', ...) is already in a doc")>)
Traceback (most recent call last):
  File "C:\Users\Leon\anaconda3\envs\sigx\lib\site-packages\tornado\ioloop.py", line 743, in _run_callback
    ret = callback()
  File "C:\Users\Leon\anaconda3\envs\sigx\lib\site-packages\tornado\ioloop.py", line 767, in _discard_future_result
    future.result()
  File "C:\Users\Leon\anaconda3\envs\sigx\lib\site-packages\bokeh\server\session.py", line 67, in _needs_document_lock_wrapper
    result = func(self, *args, **kwargs)
  File "C:\Users\Leon\anaconda3\envs\sigx\lib\site-packages\bokeh\server\session.py", line 195, in with_document_locked
    return func(*args, **kwargs)
  File "C:\Users\Leon\anaconda3\envs\sigx\lib\site-packages\bokeh\document\document.py", line 1183, in wrapper
    return doc._with_self_as_curdoc(invoke)
  File "C:\Users\Leon\anaconda3\envs\sigx\lib\site-packages\bokeh\document\document.py", line 1169, in _with_self_as_curdoc
    return f()
  File "C:\Users\Leon\anaconda3\envs\sigx\lib\site-packages\bokeh\document\document.py", line 1182, in invoke
    return f(*args, **kwargs)
  File "C:\Users\Leon\anaconda3\envs\sigx\lib\site-packages\bokeh\document\document.py", line 972, in remove_then_invoke
    return callback(*args, **kwargs)
  File "C:\Users\Leon\anaconda3\envs\sigx\lib\site-packages\panel\pane\vtk\vtk.py", line 88, in _update_model
    super(AbstractVTK, self)._update_model(events, msg, root, model, doc, comm)
  File "C:\Users\Leon\anaconda3\envs\sigx\lib\site-packages\panel\reactive.py", line 137, in _update_model
    model.update(**msg)
  File "C:\Users\Leon\anaconda3\envs\sigx\lib\site-packages\bokeh\core\has_props.py", line 374, in update
    setattr(self, k, v)
  File "C:\Users\Leon\anaconda3\envs\sigx\lib\site-packages\bokeh\core\has_props.py", line 278, in __setattr__
    super().__setattr__(name, value)
  File "C:\Users\Leon\anaconda3\envs\sigx\lib\site-packages\bokeh\core\property\descriptors.py", line 539, in __set__
    self._internal_set(obj, value, setter=setter)
  File "C:\Users\Leon\anaconda3\envs\sigx\lib\site-packages\bokeh\core\property\descriptors.py", line 763, in _internal_set
    self._real_set(obj, old, value, hint=hint, setter=setter)
  File "C:\Users\Leon\anaconda3\envs\sigx\lib\site-packages\bokeh\core\property\descriptors.py", line 832, in _real_set
    self._trigger(obj, old, value, hint=hint, setter=setter)
  File "C:\Users\Leon\anaconda3\envs\sigx\lib\site-packages\bokeh\core\property\descriptors.py", line 909, in _trigger
    obj.trigger(self.name, old, value, hint, setter)
  File "C:\Users\Leon\anaconda3\envs\sigx\lib\site-packages\bokeh\model.py", line 662, in trigger
    self._document._invalidate_all_models()
  File "C:\Users\Leon\anaconda3\envs\sigx\lib\site-packages\bokeh\document\document.py", line 1031, in _invalidate_all_models
    self._recompute_all_models()
  File "C:\Users\Leon\anaconda3\envs\sigx\lib\site-packages\bokeh\document\document.py", line 1098, in _recompute_all_models
    a._attach_document(self)
  File "C:\Users\Leon\anaconda3\envs\sigx\lib\site-packages\bokeh\model.py", line 674, in _attach_document
    raise RuntimeError("Models must be owned by only a single document, %r is already in a doc" % (self))
RuntimeError: Models must be owned by only a single document, LinearColorMapper(id='2767', ...) is already in a doc

Which version of panel are you using?
try to add
pn.pane.VTK(self.get_3dplot().plotter.ren_win, serialize_on_instantiation=True)

Thanks @xavArtley, that completely solved it!

It makes sense after reading the description of serialize_on_instantiation.