Skip to content
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

GUACAMOLE-1196: Implement support for VNC display size updates #469

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

necouchman
Copy link
Contributor

This PR takes a crack at implementing the recently-added libvncclient support for SendExtDesktopSize(), which should allow Guacamole as a VNC client to send its size to VNC servers that support such functionality and have the display dynamically resized.

I'm creating as a draft for the moment since I have not actually tested the functionality. Among the things I'm not sure of:

  • The RDP protocol contains a resolution setting which specifies the DPI resolution of the screen. I don't see any reason to try to mirror this into the VNC protocol, as I don't think VNC actually does anything with it (I think the DPI is fixed), but if I'm wrong let me know and I can add that support and try to update the code accordingly.
  • In the Jira issue (https://issues.apache.org/jira/browse/GUACAMOLE-1196), @mike-jumper mentioned a way of possibly sending the resize command/message using WriteToRFBServer() - I'm wondering if it's worth trying to implement the display update functionality with that in cases where libvncclient doesn't contain the SendExtDesktopSize() function?
  • I added the message_lock mutex for sending this message, as in the RDP protocol, but I don't know if there are other places where this lock should be used (authentication, for example), or if it's even required in this scenario?
  • I moved a few bits from the RDP protocol to the common/display.h file - among them are the minimum and maximum display size. It wasn't clear to me from the comments in the code whether those minimum and maximum sizes are arbitrary or if there's some particular reason those values are used? Not sure if there's something specific to RDP that has those bounds?

@necouchman
Copy link
Contributor Author

Okay, did some initial testing, and the desktop size messages are being sent correctly through to the VNC server. Unfortunately I'm hitting an issue with the VNC server (tigervnc) where it is rejecting the size updates due to missing modelines for Xvnc. Obviously having to load all the possible modelines for all of the possible resolutions that Guacamole might request is a bit silly, so I'm thinking that I might need to find another VNC server that doesn't have this requirement.

Good news, though, is that the changes on the Guacamole side seem sound.

@necouchman necouchman marked this pull request as ready for review November 28, 2023 23:43
@DrummyFloyd
Copy link

Hi , any update regarding this wonderfull and waited PR ? =D

Comment on lines 220 to 240
void guac_vnc_display_set_size(guac_vnc_display* display,
rfbClient* rfb_client, int width, int height) {

/* Fit width within bounds, adjusting height to maintain aspect ratio */
guac_common_display_fit(&width, &height);

/* Fit height within bounds, adjusting width to maintain aspect ratio */
guac_common_display_fit(&height, &width);

/* Width must be even */
if (width % 2 == 1)
width -= 1;

/* Store deferred size */
display->requested_width = width;
display->requested_height = height;

/* Send display update notification if possible */
guac_vnc_display_update_size(display, rfb_client);

}
Copy link
Contributor

Choose a reason for hiding this comment

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

The limitations enforced here were originally established specifically due to RDP:

  • The "Display Update" channel for RDP defines an upper limit of 8192 pixels for display dimensions.
  • The "Display Update" channel mandates that the width provided is even.
  • Windows was known to become unresponsive (requiring a reboot to resolve) if multiple display update requests were sent in rapid succession.

Except for enforcing our own upper bound on screen size by choice, which is a good idea regardless of whether it's required by the underlying protocol, I'm not sure these same limitations apply to VNC.

If we instead send the display size request immediately upon receiving the size instruction from the user (adjusting received values to fit our own maximum), do things still work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm happy to give it a go, although my overall ability to test these changes is limited. I'll hunt around, again, for a VNC server that supports dynamic resize and see if I can find one that is free and try it out, but I had limited success last time around.

@necouchman
Copy link
Contributor Author

Hi , any update regarding this wonderfull and waited PR ? =D

Looks like Mike has started reviewing it. Any chance you'd be able to test it out? I've been unable to get access to a VNC server that actually supports it...

@DrummyFloyd
Copy link

Hi , any update regarding this wonderfull and waited PR ? =D

Looks like Mike has started reviewing it. Any chance you'd be able to test it out? I've been unable to get access to a VNC server that actually supports it...

tbh, i only know tigerVnc, i can try the latest one , because it seems taht the options is presnet in latest tigerVNC + vncserver =>-AcceptSetDesktopSize

@necouchman
Copy link
Contributor Author

Hi , any update regarding this wonderfull and waited PR ? =D

Looks like Mike has started reviewing it. Any chance you'd be able to test it out? I've been unable to get access to a VNC server that actually supports it...

tbh, i only know tigerVnc, i can try the latest one , because it seems taht the options is presnet in latest tigerVNC + vncserver =>-AcceptSetDesktopSize

If you're able to give it a try with the changes from this PR, that'd be great. I'm also using TigerVNC, and, according to the Xvnc man page, AcceptSetDesktopSize is enabled by default, so it should be working, but I was getting errors indicating that any resolution I wanted to set needed a modeline in the X configuration, which just isn't tenable.

@necouchman
Copy link
Contributor Author

Okay, I was able to test it and am successfully sending the SendExtDesktopSize() message size, but immediately after the resize it's failing on the HandleRFBServerMessage() call, here:

https://github.com/necouchman/guacamole-server/blob/12c98e331c1dc85b36f2c194fc067ba7fbd29cfe/src/protocols/vnc/vnc.c#L473-L479

So, something about the resize is not working correctly - I'm not sure if there's something that needs to be updated in the rfbClient when the resize is sent, or it's a bug, or...?

@x-7
Copy link

x-7 commented May 21, 2024

Hi , any update regarding this wonderfull and waited PR ? =D

Looks like Mike has started reviewing it. Any chance you'd be able to test it out? I've been unable to get access to a VNC server that actually supports it...

tbh, i only know tigerVnc, i can try the latest one , because it seems taht the options is presnet in latest tigerVNC + vncserver =>-AcceptSetDesktopSize

If you're able to give it a try with the changes from this PR, that'd be great. I'm also using TigerVNC, and, according to the Xvnc man page, AcceptSetDesktopSize is enabled by default, so it should be working, but I was getting errors indicating that any resolution I wanted to set needed a modeline in the X configuration, which just isn't tenable.

@necouchman
Copy link
Contributor Author

@x-7 Thank you for testing! I'm glad to hear that it works for you - maybe the error that I'm currently seeing is actually a bug in the VNC Server, and not something with how I've implemented it. I'll try to find some additional VNC servers to test with - maybe even grab an eval copy of RealVNC or something like that and see if that works.

@x-7
Copy link

x-7 commented May 22, 2024

@x-7 Thank you for testing! I'm glad to hear that it works for you - maybe the error that I'm currently seeing is actually a bug in the VNC Server, and not something with how I've implemented it. I'll try to find some additional VNC servers to test with - maybe even grab an eval copy of RealVNC or something like that and see if that works.

@x-7 Thank you for testing! I'm glad to hear that it works for you - maybe the error that I'm currently seeing is actually a bug in the VNC Server, and not something with how I've implemented it. I'll try to find some additional VNC servers to test with - maybe even grab an eval copy of RealVNC or something like that and see if that works.

yes,I used two clients for testing: next-terminal(https://github.com/dushixiang/next-terminal) and gucalmole-client.

  1. next-terminal "autoresize" is ok, but when the mouse is placed on the edge of the window, the mouse style does not change to the zoom style.

  2. gucalmole-client client "autoresize" is also ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants