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

shadow desktop scaling broken for scaling < 100% #4324

Closed
Lanchon opened this issue Aug 12, 2024 · 6 comments
Closed

shadow desktop scaling broken for scaling < 100% #4324

Lanchon opened this issue Aug 12, 2024 · 6 comments
Labels
bug Something isn't working geometry X11

Comments

@Lanchon
Copy link

Lanchon commented Aug 12, 2024

Describe the bug
shadow desktop scaling is broken when using --desktop-scaling < 100%. this issue is worked-around if --opengl=off is specified (but then bug #4323 hits, so workaround is also unusable).

what happens when scaling < 100% is used is:

  • in the server the desktop image is scaled down before encoding and transmitting. this seems to work correctly.
  • in the client a scaled-down window of the correct size pops up.
  • however the images from the server, once decoded, are SCALED UP before being drawn in the client window. this causes only the upper left part of the desktop to be visible. the resulting effective scale seems to be 1/f, where f is the requested scaling factor. for example, if f=0.5 then this happens:
    • a 50% sized (25% area) client window pops up (correct size).
    • the window is filled with the transmitted images blown up by a factor of 2 by length (of 4 by area). with respect to the original desktop images, which were halved before transmission, this effectively cancels the scaling (while still halving the resolution and transmitting only 1/4 of the original pixels).
    • given that the client window size is correctly halved in length and that the effective content size is the original desktop size, only 1/2 of the screen by length is seen in the horizontal an vertical directions (only 1/4 of the area is visible, the top left corner).
  • while this happens, mouse events from the client to the server are scaled correctly (which means local mouse and local image as shown in the client are mismatched).
  • if OpenGL is disabled in the client, the scaling problem disappears.

To Reproduce
Steps to reproduce the behavior:

  1. server command: none
  2. client command: xpra shadow ssh:XXX:0 --desktop-scaling=70%
  3. specific action to trigger the bug: none

System Information (please complete the following information):

  • Server OS: Linux Mint 22 Wilma base: Ubuntu 24.04 noble
  • Client OS: Linux Mint 22 Wilma base: Ubuntu 24.04 noble
  • Xpra Server Version: xpra v6.1.1-r0
  • Xpra Client Version: xpra v6.1.1-r0

Additional context
on both sides:
Desktop: Cinnamon v: 6.2.9 tk: GTK v: 3.24.41 wm: Muffin vt: 7 dm: LightDM v: 1.30.0
standard X11 session

client:
Graphics: Intel Alder Lake-P GT2 [Iris Xe Graphics] vendor: Lenovo driver: i915 v: kernel arch: Gen-12.2

@Lanchon Lanchon added the bug Something isn't working label Aug 12, 2024
@totaam
Copy link
Collaborator

totaam commented Aug 13, 2024

Can you try running version LTS 5.x instead?
I have seen some corruption with opengl and scaling, bisected down to 8b73c2b - this is one of the v6 key features, the v5.x branch should not be affected.

@totaam totaam changed the title shadow desktop scaling broken for sales < 100% shadow desktop scaling broken for scaling < 100% Aug 13, 2024
@totaam
Copy link
Collaborator

totaam commented Aug 13, 2024

The fix is in 32d9008 + 617aa2e + 342dfa0

Works for me, this will be included in v6.1.2

@totaam totaam closed this as completed Aug 13, 2024
@Lanchon
Copy link
Author

Lanchon commented Aug 14, 2024

Can you try running version LTS 5.x instead?

i downgraded only the client. opengl works but it downscales using nearest neighbor (no bilinear), so not really useful.

The fix is in 32d9008 + 617aa2e + 342dfa0

thanks! i will test once the fix is released. i'll come back to this issue in case of trouble.

@totaam
Copy link
Collaborator

totaam commented Aug 14, 2024

i downgraded only the client. opengl works but it downscales using nearest neighbor (no bilinear), so not really useful.

In your case, the downscaling is done server-side, it should be possible to teach the module to use a different sampling algorithm when downscaling.
Normally, this is driven by the speed option alone:

cdef inline FilterMode get_filtermode(int speed):
if speed>66:
return kFilterNone
elif speed>33:
return kFilterBilinear
return kFilterBox

Another (less optimal) option would be to tell the server to not downscale before compression and let the opengl client apply the linear sampling:

xpra/xpra/opengl/backing.py

Lines 566 to 572 in 474343f

def get_init_magfilter(self) -> IntConstant:
rw, rh = self.render_size
w, h = self.size
if rw / w != rw // w or rh / h != rh // h:
# non integer scaling, use linear magnification filter:
return GL_LINEAR
return GL_NEAREST


i will test once the fix is released.

I am afraid that I have found some more issues, so it could take a while.

@Lanchon
Copy link
Author

Lanchon commented Aug 14, 2024

for now im using v5.0.9-r0 client in non-GL mode against current 6.x server. it works fine like this (bilinear), so for me there is no need to debug the downscaling filtering in GL mode (unless you want to).

thanks again!

@totaam
Copy link
Collaborator

totaam commented Aug 15, 2024

FYI: I have created a ticket for improving the scaling filters based on the window's content-type: #4326

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working geometry X11
Projects
None yet
Development

No branches or pull requests

2 participants