FreeRDP / FreeRDP

FreeRDP is a free remote desktop protocol library and clients
http://www.freerdp.com/
Apache License 2.0
10.78k stars 14.74k forks source link

XfreeRDP selected monitors on a multi monitor setup not working as expected #7497

Open FirstLobster opened 2 years ago

FirstLobster commented 2 years ago

I have a 6 monitor setup

+------------+    +------------+     +------------+                                                    
|                 |    |                 |     |                 |                                        
|         0      |    |         2      |     |         4      |                            
|                 |    |                 |     |                 |                                             
+------------+    +------------+     +------------+ 
+------------+    +------------+     +------------+                                                    
|                 |    |                 |     |                 |                                        
|         1      |    |         3      |     |         5      |                            
|                 |    |                 |     |                 |                                             
+------------+    +------------+     +------------+ 

I am trying to run RDP on a selected number of monitors but i cant get a grip on what order RDP wants the monitors. If i run xfreerdp /multimon /monitors:x where x is only one monitor i always run fullscreen on the selected monitor.

But if i run xfreerdp /multimon /monitors:0,2 It may work and monitor 0 and 2 will display the remote session. But if i run /monitors:1,3 it could show the remote session on 1 and 3 but monitor 0 and 2 will be black. If i select monitor 1, 3 and 5 it can show the remote session on monitor 3,5 but all the other monitors is black.

I have tried to move the DP cables around the back of the graphics card with limited success, sometimes it will make it better and some times it will make selections that used to work not work anymore.

Running one Nividia quadro card with 4 outputs and using the 2 motherboard ports as well.

This is my xrandr output Monitors: 6 0: +*DP-0 1920/518x1200/324+0+0 DP-0 1: +DP-2 1920/518x1200/324+1920+0 DP-2 2: +DP-4 1920/518x1200/324+3840+1200 DP-4 3: +DP-6 1920/518x1200/324+3840+0 DP-6 4: +DP-1-3 1920/518x1200/324+0+1200 DP-1-3 5: +DP-1-2 1920/518x1200/324+1920+1200 DP-1-2

this is my xfreerdp /monitor-list

Is there any logic to this?

Running FreeRDP version 2.3.0 (2.3.0) PopOS 21.10 Nvidia driver: 470.86

akallabeth commented 2 years ago

hard to tell, it is highly dependent on your remote os. Could you answer the follwing:

  1. First, with just /multimon does the session use all monitors successfully?
  2. If you are able to compile a test version:
    • Log the layout sent in gcc_write_client_data_blocks and disp_send_display_control_monitor_layout_pdu
    • Check for gaps between monitor layouts, windows requires the monitors to be next to each other without any pixel left empty in between
FirstLobster commented 2 years ago

hard to tell, it is highly dependent on your remote os. Could you answer the follwing:

  1. First, with just /multimon does the session use all monitors successfully?
  2. If you are able to compile a test version:

    • Log the layout sent in gcc_write_client_data_blocks and disp_send_display_control_monitor_layout_pdu
    • Check for gaps between monitor layouts, windows requires the monitors to be next to each other without any pixel left empty in between

Yes, if i only use multimon all the monitors are being used. Right now it works with 2 monitors, like 0, 2 or 1, 3 but the other variants results in black screens and maybe 1 monitor that shows the rdp session.

No gaps, you notice right away with xrandr if its not aligned.

I forgot to mention that i have had it to work as expected in the past but with a reboot later it stops working with the only thing that has changed is monitor numbering when you check with xrandr. I just cant figure out whats the "correct" order the monitors have to be in.

Are you suggesting that its a "guest" issue. I connect against 3 windows machines one with windows 10, windows server 2016 and server 2018. They all respond the same.

I dont have any experience with compiling from source but i could give it a try.

akallabeth commented 2 years ago

@FirstLobster ok, that is indeed valuable information. The problem is not that there are gaps in your local config (it does not have) but that the /monitors switch filters out some of your monitors. This requres to adjust the original layout to a gap free layout with the reduced set that somehow resembles the original layout, which, as you might imagine, is quite error prone.

I don´t know anyone tested this with more than 3 monitors yet, so depending on order and what is left out the remote layout might be broken.

FirstLobster commented 2 years ago

Yeah, that's I how I imagine it works and it some how relies on the order of the monitors. Which annoyingly could change if you turn one monitor off.

Regarding the building and logging, is there something you could point me to? Should I follow this guide https://github.com/FreeRDP/FreeRDP/wiki/Compilation#linux-specifics

And how do I log the variables you asked for? Is it something like this? WLOG_LEVEL=DEBUG xfreerdp /u:xx /v:xx ...

I will do some more testing. I will start by arrange the monitors to just one row and see how it works with just one axsis.

Thank you for your time.

akallabeth commented 2 years ago

@FirstLobster I´ve pushed enhanced logging to https://github.com/akallabeth/FreeRDP/tree/monitor_log Just clone that repo and build it. Since PopOS is ubuntu based do:

  1. Ensure you have source packages enabled in your repository sources
  2. sudo apt build-dep freerdp2-dev
  3. git clone https://github.com/akallabeth/FreeRDP.git -b monitor_log
  4. cd FreeRDP
  5. ln -s packaging/deb/freerdp-nightly/ debian
  6. dpkg-buildpackage
  7. dpkg -i ../*.deb

run it with: /opt/freerdp-nightly/bin/xfreerdp /log-level:debug <yourargs here> 2>&1 |tee somefile.txt

Now you should have all messages written to somefile.txt and can look for lines containing xxxxxx MonitorCount or disp_send_display_control_monitor_layout_pdu and check the layout sent.

FirstLobster commented 2 years ago

@akallabeth https://github.com/akallabeth/FreeRDP/tree/monitor_log just gives me a 404 And if i try to clone the repo i get remote branch monitor_log not found in upstream origin could it be the https://github.com/akallabeth/FreeRDP/tree/advanced_logging branch?

akallabeth commented 2 years ago

@FirstLobster sorry, did create an upstream pr from that and upon merging the branch was deleted. You can just use FreeRDP master now.

FirstLobster commented 2 years ago

after i fixed all the missing dependencies i was able to run dpkg-buildpackage but it errors out with dh_auto_install: error: mkdir debian/freerdp-nightly: File exists make: *** [debian/rules:35: binary] Error 255 dpkg-buildpackage: error: debian/rules binary subprocess returned exit status 2

I have googled it to the best of my abilities but have not been able to fix it.

akallabeth commented 2 years ago

@FirstLobster did you start with a clean checkout? do git clean -xdf and restart, otherwise there is nothing that can fail there. As for dependencies, did you run apt build-dep? that should take care of that...

FirstLobster commented 2 years ago

Thanks, clean did the trick.

FirstLobster commented 2 years ago

Just a update, running only sudo apt build-dep freerdp2-dev and then the running dpkg-buildpackage leaves me with dpkg-checkbuilddeps: error: Unmet build dependencies: cdbs libfuse-dev | libfuse3-dev libdbus-glib-1-dev I solved with installing apt install devscripts and apt install equivs and then running mk-build-deps --install --root sudo --remove

FirstLobster commented 2 years ago

@akallabeth I did run /opt/freerdp-nightly/bin/xfreerdp /log-level:debug <yourargs here> 2>&1 |tee somefile.txt but i found none of the lines you mentioned. I have attached the file. Freerdp_log.txt My args: -grab-keyboard /multimon /monitors:4,5,2

akallabeth commented 2 years ago

@FirstLobster then please retry, I´ve just tested this on my local setup and the lines are in there.

FirstLobster commented 2 years ago

@akallabeth Just to be sure should i use https://github.com/akallabeth/FreeRDP.git -b master or https://github.com/FreeRDP/FreeRDP.git -b master ?

akallabeth commented 2 years ago

@FirstLobster it is already upstream, so you can also just use the last nightly. (but for git use the https://github.com/freerdp/freerdp link

FirstLobster commented 2 years ago

@akallabeth

[13:41:15:365] [418746:418748] [DEBUG][com.freerdp.core.gcc] - [gcc_write_client_monitor_data] MonitorCount=3
[13:41:15:365] [418746:418748] [DEBUG][com.freerdp.core.gcc] - [gcc_write_client_monitor_data] Monitor[0]: top=0, left=3840, bottom=1199, right=5759, flagsu
[13:41:15:365] [418746:418748] [DEBUG][com.freerdp.core.gcc] - [gcc_write_client_monitor_data] Monitor[1]: top=0, left=0, bottom=1199, right=1919, flagsu
[13:41:15:365] [418746:418748] [DEBUG][com.freerdp.core.gcc] - [gcc_write_client_monitor_data] Monitor[2]: top=0, left=1920, bottom=1199, right=3839, flagsu

the output from /opt/freerdp-nightly/bin/xfreerdp /monitor-list is

      * [0] 1920x1200   +0+0
        [1] 1920x1200   +1920+0
        [2] 1920x1200   +3840+1200
        [3] 1920x1200   +3840+0
        [4] 1920x1200   +0+1200
        [5] 1920x1200   +1920+1200

My monitor layout is 0 1 3 4 5 2 My args where monitors: 4,5,2 With this i end up having the remote view on monitor 5 and 2.

If i change the args to monitors: 4,5 i get

[14:07:29:195] [419439:419441] [DEBUG][com.freerdp.core.gcc] - [gcc_write_client_monitor_data] Monitor[0]: top=0, left=0, bottom=1199, right=1919, flagsu
[14:07:29:195] [419439:419441] [DEBUG][com.freerdp.core.gcc] - [gcc_write_client_monitor_data] Monitor[1]: top=0, left=1920, bottom=1199, right=3839, flagsu

And this works as expected.

akallabeth commented 2 years ago

@FirstLobster ok, this is helpful. Does changing the order of the monitors change something for you? This looks like the order sent is wrong (1, 0, 3 or 2, 4, 5)

FirstLobster commented 2 years ago

@akallabeth Yes, changing the monitor order does affect how it behaves, but i cant set how the order should be, as soon as i switch places on the DP-cables all the monitors could get new numbers. i have tried to just brut force and just switching and trying and could sometimes get it to work but as soon you turn a monitor off or disconnect a monitor it can break.

Would it be possible to sort the monitors from its position so it sends the right monitor number?

akallabeth commented 2 years ago

@FirstLobster ok. Yes, it would be possible to do that, but will require additional code changes (you need to keep a mapping of local to remote monitors and adjust mouse, touch, graphics updates, ... accordingly)

FirstLobster commented 2 years ago

@akallabeth Okey, well that doesn't sound like a quick fix :/ Will do some more testing to see if the monitor numbering could be the issue.

FirstLobster commented 2 years ago

@akallabeth So i did some testing and it looks like it does not matter if i choose the top 2 or 3 monitors or the bottom ones, the [gcc_write_client_monitor_data] is still the same. So it looks like the only thing that matters in what order the monitors are presented to the rdp server.

My monitor layout
the top left is my primary

       * [0] 1920x1200  +0+0
        [1] 1920x1200   +1920+0
        [2] 1920x1200   +3840+1200
        [3] 1920x1200   +3840+0
        [4] 1920x1200   +0+1200
        [5] 1920x1200   +1920+1200

0 1 3
4 5 2

Monitors 0,1 - Working

[01:59:17:406] [427129:427130] [DEBUG][com.freerdp.core.gcc] - [gcc_write_client_monitor_data] MonitorCount=2
[01:59:17:406] [427129:427130] [DEBUG][com.freerdp.core.gcc] - [gcc_write_client_monitor_data] Monitor[0]: top=0, left=0, bottom=1199, right=1919, flagsu
[01:59:17:406] [427129:427130] [DEBUG][com.freerdp.core.gcc] - [gcc_write_client_monitor_data] Monitor[1]: top=0, left=1920, bottom=1199, right=3839, flagsu

monitors 4,5 - Working

02:01:00:457] [427245:427246] [DEBUG][com.freerdp.core.gcc] - [gcc_write_client_monitor_data] MonitorCount=2
[02:01:00:457] [427245:427246] [DEBUG][com.freerdp.core.gcc] - [gcc_write_client_monitor_data] Monitor[0]: top=0, left=0, bottom=1199, right=1919, flagsu
[02:01:00:457] [427245:427246] [DEBUG][com.freerdp.core.gcc] - [gcc_write_client_monitor_data] Monitor[1]: top=0, left=1920, bottom=1199, right=3839, flagsu

Monitors 0,4 - picture on 0 and 4 but monitors 1 and 5 goes black

[02:02:31:660] [427331:427332] [DEBUG][com.freerdp.core.gcc] - [gcc_write_client_monitor_data] MonitorCount=2
[02:02:31:660] [427331:427332] [DEBUG][com.freerdp.core.gcc] - [gcc_write_client_monitor_data] Monitor[0]: top=0, left=0, bottom=1199, right=1919, flagsu
[02:02:31:660] [427331:427332] [DEBUG][com.freerdp.core.gcc] - [gcc_write_client_monitor_data] Monitor[1]: top=1200, left=0, bottom=2399, right=1919, flagsu

Monitors 3,2 - Working

[02:11:31:618] [427726:427727] [DEBUG][com.freerdp.core.gcc] - [gcc_write_client_monitor_data] Monitor[0]: top=1200, left=0, bottom=2399, right=1919, flagsu
[02:11:31:618] [427726:427727] [DEBUG][com.freerdp.core.gcc] - [gcc_write_client_monitor_data] Monitor[1]: top=0, left=0, bottom=1199, right=1919, flagsu

Monitors 0,1,3 - Working

[02:06:08:656] [427428:427429] [DEBUG][com.freerdp.core.gcc] - [gcc_write_client_monitor_data] MonitorCount=3
[02:06:08:656] [427428:427429] [DEBUG][com.freerdp.core.gcc] - [gcc_write_client_monitor_data] Monitor[0]: top=0, left=0, bottom=1199, right=1919, flagsu
[02:06:08:656] [427428:427429] [DEBUG][com.freerdp.core.gcc] - [gcc_write_client_monitor_data] Monitor[1]: top=0, left=1920, bottom=1199, right=3839, flagsu
[02:06:08:656] [427428:427429] [DEBUG][com.freerdp.core.gcc] - [gcc_write_client_monitor_data] Monitor[2]: top=0, left=3840, bottom=1199, right=5759, flagsu

Monitors 4,5,2 - picture on 5 and 2

[02:07:46:011] [427519:427520] [DEBUG][com.freerdp.core.gcc] - [gcc_write_client_monitor_data] MonitorCount=3
[02:07:46:011] [427519:427520] [DEBUG][com.freerdp.core.gcc] - [gcc_write_client_monitor_data] Monitor[0]: top=0, left=3840, bottom=1199, right=5759, flagsu
[02:07:46:011] [427519:427520] [DEBUG][com.freerdp.core.gcc] - [gcc_write_client_monitor_data] Monitor[1]: top=0, left=0, bottom=1199, right=1919, flagsu
[02:07:46:011] [427519:427520] [DEBUG][com.freerdp.core.gcc] - [gcc_write_client_monitor_data] Monitor[2]: top=0, left=1920, bottom=1199, right=3839, flagsu
akallabeth commented 2 years ago

@FirstLobster ok, I see the problem. The current crude algorithm orders the monitors wrong. With windows, primary needs to start at 0,0 and all others must be right/below that one. Additionally there must be no gaps between monitors The reordermapping currently done does not properly do that and so you either have only the monitors visible that are right/below the primary without gaps.

FirstLobster commented 2 years ago

@akallabeth I figure that there is no easy fix and there are more important stuff to fix, but just let me know if there is anything i can do to help with the issue. Thank your for all your help!

arrowd commented 2 months ago

It seems we bumped into the same issue. What would the proper fix look like? Maybe we can contribute a fix.

github-actions[bot] commented 2 weeks ago

This issue is stale because it has been open for 30 days with no activity.

robamoroso commented 6 days ago

Something similar to this is happening to me as well.

I'm running Kubuntu 24.04 with a four monitor configuration with KDE5 and X.

I apologize for the graphic below. The post was stripping the spaces. The + characters are the screens themselves, | and - are the borders of the screens and _ is jsut a placeholder so the top two lines would line up on the right.

__ ----------- _____ ++++++ ------------------------- ------------------------- +++1++ ++++++++++++++ ++++++++++++++ +++++ +++++++ 0 +++++ ++++2 +++++++++ ---------- ++++++++++++++ ++++++++++++++ ----------------------- ++++++++++++++ ++++++++++++++ ++++++3++++++ ++++++++++++++ ++++++++++++++ +++++++++++++

0 and 2 are 3840x2160 1 is 1080x1920 (portrait) 3 is 1920x1080

I'm getting strange results when specifying the monitors. At first I thought it had something to do with the odd shape of the layout so I messed around with them to make it more square but no luck.

I then tried passing just one monitor at a time to the /monitors parameter and saw something odd. /monitors:0 displays correctly /monitors:1 displays correctly /monitors:2 will not display on #2 but displays instead on #0 /monitors:3 displays correctly

Here's the monitors output in case it might help from /list:monitors:

Here's what xrandr says about the layout: 0: +*HDMI-0 3840/698x2160/393+3840+840 HDMI-0 1: +DVI-D-0 1080/531x1920/299+7680+0 DVI-D-0 2: +DP-1 3840/698x2160/393+0+840 DP-1 3: +DVI-I-1 1920/510x1080/287+7680+1920 DVI-I-1

I was recently running kubuntu 22.04 which was working somewhat correctly. At the time I was using freerdp2. Although it would show similar behavior as above with single monitors, it would work if I specified it as /monitors:0,2,3 which itself made no sense but it worked for some reason. After my upgrade to 24.04, it won't work anymore and shows the behavior above. I've tried with both freerdp 2 and 3 and they seem to behave the same. It just makes no sense to me and seems like however freerdp is calculating which monitor to display on, it will not display on #2 no matter what I try. If this isn't the same bug, I'm happy to create a new one but it seems similar so I figured I'd start with a report here.

EDIT: If I use the /multimon switch without a monitor list, it loads on all four monitors correctly and works great. Maybe that's a clue, not sure.