Skip to content

Do not request screen updates while the window is not visible - #1940

Open
phd wants to merge 1 commit into
TigerVNC:masterfrom
phd:phd-update-only-when-visible
Open

Do not request screen updates while the window is not visible#1940
phd wants to merge 1 commit into
TigerVNC:masterfrom
phd:phd-update-only-when-visible

Conversation

@phd

@phd phd commented Apr 16, 2025

Copy link
Copy Markdown
Contributor

Do not request screen updates while the window is not visible, e.g. minimized.
This saves a lot of bandwidth and CPU.

New option: UpdateOnlyWhenVisible

@phd
phd force-pushed the phd-update-only-when-visible branch from 9ab40bd to 1c4fc47 Compare April 16, 2025 14:51

@CendioOssman CendioOssman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Seems reasonable. Is this an issue you've observed in practice?

Comment thread common/rfb/CConnection.cxx Outdated
writer()->writeFramebufferUpdateRequest({0, 0,
server.width(),
server.height()},
!forceNonincremental);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What if there already is a pending update request?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I based this code on what CConnection::requestNewUpdate() does.
Should it be done differently here? I'm not very familiar with how these updates are handled in vncviewer.

Comment on lines +955 to +958
writer()->writeFramebufferUpdateRequest({0, 0,
server.width(),
server.height()},
!forceNonincremental);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this needed if we're using continuous updates?

Comment on lines +955 to +958
writer()->writeFramebufferUpdateRequest({0, 0,
server.width(),
server.height()},
!forceNonincremental);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If you're going to look at forceNonincremental, then you need to reset it as well.

Comment thread common/rfb/CConnection.cxx Outdated
Comment thread vncviewer/DesktopWindow.cxx Outdated
Comment thread vncviewer/parameters.cxx Outdated
Comment on lines +245 to +250
core::BoolParameter
updateOnlyWhenVisible("UpdateOnlyWhenVisible",
"Do not request screen updates while the window is "
"not visible, e.g. minimized.",
false);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we really need to add another setting for this? Why can't it be constantly be enabled?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Do all VNC servers tolerate not sending updates for extended periods of time? If yes and this can be always enabled, then I fully agree that this option should be removed.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would hope, since they don't know how fast a client might be able to respond. All servers I know of track the coordinates of things that are changed, rather than the changed pixels themselves. So there shouldn't be any issue of things overbuffering.

@phd

phd commented Apr 28, 2025

Copy link
Copy Markdown
Contributor Author

Seems reasonable. Is this an issue you've observed in practice?

I'm running several instances of the TigerVNC viewer, and each of them uses 10%-15% CPU when there are a lot of updates on the screen.
This way I can minimize them (or, with compositing disabled, simply move them to other virtual desktops) and have better performance on my desktop.
Also the Xtigervnc sever uses similar amounts of CPU to send these updates, so it saves resources also on the server side.

@phd
phd force-pushed the phd-update-only-when-visible branch from 1c4fc47 to 9d1329c Compare April 28, 2025 11:04
@CendioOssman

Copy link
Copy Markdown
Member

This way I can minimize them (or, with compositing disabled, simply move them to other virtual desktops) and have better performance on my desktop.

I'm a bit surprised that you're getting FL_SHOW/FL_HIDE by just switching virtual desktop. Which desktop environment is this?

Any idea if we can get some hint for the compositing desktops as well? E.g. GNOME, which is the default desktop on most Linux systems, doesn't really do minimize.

@phd

phd commented Apr 28, 2025

Copy link
Copy Markdown
Contributor Author

I'm a bit surprised that you're getting FL_SHOW/FL_HIDE by just switching virtual desktop. Which desktop environment is this?

KDE 5 on X11.
Just tested this again to be sure, and yes, I get these events while switching virtual desktops.
But I have to disable compositing for this to work (Shift+Alt+F12), otherwise windows are always considered visible and drawn (which is expected, so that KWin can for example show virtual desktops' grid with live preview).

Any idea if we can get some hint for the compositing desktops as well? E.g. GNOME, which is the default desktop on most Linux systems, doesn't really do minimize.

Blocking compositing was historically a big issue outside KDE. Only KDE allowed to block it automatically for fullscreen applications and provided the shortcut for manually disabling it. I don't really know what the current state of GNOME and possibly Wayland is, and if they even want this or care.

@CendioOssman

Copy link
Copy Markdown
Member

Compositing is fundamental to modern desktops, so I don't think there's any option of blocking that.

I was rather hoping that the desktop would be kind enough to send us some other signal to indicate "you're currently not visible, so don't waste time rendering stuff".

@phd
phd force-pushed the phd-update-only-when-visible branch from 9d1329c to bc5f0ef Compare September 22, 2025 12:42
@phd
phd force-pushed the phd-update-only-when-visible branch from bc5f0ef to 617f37d Compare February 28, 2026 23:12
@phd
phd force-pushed the phd-update-only-when-visible branch from 617f37d to 47a6f86 Compare July 16, 2026 08:50
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