Skip to content

fix(portal): recover capture sooner after GNOME display changes (#27) - #35

Merged
VallierDev merged 2 commits into
VallierDev:mainfrom
wanglz111:codex/issue27-display-recovery
Oct 17, 2026
Merged

VallierDev merged 2 commits into
VallierDev:mainfrom
wanglz111:codex/issue27-display-recovery

Conversation

@wanglz111

Copy link
Copy Markdown
Contributor

Fixes #27

GNOME scaling changes can leave Portal capture paused without a negotiated format until the existing five-second failure threshold expires. This change uses Mutter MonitorsChanged to check that failure sooner and reuse the existing serialized session recovery.

实现 / Implementation

  • 每个 GNOME Portal 会话在已有 D-Bus context 订阅显示变化;只有已推流且连续「暂停、无格式」的采集与通知相关联,才在两者就绪后的 200 ms 宽限结束后提前恢复。
  • 有效格式或重新推流清除提前检查提示;重复通知不延长同次异常的判定。保留原有 5 秒兜底,输入和剪贴板存活判断不变。
  • Subscribe per GNOME Portal handle on its existing D-Bus context. Require a continuously paused, format-less stream and a correlated notification, then allow 200 ms from the later condition before reporting capture failure.
  • Healthy renegotiation clears the hint; repeated notifications do not postpone the interruption. Preserve the five-second fallback and existing input/clipboard health checks.

实测 / Measurements

Ubuntu 26.04, GNOME 50 Wayland, one 3840x2160 display, 200% ↔ 166.67% scaling:

  • 原路径中,PAUSED 在通知前 5–9 ms,格式清空在通知后 10–36 ms。通知后仅检查一次会漏掉格式稍后清空的情况。
  • 独立真实采集/编码探针中,通知到会话恢复从约 6.15–6.18 s 降至 1.396 / 1.360 s。
  • 相隔 163 ms 的连续双切换只恢复一次;静态观察 30 s 无额外恢复;探针正常编码 3,600 帧,首帧为 IDR。
  • Before the change, PAUSED preceded notification receipt by 5–9 ms and NULL format followed by 10–36 ms. Independent real capture/encoding tests reduced notification-to-restored time from about 6.15–6.18 s to 1.396 / 1.360 s.
  • A pair of changes 163 ms apart caused one recovery; 30 seconds of static observation caused none. The probe completed 3,600 encoded frames with an initial IDR.

200 ms 是本机测量后的初始宽限,不是所有 GNOME 版本的保证。候选版官方客户端的渲染、鼠标和黑屏耗时尚未完成验收;上述数字是主机会话恢复时间。其他桌面保留兜底;多屏、物理分辨率和旋转不在本次范围。

The 200 ms grace is an initial measured value, not a guarantee across GNOME versions. Official-viewer rendering, pointer acceptance and black-screen duration remain unverified for the candidate; these measurements cover host session recovery. Other desktops retain the fallback. Multi-monitor, physical-resolution and rotation support remain outside this change.

Details: docs/experiments/issue-27-display-recovery.md.

验证 / Validation

  • cargo test --locked --features wayland,portal
  • cargo build --locked --release --features wayland,portal
  • Four native suites under ASan/UBSan, including 13 EIS geometries.
  • Coverage includes all six event orders, grace boundaries, stale/repeated/delayed notifications, natural recovery, clipboard readiness, and private D-Bus subscription teardown with/without a worker.

Use Mutter notifications to enable a 200 ms grace for correlated, continuously paused capture without a valid format. Cancel stale hints on healthy renegotiation and retain the five-second fallback.

Test event ordering, repeated and stale notifications, natural recovery, and subscription teardown. Document measured recovery gains and limits.

Fixes VallierDev#27
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-17T05:46:35.866632Z b18a77e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

…he repository

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@VallierDev

Copy link
Copy Markdown
Owner

感谢!实现很克制(只在 GNOME 会话订阅 Mutter MonitorsChanged、全部在锁内、保留 5 秒兜底、无新日志),测量也很清楚。和 #34 一样,我补了一个小提交把 docs/experiments/ 移出仓库(实验/验收记录按约定放在 PR 里,你的描述已完整保留),README 链接改指向本 PR。CI 通过后合并。

Thanks — tight change and clear measurements. As with #34 I pushed a small commit moving docs/experiments/ out of the repository (README now links here). Will merge once CI passes.

@VallierDev
VallierDev merged commit 25edc41 into VallierDev:main Oct 17, 2026
3 checks passed
@VallierDev

Copy link
Copy Markdown
Owner

已合并,感谢!将随下一个版本发布。/ Merged, thanks — ships in the next release.

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.

[Enhancement] 监听显示配置变化以缩短恢复与黑屏时间 / Monitor display changes to reduce recovery delay and black-screen duration

2 participants