Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

phd
Copy link
Contributor

@phd phd commented Apr 16, 2025

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
Copy link
Member

@CendioOssman CendioOssman left a comment

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?

writer()->writeFramebufferUpdateRequest({0, 0,
server.width(),
server.height()},
!forceNonincremental);
Copy link
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?

Comment on lines +955 to +958
writer()->writeFramebufferUpdateRequest({0, 0,
server.width(),
server.height()},
!forceNonincremental);
Copy link
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
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 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
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
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
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
Copy link
Contributor Author

phd commented Apr 28, 2025

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
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
Copy link
Contributor Author

phd commented Apr 28, 2025

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

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