Skip to content

fix(vdd): harden restore capture startup#707

Merged
qiin2333 merged 2 commits into
masterfrom
codex/vdd-restore-capture-robustness
Jun 4, 2026
Merged

fix(vdd): harden restore capture startup#707
qiin2333 merged 2 commits into
masterfrom
codex/vdd-restore-capture-robustness

Conversation

@qiin2333
Copy link
Copy Markdown
Collaborator

@qiin2333 qiin2333 commented Jun 3, 2026

改了啥呀

  • VDD direct capture 会先把 HardwareCursor 关掉;这次把成功关闭后的状态同步写回 vdd_settings.xml,避免恢复串流时反复误判、反复让驱动 reload。
  • VDD shared-texture capture 不再接受尺寸不匹配的唯一 producer 作为 fallback。现在会短暂等待 producer metadata 精确匹配目标模式,超时后拒绝 stale producer,避免 3168x1440 编码目标接到 3440x1440 producer 后陷入黑屏/reinit 循环。

为啥要改

日志里恢复串流前 VDD 还在,但 HardwareCursor false 又触发了一次驱动 reload,VDD monitor 随后掉线并被重建。改编码格式后黑屏那段也显示会话/编码器目标是 3168x1440,但 VDD producer 仍发布 3440x1440,旧逻辑 fallback 到这个 stale producer 后一直 reinit。杂鱼状态别再冒充可用了喂。

验证

  • git diff --check -- src/display_device/vdd_utils.cpp src/platform/windows/display_vdd.cpp
  • 尝试运行 cmake --build build --target sunshine,但当前本地 MSYS2 toolchain 阻塞:C:\msys64\ucrt64\bin\c++.exe 连空的单文件编译也无诊断返回 1,因此完整构建未能在本机完成。

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 3, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7f0f765e-4976-4658-8f62-196e8e1bb245

📥 Commits

Reviewing files that changed from the base of the PR and between e073679 and e077795.

📒 Files selected for processing (1)
  • src/display_device/vdd_utils.cpp
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/display_device/vdd_utils.cpp
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Windows

Summary by CodeRabbit

发布说明

  • Bug Fixes

    • 硬件光标配置设置现已正确保存并持久化
    • 显示设备检测逻辑优化,减少设备初始化异常导致的显示问题
  • Improvements

    • 增强显示设备匹配精度,引入重试机制提升可靠性

Walkthrough

本PR在VDD设备初始化中引入两项改动:为硬件光标设置新增 XML 持久化函数并在禁用流程中集成重试持久化;重构 Windows 端监视器索引探测以仅在探测到精确分辨率匹配时返回索引,并改进诊断日志。

变更

VDD硬件光标持久化

层 / 文件 总结
光标状态持久化实现与集成
src/display_device/vdd_utils.cpp
新增 persist_hardware_cursor_setting(bool enabled) 函数读取并更新 vdd_settings.xml 中的 vdd_settings.cursor.HardwareCursor 字段;在成功禁用硬件光标后调用该函数并在失败时按指数退避重试;新增 #include <locale>

VDD监视器索引精确匹配探测

层 / 文件 总结
探测结果结构与索引解析重写
src/platform/windows/display_vdd.cpp
新增 vdd_probe_result_t 用于记录精确匹配、有效生产者计数及唯一生产者信息;probe_vdd_monitor_index 填充该结果并记录 debug;resolve_vdd_monitor_index 重写为带截止时间的重试探测,仅在发现精确分辨率匹配时返回索引,超时则根据探测到的有效生产者数量产生日志并返回 -1

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed 标题清晰准确地总结了 PR 的主要变更:针对 VDD 恢复捕获启动的硬化(持久化光标设置和生产者验证)。
Description check ✅ Passed 描述详细阐述了两项核心改动(硬件光标持久化和生产者尺寸验证)、动机(避免误判和黑屏循环)及验证方法,与变更集完全相关。
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/vdd-restore-capture-robustness

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Infer (1.2.0)
src/display_device/vdd_utils.cpp

In file included from src/display_device/vdd_utils.cpp:3:
src/display_device/vdd_utils.h:11:10: fatal error: 'windows.h' file not found
11 | #include <windows.h>
| ^~~~~~~~~~~
1 error generated.
src/display_device/vdd_utils.cpp:78:7-44: ERROR translating statement 'ReturnStmt'
Aborting translation of method 'display_device::vdd_utils::calculate_exponential_backoff' in file 'src/display_device/vdd_utils.cpp': "Assert_failure src/clang/cAst_utils.ml:249:53"
Uncaught Internal Error: "Assert_failure src/clang/cAst_utils.ml:249:53"
Error backtrace:
Raised at ClangFrontend__CAst_utils.get_decl_from_typ_ptr in file "src/clang/cAst_utils.ml", line 249, characters 53-65
Called from ClangFrontend__CTrans.CTrans_funct.get_destructor_decl_ref in file "src/clang/cTrans.ml", line 658, characters 12-59
Called from ClangFrontend__CTrans.CTrans_funct.destructor_calls.(fun) in file "src/clang/cTrans.ml", line 2048, characters 12-69
Called from Base__List.rev_filter_map.loop in file "sr

... [truncated 2200 characters] ...

gFrontend__CTrans.CTrans_funct.instruction_log.(fun) in file "src/clang/cTrans.ml", line 4784, characters 10-1023
Called from ClangFrontend__CTrans.CTrans_funct.instruction in file "src/clang/cTrans.ml" (inlined), line 4765, characters 38-71
Called from ClangFrontend__CTrans.CTrans_funct.exec_with_node_creation in file "src/clang/cTrans.ml" (inlined), line 104, characters 20-38
Called from ClangFrontend__CTrans.CTrans_funct.get_clang_stmt_trans in file "src/clang/cTrans.ml" (inlined), line 5395, characters 4-69
Called from ClangFrontend__CTrans.CTrans_funct.get_custom_stmt_trans in file "src/clang/cTrans.ml", line 5401, characters 8-55
Called from ClangFrontend__CTrans.CTrans_funct.exec_trans_instrs.exec_trans_instrs_rev in file "src/clang/cTrans.ml" (inlined), line 5365, characters 28-54


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Collaborator Author

qiin2333 commented Jun 3, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 3, 2026

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/display_device/vdd_utils.cpp`:
- Line 356: The call to persist_hardware_cursor_setting(false) ignores its
return value so disk-write failures are treated as success; modify the caller to
check the function's boolean/errno-style result from
persist_hardware_cursor_setting and handle failures: if it fails, log an error
(including the failure code/message), abort or return an error status from the
current function instead of continuing, and/or perform a retry/backoff path so
the "persist" step cannot silently fail and lead to repeated mis-detection on
restart; update the enclosing function to propagate the failure to callers (or
trigger a safe fallback) so the system does not assume the setting was persisted
when it wasn't.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3832d18c-d26a-47e1-b2fc-8b0e31d645d9

📥 Commits

Reviewing files that changed from the base of the PR and between c71a4a3 and e073679.

📒 Files selected for processing (2)
  • src/display_device/vdd_utils.cpp
  • src/platform/windows/display_vdd.cpp
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Windows
🧰 Additional context used
📓 Path-based instructions (2)
src/**/*.{cpp,c,h}

⚙️ CodeRabbit configuration file

src/**/*.{cpp,c,h}: Sunshine 核心 C++ 源码,自托管游戏串流服务器。审查要点:内存安全、 线程安全、RAII 资源管理、安全漏洞。注意预处理宏控制的平台相关代码。

Files:

  • src/display_device/vdd_utils.cpp
  • src/platform/windows/display_vdd.cpp
src/platform/**

⚙️ CodeRabbit configuration file

src/platform/**: 平台抽象层代码(Windows/Linux/macOS)。确保各平台实现一致, 注意 Windows API 调用的错误处理和资源释放。

Files:

  • src/platform/windows/display_vdd.cpp
🔇 Additional comments (5)
src/display_device/vdd_utils.cpp (1)

20-20: LGTM!

Also applies to: 299-319, 1019-1019

src/platform/windows/display_vdd.cpp (4)

269-275: LGTM!


277-312: LGTM!


326-359: LGTM!


320-321: 💤 Low value

确认 2500ms / 100ms 的字面量运算符在 platf::dxgi 作用域内可见src/platform/windows/display_vdd.cppnamespace platf { using namespace std::literals; } 在第 28-30 行,resolve_vdd_monitor_indexnamespace platf::dxgi 内第 32 行起)。std::literals 本身覆盖 chrono UDL,因此无需额外 std::chrono_literals 或担心该作用域不可达。

Comment thread src/display_device/vdd_utils.cpp Outdated
Copy link
Copy Markdown
Collaborator Author

qiin2333 commented Jun 3, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 3, 2026

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@qiin2333 qiin2333 marked this pull request as ready for review June 4, 2026 01:35
@qiin2333 qiin2333 merged commit f626db2 into master Jun 4, 2026
6 of 7 checks passed
@qiin2333 qiin2333 deleted the codex/vdd-restore-capture-robustness branch June 4, 2026 01:45
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.

1 participant