Xpra-org / xpra

Persistent remote applications for X11; screen sharing for X11, MacOS and MSWindows.
https://xpra.org/
GNU General Public License v2.0
1.99k stars 169 forks source link

on scaling #4133

Closed Lanchon closed 8 months ago

Lanchon commented 9 months ago

thank you all for this project.

i have only used xpra for a couple emergency situations. my experience with and knowledge of it are virtually nonexistent. i had issues with scaling and read around the issue tracker a bit, and found some confusion around scaling.

i'll write down here what i thought as i read around in the hope that some of it might help the devs. please mind my complete ignorance of the project take it all with copious amounts of salt.

there is some scaling implementation. i think the problem with it might be that it was not clear exactly which issues(s) that implementation was meant to fix. scaling can contribute at least to these next issues, and some of these affected the implementation:

as a result of this possible lack of focus, you may want to change the meaning of the current --desktop-scaling flag down the road.

server scaling

asymmetric scaling

i've read issues mentioning the possibility of stretching a remote desktop to fill a client window of a different aspect ratio. the good way of doing this would be to support 2 different scaling factors for X and Y in the server. the best way IMHO would be to not implement any of this at all. the old days of non-square pixels is long gone. we've all switched to 1:1 pixels and no modern desktop that i know supports asymmetric scaling. it is a feature nobody wants, there is no need to implement it in xpra just because "we can". fill the client window with margins instead.

scaling for efficiency

it could be argued that in some situation you could want to scale on both sides only for efficiency sake. eg, in a 4K shadow displayed on a 4K client you might want to scale down 2:1 on the server, then scale back up 1:2 on the client. for data compression sake, you should get better quality just by asking for more compression for the algorithm rather than doing this trick. but for CPU efficiency, this could be desired.

in any case, this could be handled entirely by the client, and the server only needs to scale when in shadow mode. both in app and desktop mode the client can simply pretend to have smaller display windows and get on with life as usual: open remote app windows with less size and request desktop sessions with less size than actually displayed. this is kind of an obscure feature, and if implemented at all it should probably be implemented as a static setting for windows at creation time, and maybe even for the whole server connection if that is easier. a 4K user could simply say then can't really see their desktop pixels and ask xpra to scale everything up by 2:1.

client scaling

well those are my $0.02 to add. i'm sure most if not all of it has been thought before, but you never know.

thanks for xpra!

totaam commented 9 months ago

fill the client window with margins instead

That's hard because now you need to center the window and manage the offsets. And you may still have some scaling used, to complicate those calculations.

adding translational components to the required transform is easy enough

Feel free to help.

in a 4K shadow displayed on a 4K client you might want to scale down 2:1 on the server, then scale back up 1:2 on the client...

That's what --desktop-scaling does for values greater than 1:1.

you should get better quality just by asking for more compression for the algorithm

No, scanning a 4K bitmap takes huge amounts of memory bandwidth. Downscaling before compressing reduces compression time significantly. At least for software compression. Hardware compression generally uses less aggressive scaling heuristics.

both in app and desktop mode the client can simply pretend to have smaller display windows and get on with life as usual: open remote app windows with less size and request desktop sessions with less size than actually displayed

The position of all windows could be messed up. The server's virtual screen(s) geometry needs to match the one that the client claims to have. (and if the client is going to upscale things, then the virtual screen needs to be downscaled to match)

if implemented at all it should probably be implemented as a static setting for windows at creation time

It is dynamic, because that's not too hard to do: the client already synchronizes its monitor geometry with the server - it has to. We tried (and failed) to make this per-window. The is an open ticket for that: #3454

but if the desktop can be remotely dynamically resized

You mean the virtual screen running on the server right? It does, this is fundamental to how xpra works.