Skip to content

Reduce viewer idle cpu#753

Merged
iory merged 3 commits into
mainfrom
reduce-viewer-idle-cpu
Jun 2, 2026
Merged

Reduce viewer idle cpu#753
iory merged 3 commits into
mainfrom
reduce-viewer-idle-cpu

Conversation

@iory
Copy link
Copy Markdown
Owner

@iory iory commented Jun 2, 2026

Skip rendering in viewers when nothing changed

PyrenderViewer and TrimeshSceneViewer re-rendered the scene on every
refresh tick (e.g. 30 times per second) even when nothing had changed,
keeping the CPU busy on a fully static view. Skip rendering entirely
when self._redraw is False.

Also force a redraw in TrimeshSceneViewer.save_image so the captured
frame is freshly rendered rather than a potentially stale buffer.

cc: @708yamaguchi @nakane11

iory added 3 commits June 2, 2026 20:34
PyrenderViewer and TrimeshSceneViewer re-rendered the scene on every
refresh tick (e.g. 30 times per second) even when nothing had changed,
keeping the CPU busy on a fully static view. Skip rendering entirely
when self._redraw is False.

Also force a redraw in TrimeshSceneViewer.save_image so the captured
frame is freshly rendered rather than a potentially stale buffer.
The default was lowered to 1Hz in #239 because rendering ran on every
refresh tick, pushing idle CPU usage over 300%. Now that rendering is
skipped when nothing changed, 30Hz no longer causes that, so restore
the original 30Hz default for smooth interaction out of the box.
Reflect the new 1/30 default and note that the viewer only re-renders
when the scene changes, so 30Hz no longer keeps the CPU busy on a
static view.
@nakane11
Copy link
Copy Markdown
Contributor

nakane11 commented Jun 2, 2026

I tested this change by sending a random angle_vector at 30 Hz.

With viewer._redraw = True on each update, CPU usage increases. If I comment it out, CPU usage drops significantly, since rendering is skipped while _redraw remains false.

@nakane11
Copy link
Copy Markdown
Contributor

nakane11 commented Jun 2, 2026

This works well. Looks good to me.

@iory iory merged commit 2f2fb9b into main Jun 2, 2026
64 of 66 checks passed
@iory iory deleted the reduce-viewer-idle-cpu branch June 2, 2026 13:58
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.

2 participants