Skip to content

feat: Remote rendering 4.2b: Choose viewer from server mode and show streamed frames - #185

Merged
LKasianAnsys merged 3 commits into
mainfrom
feat/4.2b-show-server-rendered-frames-in-browser
Nov 2, 2026
Merged

LKasianAnsys merged 3 commits into
mainfrom
feat/4.2b-show-server-rendered-frames-in-browser

Conversation

@LKasianAnsys

@LKasianAnsys LKasianAnsys commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

Issue

Resolves #27

Context

This PR adds client-side support for streaming frames from the server in SERVER mode. Until now, the browser always rendered with WASM, even in SERVER mode. It now reads the server's mode, and in server mode, ServerCanvas subscribes to the trame-rca view area, reports its size through a ResizeObserver (the first report starts the stream), and sends set_dark_theme after subscribing. No wasm is loaded in server mode. Both modes build their websocket URL through trameWebSocketUrl.

Manual check: start VISOR in SERVER mode with a dataset as initial input. Open the viewer; a frame is displayed. No WASM network requests should be shown in the network tab with dev tools open. The frame should resize with the browser window.
Client mode should be unchanged.

Summary

Adds support for server-side rendering mode in the Visor client. Previously the client always connected a local wasm scene and rendered itself. Now, on startup the client probes the server's rendering_mode and, when the server says "server", instead streams server-rendered JPEG frames over trame's Remote Controlled Area (RCA) protocol and displays them directly, skipping the wasm scene entirely.

Changes

New: rendering-mode probe (hooks/useRenderingMode.ts)

  • Opens a single trame websocket connection to read the rendering_mode state value ("client" or "server").
  • In "client" mode, disconnects immediately (the existing client-mode scene opens its own connection) and returns the mode.
  • In "server" mode, keeps the trame connection alive and returns it for reuse by the streaming hook.
  • Throws/reports UnknownRenderingModeError for any unexpected value.

New: server-rendering hook (hooks/useServerVtk.ts)

  • Given the probe's trame session, constructs a ServerCanvas to receive streamed frames and sends the page's dark/light theme to the server via set_dark_theme.

New: rca/ServerCanvas.ts

  • Subscribes to the trame-rca stream topic, decodes incoming JPEG frame bytes into a Blob/object URL, and renders them into an <img> element.
  • Uses a ResizeObserver to report the element's pixel size (trame.rca.size) to the server so the server can resize its render window and produce correctly-sized frames.
  • Tracks FPS and exposes a frame-listener API; cleans up subscriptions, observers, and object URLs on dispose.

New: trameWebSocketUrl.ts

  • Shared helper building the ws/wss session URL based on the page's protocol; used by both the probe and the existing client-mode connection (useClientVtk.ts) to avoid duplicated scheme logic.

Modified: App.tsx

  • Runs useRenderingMode on mount; useClientVtk is now only "active" (and only opens its wasm connection) when the probe resolves to "client" mode.
  • When in server mode, renders the ServerCanvas element directly instead of the UiScaffold/wasm frontend.
  • Surfaces probe errors (e.g., unknown rendering mode) in the same error-display slot as the existing schema-mismatch error.

Modified: hooks/useClientVtk.ts

  • Takes a new active boolean parameter; its connection effect now no-ops until active is true, so the wasm scene is never started while the server is driving rendering.
  • Uses the shared trameWebSocketUrl helper instead of inlining the URL.

@github-actions github-actions Bot added added enhancement New feature or request labels Oct 22, 2026
@LKasianAnsys
LKasianAnsys force-pushed the feat/4.2b-show-server-rendered-frames-in-browser branch from 1a2fb9f to 006facb Compare October 26, 2026 14:16
@LKasianAnsys
LKasianAnsys force-pushed the feat/4.2b-show-server-rendered-frames-in-browser branch from 006facb to 7689ab9 Compare October 26, 2026 17:32
@LKasianAnsys LKasianAnsys self-assigned this Oct 26, 2026
@LKasianAnsys
LKasianAnsys marked this pull request as ready for review October 26, 2026 18:11
@LKasianAnsys LKasianAnsys linked an issue Oct 26, 2026 that may be closed by this pull request
@LKasianAnsys
LKasianAnsys force-pushed the feat/4.2b-show-server-rendered-frames-in-browser branch from 7689ab9 to e12d96d Compare October 28, 2026 16:15
@LKasianAnsys LKasianAnsys changed the title feat: [Remote rendering 4.2b] Choose viewer from server mode and show streamed frames feat: Remote rendering 4.2b: Choose viewer from server mode and show streamed frames Oct 28, 2026
@LKasianAnsys
LKasianAnsys added this pull request to stack #197 October 29, 2026 20:54
@LKasianAnsys
LKasianAnsys force-pushed the feat/4.2b-show-server-rendered-frames-in-browser branch from cb2c1e4 to 27d1bf6 Compare October 29, 2026 21:14
Base automatically changed from feat/4.2a-move-client-mode-wiring-out-of-app to main October 29, 2026 23:11
@LKasianAnsys
LKasianAnsys force-pushed the feat/4.2b-show-server-rendered-frames-in-browser branch from 27d1bf6 to b4dc851 Compare October 29, 2026 23:11

@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.

The window resize is not affecting the axis widget...it remains the same size (both client and server modes). I remember this was fixed in Theia (wasm/client rendering). Functionality wise everything works as expected.

@LKasianAnsys

Copy link
Copy Markdown
Collaborator Author

@ansBAkula Yes good catch. The orientation widget resize fix ended up being reverted at the time, as there was an upstream issue that had triggered a regression in add_dataset. The fix didn't get re-implemented in visor after the upstream bug was resolved. But the orientation widget resize is included in the PR for user story 4.6 (#189), for both modes.

@LKasianAnsys
LKasianAnsys merged commit 3fb271b into main Nov 2, 2026
16 checks passed
@LKasianAnsys
LKasianAnsys deleted the feat/4.2b-show-server-rendered-frames-in-browser branch November 2, 2026 13:57
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Remote rendering 4.2] Mode selection and remote entrypoint

3 participants