Skip to content

feat: Remote rendering 3.1c - register per-part triggers, serialize VTK access with lock, trigger payload validation - #52

Merged
LKasianAnsys merged 21 commits into
mainfrom
feat/3.1c-triggers-lock-and-payload-validation
Sep 2, 2026
Merged

LKasianAnsys merged 21 commits into
mainfrom
feat/3.1c-triggers-lock-and-payload-validation

Conversation

@LKasianAnsys

@LKasianAnsys LKasianAnsys commented Aug 28, 2026 •

Copy link
Copy Markdown
Collaborator

Issue

Addresses #18

Context

This is the 3rd of 5 PRs for user story 3.1 (#18) of the phased implementation plan (here) for adding remote rendering in VISOR.

Per-part visual state (visibility, opacity, diffuse color, color variable), is currently held client-side on VisorPartState and reaches the server only via getAppStateAsync when the save_state API is called. This story inverts that, making VisorDatasetRegistry the source of truth for per-part state by the end of 3.1.

This PR is the third step: exposing the server-side apply methods as Trame triggers, plus a lock on the VTK operations from the scene coordinator layer. These triggers still have no callers in this PR. The client-initiated triggers are added in PR 4, and this is extended to save/load state in PR 5.

Notes

  • A re-entrant lock was added on VisorSceneBase, taken by all ten public entry points there that touch VTK. This is the entrypoint into the VTK graph from the outside, so one lock there is comprehensive. It is scoped to this story: it serializes access only, and is not a general threading fix.
  • No wasm flush was added on the trigger path. Each coordinator method writes the registry record and applies it to VTK, and pushes nothing to the client. (Adding pushes back to the client is deferred to Phase 6 of the remote rendering epic, where the round trip mechanism will be designed and implemented.)
  • Trigger boundary: The call into the scene is typed by a ScenePartStateApi Protocol, declared in the app module so nothing imports a scene type. This is a type only, no runtime behaviour.
  • Trigger validation: Payloads are parsed into Pydantic models. A malformed payload is rejected before anything reaches the registry or VTK.

Copilot Summary

This pull request introduces a new set of per-part rendering triggers for VISOR (3.1c), ensures robust payload validation for these triggers, and adds a thread-safe locking mechanism to serialize all VTK access in the scene. These changes increase the reliability and maintainability of the rendering workflow, especially in multi-threaded environments. The most important changes are grouped below:

Per-part trigger registration and API:

  • Added a structural protocol ScenePartStateApi and corresponding payload models for each per-part trigger in local_app.py, enabling type-checked, modular, and validated per-part state updates from the frontend [1] [2].
  • Registered new per-part triggers in LocalApp (set_part_visibility, set_part_opacity, set_part_diffuse_color, set_part_selected, set_part_color_variable, clear_part_color_variable) and delegated their handling to the injected scene API, with robust payload validation using Pydantic models [1] [2].
  • Injected the scene as the per-part state API into LocalApp during initialization, ensuring the triggers are routed correctly [1] [2] [3].

Thread safety and VTK access serialization:

  • Introduced a re-entrant lock (_vtk_lock) in the scene base class to serialize all server-side VTK mutations and rendering operations, preventing race conditions between the trame event loop and main thread [1] [2].
  • Wrapped all VTK-mutating methods (apply_state, clear, populate_scene, finalize_scene, update_widgets, add_dataset, remove_dataset, update_variables_for_dataset, render, reset_camera) with _vtk_lock to ensure thread-safe access [1] [2] [3] [4] [5] [6] [7] [8].

@github-actions github-actions Bot added test Work associated with testing added enhancement New feature or request labels Aug 28, 2026
@LKasianAnsys
LKasianAnsys force-pushed the feat/3.1c-triggers-lock-and-payload-validation branch from d81f1c7 to a6b0351 Compare August 28, 2026 20:08
@LKasianAnsys
LKasianAnsys changed the base branch from main to feat/3.1b-per-part-apply-logic August 28, 2026 20:09
@LKasianAnsys
LKasianAnsys force-pushed the feat/3.1c-triggers-lock-and-payload-validation branch from a6b0351 to d857fc9 Compare August 31, 2026 14:33
@LKasianAnsys
LKasianAnsys force-pushed the feat/3.1b-per-part-apply-logic branch from 7b61414 to 0c50362 Compare August 31, 2026 15:29
@LKasianAnsys
LKasianAnsys force-pushed the feat/3.1c-triggers-lock-and-payload-validation branch from 59847e2 to 85b6630 Compare August 31, 2026 15:29
@LKasianAnsys LKasianAnsys self-assigned this Aug 31, 2026
@LKasianAnsys
LKasianAnsys marked this pull request as ready for review August 31, 2026 17:23
margalva
margalva previously approved these changes Sep 2, 2026
Base automatically changed from feat/3.1b-per-part-apply-logic to main September 2, 2026 18:44
@LKasianAnsys
LKasianAnsys dismissed margalva’s stale review September 2, 2026 18:44

The base branch was changed.

@LKasianAnsys
LKasianAnsys merged commit a27249d into main Sep 2, 2026
15 checks passed
@LKasianAnsys
LKasianAnsys deleted the feat/3.1c-triggers-lock-and-payload-validation branch September 2, 2026 20:00
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.

3 participants