Repository navigation
Description
English summary: On KDE Wayland, a cold desktop connection made while the session is locked never produces a picture: the Portal request stays behind the lock screen, so only the synthetic 1 fps black frame is sent. Two host-side causes: the Portal app_id for a service-managed host is the empty string (xdg-desktop-portal only derives an app_id from app-<id>.service unit names), and the restore data is kept only in process memory and discarded outright when one restore attempt fails. Running the host under app-uu\x2dremote\x2dlinux.service plus a kde-authorized entry for uu-remote-linux fixes it; details and log evidence below.
环境
- Ubuntu 26.04.1 LTS,KDE Plasma 6.6.7 / KWin 6.6.7,Wayland 会话
- xdg-desktop-portal 1.21.1+ds-1ubuntu3.1,xdg-desktop-portal-kde 6.6.7-0ubuntu0.1
- uu-remote-linux 0.2.67(deb),以 user unit
uuremote-native.service启动,RUST_LOG=info - 控制端:官方 iPhone 客户端(
controller_platform=3,controller=Ios) - 链路:中继(
relay_only=true),RTT 约 140–210 ms
现象
桌面锁屏,控制端连接能建立(DataChannel/CONTROL 正常,客户端停在“正在传输画面”),但始终没有画面。主机日志只有每秒一帧的合成帧,没有任何 Portal authorization result:
Desktop is locked; opening Portal capture for the lock screen
Portal attempt: reopening the capture session (force_wake=true)
Locked desktop video: sent=1 codec=H265 synthetic_size=1280x720 bytes=2757 attempts=1
... 持续 29–32 秒,直到控制端断开
解锁后(有人在本机登录桌面)连接立即恢复正常画面。
根因
1. Portal 调用方 app_id 为空,KDE 的 mega-authorization 永远不命中
xdg-desktop-portal 只为进程所属 systemd 单元匹配 app-<id>.service 形态时才解析出 app_id,其它情况一律给空字符串。uuremote-native.service 不符合,所以 app_id 是 ""。KDE 的 isAppMegaAuthorized() 按 app_id 查 kde-authorized/remote-desktop,空串身份在权限存储里没有条目,于是每次连接都要弹 RemoteDesktopDialog。锁屏时对话框在锁屏界面之后,无人可点,portal 的 Start 一直挂起,主机只能继续发合成黑帧。
2. restore data 只存在进程内,服务重启即失效
0.2.67 只在进程内存里保存 Portal 返回的 restore data。persist_mode 的语义本意就是让应用把 restore data 持久化、下次启动复用,目前没有做到。结果是每次重启服务后,第一次桌面连接都必须有人在本机交互一次。
3. restore 失败时直接丢弃 token,锁屏状态下无法自愈
[22:12:50] WARN uuremote_server::portal::native] Portal request failed with a restore token;
discarding it and retrying once without restore (a consent dialog may appear)
[xdg-desktop-portal-kde] xdp-kde-screencast: Could not find a matching Wayland output for screen ""
丢弃之后,本来靠 restore data 免弹框的路径彻底消失;而此时桌面已经锁屏,后续每次连接都变成上面第 1 条的挂起。也就是说一次 restore 失败会把“能用的免授权通道”清成“必须交互”,而这个交互在锁屏时不可能完成。
证据时间线(UTC+8)
| 时间 | 事件 |
|---|---|
| 22:12:44 | 用旧 restore token 打开采集成功:Portal authorization result: devices_present=1 device_bits=7 stream_count=1,Portal capture format: size=2560x1440,encoder=hevc_nvenc maxrate=8000k |
| 22:12:50 | 续用 token 失败(上面的 Could not find a matching Wayland output for screen ""),主机丢弃 token |
| 22:28:20 | 锁屏重连,32 秒内只有 synthetic 黑帧,无 Portal authorization result |
| 22:33:24 | 同上,29 秒只有 synthetic 黑帧 |
| 22:36:48 | 在 kde-authorized/remote-desktop 里为空 app_id 加了一条 yes 后,同样锁屏状态立刻出图:stream_count=1、2560x1440、hevc_nvenc、maxrate=8000k |
已验证的规避
把 host 单元改名为 app-uu\x2dremote\x2dlinux.service(systemd 转义,xdg-desktop-portal 解析出 app_id = uu-remote-linux,对应已有的 /usr/share/applications/uu-remote-linux.desktop),并在权限存储里授权 kde-authorized/remote-desktop → uu-remote-linux = yes。改完后服务重启、锁屏冷连接都直接出图,无需任何交互。空 app_id 的临时授权已撤销。
建议
- 持久化 restore data:按
persist_mode的语义落盘,重启后复用。这能覆盖绝大多数“服务重启 + 锁屏”场景。 - restore 失败不要丢弃 token:至少保留并在同进程内重试,或在丢弃前确认新通道可用。现在一次失败就把唯一可用的免授权路径清空,锁屏时无法恢复。
- 支持固定 app_id:例如
UU_APP_ID,或在非app-*.service部署时默认按uu-remote-linux注册。空 app_id 在 KDE 上还有副作用:权限存储里针对空串的授权会覆盖所有没有 app_id 的调用方(Xwayland 程序),用户一般不会想为了一个远控工具这样放宽。 - README 修正:
KDE Plasma(KWin)的 Portal 采集在锁屏后仍会继续这一段的“冷连接可以直接看到真实锁屏界面”需要补前提——进程内已有 restore data,或该 app_id 已被授权;否则冷启动进程 + 锁屏会卡在授权对话框。
复现
- KDE Wayland 下锁屏;
- 删除权限存储里该调用方(或空 app_id)的条目,模拟“从未授权过”,例如新用户、新机器;
- 重启 host 服务,使进程内 restore data 失效;
- 控制端冷连接 → 一直无画面,主机日志只出现
Locked desktop video ... synthetic。
Activity
feat(portal): opt-in UU_PORTAL_APP_ID registers the caller app id (#266)
VallierDev commentedon Nov 27, 2026
感谢这么完整的分析和时间线!逐条说明:
UU_PORTAL_APP_ID(如uu-remote-linux),主机在首次调用 Portal 前通过org.freedesktop.host.portal.Registry(xdg-desktop-portal ≥ 1.19)注册它。默认不开启,原因是 restore 授权按 app_id 存储,换 app_id 会让所有现有用户保存的授权失效一次,无人值守的机器会因此卡在授权框。会随下个版本发布,发版后再请你帮忙验证。~/.config/uuremote/portal-permissions/,服务重启后会复用。你这次是 22:12:50 那次续用失败把 token 用掉了,不是重启导致的。Could not find a matching Wayland output for screen "",主机这边无法恢复已消耗的 token,所以对锁屏场景来说,app_id +kde-authorized才是可靠的办法。kde-authorized做法。🤖 Generated with Claude Code
VallierDev commentedon Nov 27, 2026
UU_PORTAL_APP_ID已随 v0.2.68 发布(Release CI 已编译 Portal 插件,x86_64 产物已核验 sha256/依赖/--help):https://github.com/VallierDev/uu-remote-linux/releases/tag/v0.2.68方便时请在 KDE 上升级后验证:
UU_PORTAL_APP_ID=uu-remote-linux(与 README 里的单元改名 / kde-authorized 做法对应),重启服务;请附
uuremote-server doctor输出和这次连接的脱敏日志(含portal相关行)。谢谢!🤖 Generated with Claude Code