Skip to content

feat: Remote rendering 4.1d: Add a SERVER rendering mode streamed through trame-rca - #183

Merged
LKasianAnsys merged 8 commits into
mainfrom
feat/4.1d-add-server-rendering-mode
Oct 29, 2026
Merged

LKasianAnsys merged 8 commits into
mainfrom
feat/4.1d-add-server-rendering-mode

Conversation

@LKasianAnsys

@LKasianAnsys LKasianAnsys commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

Issue

Resolves #26

Context

This PR adds server-side rendering mode (RenderingMode.SERVER) streamed through trame-rca.

This adds a second way to render. The scene is rendered off-screen on the server, and the frames are streamed to the browser through trame-rca. The existing VTK-WASM path stays the default. Its mode is renamed from LOCAL to CLIENT so the two names read as a matching pair.

To avoid copying the 18 scene triggers into a second trame app, they move from LocalApp into a new shared base class, SceneTriggerApp. LocalApp and the new ServerApp both inherit from it.

Breaking change: RenderingMode.LOCAL / "local" is now RenderingMode.CLIENT / "client". The old name is not accepted any more. This affects the Python API, the REST InitProps.rendering_mode field and the CLI --rendering-mode option, though this was always the default and should have had no callers.

Changes

Rendering mode enum and defaults

  • In core/visor_enums.py, RenderingMode now has two members: CLIENT (VTK-WASM in the browser) and SERVER (off-screen rendering streamed through trame-rca).
  • The defaults in Visor, VisorVTK, api/server.py and api/models.py are now RenderingMode.CLIENT.
  • The CLI help text now says the default is CLIENT. The outdated mention of HEADLESS is removed.
  • VisorVTK.new sends SERVER to the new VisorVTKServer.

Shared trigger base: app/trame/scene_trigger_app.py (new)

  • These moved out of local_app.py without changes: the SceneMutationApi protocol, the per-part payload models, the parse_payload decorator, and the lifecycle hooks, HTTP headers and www-path setup.
  • The 18 shared triggers also moved: scene details, per-part state, variable range, camera sync, widget toggles, projection, cross-section plane and panel layout.
  • A new abstract rendering_mode property is written to trame state under the key rendering_mode when the app is constructed. The client can read it to tell which mode it is in.
  • LocalApp now subclasses SceneTriggerApp. It keeps only the triggers that exist only in client mode: pick_geometry and the two perf reports.

Server rendering pipeline (new)

  • app/visor_vtk_server.py, VisorVTKServer: creates one ServerLoopBridge and one ServerStatePublisher, then the VisorServerScene and the ServerApp.
  • vtk/scene/server_scene.py, VisorServerScene: Builds a ServerRenderer and a VisorRcaWindow, both using the scene's lock.
    • Streamed frames have no transparency, so the background is set to the client's theme color. These values match --visor-viewer-background in the client CSS.
    • Adds pick_part_at and set_dark_mode, both run under the scene lock.
    • push_runtime_state re-applies the background color after a state restore and requests a frame.
  • app/trame/server_app.py, ServerApp:
    • Serves the shared triggers plus two that exist only in server mode: pick_part_at (render-window pixel → node id) and set_dark_theme.
    • Creates the trame-rca RemoteControlledArea ("view"). On on_server_ready, it builds the view handler (JPEG, 30 fps, quality 60 while interacting and 90 when still) and binds the bridge to it.
  • app/trame/server_state_publisher.py, ServerStatePublisher:
    • Lets any thread write trame state; the actual write is scheduled on the trame event loop through AsyncRunner.
    • Publishes the camera record as server_camera_state, because a client watching a streamed view has no camera of its own to read.
    • The record is copied on the calling thread while the scene lock is held, so later camera changes can't alter what gets published.

Renderer / infrastructure

  • ServerRenderer:
    • Its constructor now requires a CameraPublisher (a new protocol), and every camera write publishes the camera record after requesting a frame.
    • New set_background_rgb() changes the background color without requesting a frame.
  • TrameServerManager exposes its async_runner.
  • The docstrings in VisorSceneBase that described the old "RCA path" are updated to describe how the server path behaves now.

@github-actions github-actions Bot added test Work associated with testing added enhancement New feature or request labels Oct 22, 2026
@LKasianAnsys
LKasianAnsys force-pushed the feat/4.1c-render-frames-on-server branch from bd6d5eb to 2ebd1e9 Compare October 26, 2026 14:15
@LKasianAnsys
LKasianAnsys force-pushed the feat/4.1d-add-server-rendering-mode branch from 26fa6a3 to 63b6e49 Compare October 26, 2026 14:15
@LKasianAnsys LKasianAnsys self-assigned this Oct 26, 2026
@LKasianAnsys LKasianAnsys changed the title feat: [Remote rendering 4.1d] Add a SERVER rendering mode feat: [Remote rendering 4.1d] Add a SERVER rendering mode streamed through trame-rca Oct 26, 2026
@LKasianAnsys
LKasianAnsys marked this pull request as ready for review October 26, 2026 17:19
@LKasianAnsys
LKasianAnsys force-pushed the feat/4.1c-render-frames-on-server branch from 2ebd1e9 to ab9cd52 Compare October 28, 2026 15:22
@LKasianAnsys
LKasianAnsys force-pushed the feat/4.1d-add-server-rendering-mode branch from dcbce3e to cd02891 Compare October 28, 2026 15:50
@LKasianAnsys LKasianAnsys changed the title feat: [Remote rendering 4.1d] Add a SERVER rendering mode streamed through trame-rca feat: Remote rendering 4.1d: Add a SERVER rendering mode streamed through trame-rca Oct 28, 2026
ansBAkula
ansBAkula previously approved these changes Oct 29, 2026

@ansBAkula ansBAkula left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested the LOCAL, sorry the CLIENT mode and no regressions observed for typical flows.

Base automatically changed from feat/4.1c-render-frames-on-server to main October 29, 2026 20:34
@LKasianAnsys
LKasianAnsys dismissed ansBAkula’s stale review October 29, 2026 20:34

The base branch was changed.

@LKasianAnsys
LKasianAnsys force-pushed the feat/4.1d-add-server-rendering-mode branch from b4d8a1a to c16d873 Compare October 29, 2026 20:38
@LKasianAnsys
LKasianAnsys merged commit 1bad74a into main Oct 29, 2026
16 checks passed
@LKasianAnsys
LKasianAnsys deleted the feat/4.1d-add-server-rendering-mode branch October 29, 2026 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

added enhancement New feature or request test Work associated with testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Remote rendering 4.1] Add headless RemoteRenderer and RCA streaming backend

4 participants