Files
ultix/12-fix-rdp-bigres.sh
T
mrcharles f66138e40b #611 UAT PASS both accounts; close-out + session-hygiene part 5 (#611)
Full matrix green incl. close-Jump-and-return (apps persist, reconnect
resumes). DisconnectedTimeLimit=0 + tcp keepalives documented; the
manager-recycle clean-slate layer (systemctl stop user@UID) captured in
the script. Scratch user/harness removed.

Details: https://projects.knownelement.com/issues/611
2026-09-01 17:38:55 -05:00

133 lines
6.3 KiB
Bash
Executable File

#!/bin/bash
# 12-fix-rdp-bigres.sh — xrdp EGFX big-resolution fix (Redmine #611)
#
# Symptom: Jump Desktop from iPad -> big external monitor (5160x2160)
# showed color bars / cut sides. Root cause candidate: default EGFX
# compressed-frame budget truncates large frames at this width.
# freerdp UAT at 5160x2160 (all codecs + mid-session resize) is clean;
# this mitigation raises the budget for the Jump client path.
#
# Idempotent: run as root on ultix-streaming.
set -euo pipefail
DROPIN=/etc/systemd/system/xrdp.service.d/bigres.conf
mkdir -p "$(dirname "$DROPIN")"
cat > "$DROPIN" <<'EOF'
[Service]
Environment=XRDP_GFX_MAX_COMPRESSED_BYTES=33554432
Environment=XRDP_GFX_FRAMES_IN_FLIGHT=2
EOF
systemctl daemon-reload
# bounce only when nobody is connected: check for active RDP sessions first
ACTIVE=$(pgrep -c -f 'Xorg.*xrdp/xorg.conf' || true)
if [ "${ACTIVE:-0}" -gt 0 ]; then
echo "Active RDP X sessions: $ACTIVE — NOT restarting; apply at next bounce with:"
echo " systemctl restart xrdp-sesman xrdp"
else
systemctl restart xrdp-sesman xrdp
sleep 2
systemctl is-active xrdp xrdp-sesman
fi
grep -q XRDP_GFX_MAX_COMPRESSED_BYTES "$DROPIN" && echo "drop-in present: $DROPIN"
###############################################################################
# Part 2 — kwin_x11 black-screen fix (root-caused 2026-09-01, #611)
#
# Symptom: RDP login -> KDE spinner -> BLACK screen. Server-side bisect
# showed display :10 rendering pure black (colors=1): kwin_x11 was
# crash-looping (plasma-kwin_x11.service "start operation timed out",
# restart counter 12+). Cause: software-GL compositing init under
# xorgxrdp (no DRI) at 5160x2160 never finishes inside the unit's
# start timeout; systemd kills kwin -> no desktop. The "spinner" the
# user sees is KSplash firing on every kwin restart.
#
# Fix: disable X11 compositing for the RDP accounts (kwin runs
# uncomposited = instant, no GL) and give the kwin unit start-time
# headroom. Wayland console session unaffected (Compositing/Enabled is
# an X11-only key). Verified with the freerdp harness on rdptest:
# fresh 1408x945 / fresh 5160x2160 / resize up mid-session / resize
# down on reconnect — all render real desktops.
###############################################################################
for ACCOUNT in reachableceo reachableceo-offstage; do
runuser -u "$ACCOUNT" -- kwriteconfig6 --file kwinrc \
--group Compositing --key Enabled false
echo "kwinrc Compositing=false: $ACCOUNT"
done
mkdir -p /etc/systemd/user/plasma-kwin_x11.service.d
cat > /etc/systemd/user/plasma-kwin_x11.service.d/bigres-timeout.conf <<'EOF'
[Service]
# big-res xorgxrdp sessions: software-GL init is slow; give kwin room
# instead of kill+crashloop (#611)
TimeoutStartSec=300
EOF
systemctl daemon-reload
###############################################################################
# Part 3 — EGFX off for all clients (drdynvc=false), 2026-09-01 evening
#
# Final piece of #611: with the server rendering CLEAN at 5160x2160
# (verified by band-analysis of live captures + freerdp harness on every
# codec), Jump Desktop still painted color bars down the side — its
# decode of xrdp's EGFX large frames is broken regardless of the
# compressed-frame budget. EGFX rides the drdynvc channel; blocking it
# server-side makes every client (Jump included) fall back to the
# classic codecs, which render this monitor fine. Clipboard (cliprdr)
# and audio (rdpsnd) are separate channels and survive.
###############################################################################
sed -i 's/^drdynvc=true/drdynvc=false/' /etc/xrdp/xrdp.ini
grep -q '^drdynvc=false' /etc/xrdp/xrdp.ini || { echo "drdynvc line missing; check /etc/xrdp/xrdp.ini" >&2; exit 1; }
###############################################################################
# Part 4 — max_bpp=24: the actual color-bars root cause (2026-09-01 night)
#
# With EGFX off, Jump's fallback is classic bitmap tiles — and xrdp's
# bitmap path DROPS tiles with "libxrdp_send_bitmap: error, decompressed
# size too big: 20640 bytes" because 5160 px * 4 Bpp overflows the 16K
# row buffer. Jump paints the dropped tiles as bars. At 24bpp the row
# is 15480 bytes and fits. (freerdp never hit this: it negotiates
# NSCodec/planar after EGFX goes away.)
###############################################################################
sed -i 's/^max_bpp=.*/max_bpp=24/' /etc/xrdp/xrdp.ini
grep -q '^max_bpp=24' /etc/xrdp/xrdp.ini || { echo "max_bpp line missing; check /etc/xrdp/xrdp.ini" >&2; exit 1; }
ACTIVE=$(pgrep -c -f 'Xorg.*xrdp/xorg.conf' || true)
if [ "${ACTIVE:-0}" -gt 0 ]; then
echo "Active RDP X sessions: $ACTIVE — xrdp listener restart will blip clients;"
echo "sessions survive (sesman untouched). Apply with: systemctl restart xrdp"
else
systemctl restart xrdp
fi
echo "EGFX disabled (drdynvc=false) — clients now negotiate classic codecs."
###############################################################################
# Part 5 — session hygiene (2026-09-01 night, #611 close-out)
#
# - sesman.ini: KillDisconnected=false + DisconnectedTimeLimit=0 — human
# keeps apps up 24x7 and reconnects at will.
# - xrdp.ini: tcp_nodelay/tcp_keepalive=true so dead client connections
# (iPad backgrounding Jump) are detected; reconnects then RESUME the
# existing session instead of spawning duplicates.
# - THE CLEAN SLATE, when a login black-screens and nothing else works:
# the systemd --user manager accumulates poisoned state across session
# generations (stale DISPLAY env, wedged dbus name waits — plasma units
# are Type=dbus and hang "activating" at ~0% CPU). Recycle it:
# systemctl stop user@<uid>
# then reconnect (fresh manager = clean login at ANY resolution).
# pkill of kwin/plasmashell/Xorg alone does NOT reach this layer.
###############################################################################
grep -q '^DisconnectedTimeLimit=0' /etc/xrdp/sesman.ini || sed -i 's/^DisconnectedTimeLimit=.*/DisconnectedTimeLimit=0/' /etc/xrdp/sesman.ini
grep -qE '^tcp_keepalive' /etc/xrdp/xrdp.ini || printf 'tcp_keepalive=true\ntcp_nodelay=true\n' >> /etc/xrdp/xrdp.ini
echo "session hygiene present (DisconnectedTimeLimit=0, tcp keepalives)."
echo "kwin unit override: /etc/systemd/user/plasma-kwin_x11.service.d/bigres-timeout.conf"
echo
echo "If a session is currently black: loginctl terminate-session <id> (or"
echo "loginctl terminate-user <user> for their RDP sessions) and reconnect."