Skip to content

two views with vtkCameraOrientationWidget produces error in second view #70

Description

@jspanchu

Description

Set up two independent vtklocal.LocalView instances, each backed by its own
render window/renderer and its own vtkCameraOrientationWidget. Each widget is
registered with its view via LocalView.register_vtk_object so the widget is
serialized into the wasm scene separately from the render window.

Where does the issue originate?

This project (trame-vtklocal), or upstream in VTK.

Version Information

trame-vtklocal - v0.17.1
VTK - 9.6.20260517.dev0

Steps to Reproduce

  1. Run this code snippet.
"""Minimal reproducer for the two-view camera-orientation-widget issue.

Sets up two independent ``vtklocal.LocalView`` instances, each backed by its own
render window/renderer and its own ``vtkCameraOrientationWidget``. Each widget is
registered with its view via ``LocalView.register_vtk_object`` so the widget is
serialized into the wasm scene separately from the render window.

Run:
    python issue_orientation_widget.py

Then open the printed URL. The second view's widget update is expected to fail
with client-side errors -- this script exists to reproduce that in isolation.
"""

import os

import vtkmodules.vtkInteractionStyle  # noqa: F401
import vtkmodules.vtkRenderingOpenGL2  # noqa: F401
from trame.app import get_server
from trame.ui.vuetify3 import SinglePageLayout
from trame.widgets import vtklocal, vuetify3
from vtkmodules.vtkFiltersSources import vtkConeSource
from vtkmodules.vtkInteractionWidgets import vtkCameraOrientationWidget
from vtkmodules.vtkRenderingCore import (
    vtkActor,
    vtkPolyDataMapper,
    vtkRenderer,
    vtkRenderWindow,
    vtkRenderWindowInteractor,
)

os.environ.setdefault("VTK_DEFAULT_OPENGL_WINDOW", "vtkEGLRenderWindow")

def setup_vtk_pipeline():
    """Build a render window with a single cone actor and an orientation widget."""
    window = vtkRenderWindow(interactor=vtkRenderWindowInteractor())
    window.interactor.interactor_style.SetCurrentStyleToTrackballCamera()
    renderer = vtkRenderer(background=(0.2, 0.2, 0.2))
    window.AddRenderer(renderer)

    cone = vtkConeSource()
    mapper = vtkPolyDataMapper()
    mapper.SetInputConnection(cone.GetOutputPort())
    actor = vtkActor()
    actor.SetMapper(mapper)
    renderer.AddActor(actor)
    renderer.ResetCamera()

    # Camera orientation widget (axes gizmo) anchored to the renderer.
    orientation_widget = vtkCameraOrientationWidget()
    orientation_widget.parent_renderer = renderer
    orientation_widget.SetInteractor(window.interactor)
    orientation_widget.On()

    return window, renderer, orientation_widget


def main():
    server = get_server(client_type="vue3")

    win_a, _ren_a, widget_a = setup_vtk_pipeline()
    win_b, _ren_b, widget_b = setup_vtk_pipeline()

    with SinglePageLayout(server) as layout:
        layout.title.set_text("Two-view orientation widget reproducer")
        with layout.content, vuetify3.VContainer(
            fluid=True, classes="fill-height pa-0", style="gap: 0;"
        ), vuetify3.VRow(classes="fill-height ma-0"):
            with vuetify3.VCol(cols=6, classes="pa-0"):
                view_a = vtklocal.LocalView(
                    win_a, style="width: 100%; height: 100%;"
                )
                # Register the widget separately from the render window.
                view_a.register_vtk_object(widget_a)
            with vuetify3.VCol(cols=6, classes="pa-0"):
                view_b = vtklocal.LocalView(
                    win_b, style="width: 100%; height: 100%;"
                )
                view_b.register_vtk_object(widget_b)

    server.start()


if __name__ == "__main__":
    main()
  1. Second view is blank
Image

Relevant Log Output

JS Error => 2026-06-18 14:12:52.673 (   0.246s) [          8D8374]  vtkAbstractWidget.cxx:106    ERR| vtkCameraOrientationWidget (0xce0b70): The interactor must be set prior to enabling the widget
 JS Error => 2026-06-18 14:12:52.675 (   0.247s) [          8D8374]  vtkAbstractWidget.cxx:106    ERR| vtkCameraOrientationWidget (0xce0b70): The interactor must be set prior to enabling the widget
 JS Error => 2026-06-18 14:12:52.687 (   0.260s) [          8D8374]   vtkObjectManager.cxx:895    ERR| vtkObjectManager (0x925cb0): Cannot update state for object at id=102 because there is no such object!
 JS Error => 2026-06-18 14:12:52.688 (   0.260s) [          8D8374]   vtkObjectManager.cxx:895    ERR| vtkObjectManager (0x925cb0): Cannot update state for object at id=129 because there is no such object!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions