Skip to content

perf(rendering): render each view at most once per frame - #1037

Draft
PaulHax wants to merge 2 commits into
Kitware:mainfrom
PaulHax:render-frame-scheduler
Draft

PaulHax wants to merge 2 commits into
Kitware:mainfrom
PaulHax:render-frame-scheduler

Conversation

@PaulHax

@PaulHax PaulHax commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator

Builds on #1034. Only the last commit is new here; the first is #1034's.

After #1034, a single change could still render a view several times before the next frame was shown. The app, vtk.js widgets, and the vtk interactor each asked for renders independently, and each one drew.

This change gives every view one render per frame:

  • The view's interactor is created with enableRender: false, so vtk.js's own render() calls only emit RenderEvent, which the view turns into a render request. vtk-initiated renders join the app's requests instead of drawing immediately. Frames of vtk's interaction animation, during drags and wheel zoom, draw when vtk asks for them.
  • Requests are batched with batchForNextFrame, which renders in the next animation frame.
  • A request made while the view is rendering is dropped, since vtk modifies what it draws during the draw.
  • The view's size comes from a single resize observer. Views without area skip rendering until they gain area. VtkSliceView fits the camera on the view's window resize event, so the render that follows already shows the fit.

Not covered: during interaction, vtk's interactor animation loop still renders every frame even when nothing changed, for example in the tail after mouse wheel input.

@netlify

netlify Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for volview-dev ready!

Name Link
🔨 Latest commit 1399efa
🔍 Latest deploy log https://app.netlify.com/projects/volview-dev/deploys/6afa15efbef546e4fa25fa1a
😎 Deploy Preview https://deploy-preview-1037--volview-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@PaulHax
PaulHax force-pushed the render-frame-scheduler branch from f6825b7 to 3d398de Compare November 15, 2026 18:20
A parent render window render traverses every child view, so each view
resize redrew the whole layout twice and then the resized view twice
more. Sibling views keep their own canvases, so only the resized view
needs a redraw, and its immediate render now covers the queued one.

The orientation marker also redrew the 3D view on every canvas resize.
It now fits its viewport during the resize, before the view renders.
@PaulHax
PaulHax force-pushed the render-frame-scheduler branch from 3d398de to f63a373 Compare November 15, 2026 18:22
Render requests from the app and from vtk.js now share one render per
view per frame. The vtk interactor's own render calls become requests,
and a request made while rendering is dropped. View size comes from one
resize observer, and slice views fit the camera on the view's resize
event.
@PaulHax
PaulHax force-pushed the render-frame-scheduler branch from f63a373 to 1399efa Compare November 15, 2026 20:28

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant