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

[WIP] merging in EGFX and resize changes #220

Open
wants to merge 3 commits into
base: devel
Choose a base branch
from

Conversation

Nexarian
Copy link
Contributor

author Christopher Pitstick [email protected] 1615102163 -0500
committer Nexarian [email protected] 1651116572 -0400

Add trishume:improve-large-updates-pr

With scroll detection removed.

Adding in egfx.

Merging in nvidia_hack.

Avoid potential infinite loop for rdpUpdate.

When frame acknowledgement is enabled, such as with the prototype of
egfx, the driver is at risk of going into an infinite loop if for some
reason an ack is missed.

While this line could fix it from xrdp: mm->mod->mod_frame_ack(mm->mod, 0, INT_MAX);,
the driver needs to be stable by itself.

The rationale here is that this is akin to a network socket timeout.
After a certain wait, it gives up. Same here.

Also, frame acknowledgement is a quality of service feature, and is not
strictly necessary for the functionality of remote desktop. In the worst
case, bandwidth calcuations between client and server are temporarily
incorrect.

200 was selected after some empirical testing, it could be tweaked.

[184680.280] rdpDeferredUpdateCallback: reschedule rect_id 542 rect_id_ack 541, retries: 197
[184680.284] rdpDeferredUpdateCallback: reschedule rect_id 542 rect_id_ack 541, retries: 198
[184680.289] rdpDeferredUpdateCallback: reschedule rect_id 542 rect_id_ack 541, retries: 199
[184680.293] rdpDeferredUpdateCallback: reschedule rect_id 542 rect_id_ack 541, retries: 200
[184680.298] rdpDeferredUpdateCallback: reschedule rect_id 542 rect_id_ack 541, retries: 201
[184680.298] rdpScheduleDeferredUpdate: clientCon->retries is 201 and has exceeded timeout. Overriding rect_id_ack.

Merging in xorgxrdp_helper hack.

work on nvidia

work on nvidia

use damage to know when opengl, vulkan, vdpau apps draw

fix for non multiple 64 width desktop, other non logic changes

add nv12_709fr functions

fix for multiple nvidia gpus

add nv12 yuv to rgb for non multiples of 8

add nv12_709fr functions

some fixes for h264 encoder alignments

add a8r8g8b8_to_nv12_709fr_box_x86_sse2 to funcs_x86.h

add capture for yuv444

hack to use helper

helper, don't open stdout/err files

allow for 0 in MIN_MS_TO_WAIT_FOR_MORE_UPDATES

fix for stack overflow

fix for T4

helper pixmap fixes

Fixing bad merge.

More bad merge fixes.

Updates for resizing stability

Updating pre-increment directive.

Small update for consistency with devel.

Fixing clientCon rect_id increment.

Merging in use of flag for nvenc encoding.

Adding in XRDP_USE_HELPER

Adding 444 capture.

Adding patch for Nvidia present and dri3 extension compatibility.

Stability enhancements to block capture until invalidate.

Stability improvements.

Fixing retry issue.

Compatibility with latest xrdp.

@akarl10
Copy link
Contributor

akarl10 commented Oct 2, 2022

I've made some experiments with this branch with different hardware configurations and same compile (built on a custom ppa)

What I discovered is that if lrandr is enabled non nvidia configuration crash immediately

[  1190.600] rdpDeferredRandR:
[  1190.601] rdpResizeSession: width 1024 height 768
[  1190.601]   calling RRScreenSizeSet
[  1190.601] rdpRRScreenSetSize: width 1024 height 768 mmWidth 271 mmHeight 203
[  1190.601] rdpRRScreenSetSize: screen_tex 0x00000003
[  1190.602] rdpRRGetInfo:
[  1190.602]   screen resized to 1024x768
[  1190.602]   RRScreenSizeSet ok 1
[  1190.602] rdpResizeSession: width 1024 height 768
[  1190.602] rdpInDeferredRepeatCallback:
[  1190.602] rdpkeybChangeKeyboardControl:
[  1190.602] rdpkeybChangeKeyboardControl: autoRepeat off
[  1190.660] rdpClientConGotConnection:
[  1190.660] rdpClientConGotConnection: g_sck_accept ok new_sck 9
[  1190.660] rdpClientConGetConnection: idle_disconnect_timeout set to non-positive value, idle timer turned off
[  1190.660] rdpAddClientConToDev: adding first clientCon 0x55d6a1731460
[  1190.661] rdpClientConProcessMsgVersion: version 0 0 0 1
[  1190.661] rdpClientConProcessScreenSizeMsg: set width 1024 height 768 bpp 32
[  1190.661] rdpClientConAllocateSharedMemory: shmemid 7 shmemptr 0x7f0197b20000 bytes 3145728
[  1190.661] rdpClientConProcessMsgClientInput: invalidate x 0 y 0 cx 1024 cy 768
[  1190.661] KbdSync: toggling num lock
[  1190.662] rdpClientConProcessMsgClientInfo:
[  1190.662]   got client info bytes 7184
[  1190.662]   jpeg support 0
[  1190.662]   offscreen support 0
[  1190.662]   offscreen size 0
[  1190.662]   offscreen entries 0
[  1190.662] rdpClientConProcessMsgClientInfo: got RFX capture
[  1190.662]   cap_width 1024 cap_height 768
[  1190.662] rdpClientConAllocateSharedMemory: reusing shmemid 7
[  1190.662]   client can not do offscreen to offscreen blits
[  1190.662]   client can do new(color) cursor
[  1190.663]   client can not do multimon
[  1190.663] (EE) 
[  1190.663] (EE) Backtrace:
[  1190.664] (EE) 0: /usr/lib/xorg/Xorg (OsLookupColor+0x139) [0x55d69e8f16e9]
[  1190.680] (EE) 1: /lib/x86_64-linux-gnu/libc.so.6 (__sigaction+0x50) [0x7f01aa237520]
[  1190.681] (EE) 2: /usr/lib/xorg/modules/libxorgxrdp.so (rdpEglDestroy+0x313) [0x7f01a966df83]
[  1190.683] (EE) 3: /usr/lib/xorg/modules/libxorgxrdp.so (rdpClientConCheck+0xc24) [0x7f01a9669364]
[  1190.684] (EE) 4: /usr/lib/xorg/Xorg (WakeupHandler+0xb3) [0x55d69e780053]
[  1190.687] (EE) 5: /usr/lib/xorg/Xorg (WaitForSomething+0x1a2) [0x55d69e8eae32]
[  1190.689] (EE) 6: /usr/lib/xorg/Xorg (SendErrorToClient+0x117) [0x55d69e77b257]
[  1190.689] (EE) 7: /usr/lib/xorg/Xorg (InitFonts+0x3c4) [0x55d69e77f524]
[  1190.692] (EE) 8: /lib/x86_64-linux-gnu/libc.so.6 (__libc_init_first+0x90) [0x7f01aa21ed90]
[  1190.695] (EE) 9: /lib/x86_64-linux-gnu/libc.so.6 (__libc_start_main+0x80) [0x7f01aa21ee40]
[  1190.696] (EE) 10: /usr/lib/xorg/Xorg (_start+0x25) [0x55d69e7685f5]
[  1190.696] (EE) 
[  1190.696] (EE) Segmentation fault at address 0x0
[  1190.696] (EE) 
Fatal server error:
[  1190.696] (EE) Caught signal 11 (Segmentation fault). Server aborting

with a nvidia gpu it works and xrandr also shows the rdp0 display that is missing without lrandr.

@akarl10
Copy link
Contributor

akarl10 commented Oct 2, 2022

I discovered why lrandr crashes if not used with an nvidia gpu:

rdpKeyboard:rdpkeybPlug calls xorgxrdpCheckWrap. This one set xf86DriverList[0]->PciProbe if the x driver is NVIDIA.
xorgxrdpPciProbe calls xorgxrdpWrapPreIntScreenInit that sets up xorgxrdpScreenInit. xorgxrdpScreenInit then call xorgxrdpDeferredStartup with a TimerSet. xorgxrdpDeferredStartup then does the much needed call to rdpLRRInit(dev);

believe it or not, but for lrandr to initialize we depend on the keyboard part and NVIDIA that supposedly needs some crude initialization 😭

- Add trishume:improve-large-updates-pr with scroll detection removed.
- Adding in egfx compatibility written by Jay Sorg.
- Adding in Nvidia integration written by Jay Sorg.
- Misc fixes to prevent infinite loops from occuring in the driver.
- Fixes to enable compatibility with dynamic resolution resizing.
- Integrate with the xorgxrdp_helper (acceleration assistant) for direct
video memory access.
- Use damage to know when opengl, vulkan, vdpau apps draw
- Add capture for yuv444
- Adding patch for Nvidia present and dri3 extension compatibility.
- Stability enhancements to block capture until invalidate.
- Compatibility with xorgxrdp_helper for GFX H264 and RFX PRO
- Updated memory allocation.
- Adding LRandR extension that enables Gnome 3 with Nvidia.

Fix corruption at low latency.

This fix was introduced to prevent an infinite timeout/loop problem that
resulted from certain edge cases in the dynamic resolution state
machine. However, further improvements have rendered this unnecessary.

An unintended side effect of this was disabling high-quality timing of
the shared memory, resulting in corruption issues.

Stress tested the resizing feature again without this, and it works
fine.
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