Skip to content

fix(vdd): fallback display modes after CCD failures#713

Open
qiin2333 wants to merge 3 commits into
masterfrom
codex/vdd-mode-fallback
Open

fix(vdd): fallback display modes after CCD failures#713
qiin2333 wants to merge 3 commits into
masterfrom
codex/vdd-mode-fallback

Conversation

@qiin2333
Copy link
Copy Markdown
Collaborator

@qiin2333 qiin2333 commented Jun 5, 2026

改了啥呀

  • 在 Windows 显示模式应用失败后,给 VDD 目标增加一层专用 fallback。
  • 原目标模式仍然先走现有 set_display_modes() 三段式逻辑;只有目标全是 Zako HDR 且失败时,才进入补强路径。
  • VDD fallback 会先短暂等待 Windows CCD / active path / mode state 稳定后重试目标模式。
  • 目标模式仍失败时,按顺序尝试更稳的模式:同分辨率 120Hz、同分辨率 60Hz,最后 1920x1080@60
  • 物理显示器失败路径保持原行为,不让这个小补丁乱碰正常物理屏,杂鱼 CCD 状态只在 VDD 小房间里挨打。

为啥要改

BlackCat 的日志显示 VDD 已经创建出来,但 2560x1600@144SetDisplayConfig 的 recommended / strict / explicit target 三种方式里都被 Windows 返回 ERROR_GEN_FAILURE / 1610 拒绝。

这类问题很可能是 VDD 刚创建后,Windows 还没稳定暴露目标 mode/source/target 组合,或者高分高刷组合本身不在当前可应用集合里。继续直接 503 会让用户感觉“VDD 创建失败”,但实际更像“目标显示模式还不能用”。

这次改成:先等一下再试,还不行就自动降级到更安全的 VDD 模式,尽量让串流能进;只有 fallback 全失败才保留原来的失败行为。

验证

  • git diff --check
  • cmake --preset dev-win -DPKG_CONFIG_EXECUTABLE=C:/Strawberry/perl/bin/pkg-config.bat 未完成:当前本地工具链缺 libcurl.pc,配置停在依赖发现阶段,还没进入本次 C++ 改动编译。CI 需要继续验证 Windows build。

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 5, 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: 77dccae8-7b87-47ee-9314-376a5fccd8e6

📥 Commits

Reviewing files that changed from the base of the PR and between a0c4e2c and c5a687f.

📒 Files selected for processing (1)
  • src/platform/windows/display_device/settings.cpp
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/platform/windows/display_device/settings.cpp

Summary by CodeRabbit

  • Bug Fixes
    • 优化了 Windows 显示模式应用流程:对虚拟显示设备(VDD)在直接设置分辨率/刷新率失败时引入多次延时重试(250/500/1000ms)并在仍失败时按顺序尝试兼容回退模式(包括在满足阈值时将刷新率降至 120Hz 或 60Hz,以及回退到 1920x1080@60Hz);一旦任一尝试成功即返回成功,显著提高配置成功率。

Walkthrough

在 Windows 显示设备设置路径中为 VDD(ZAKO_NAME)场景添加专用应用策略:直接应用失败时先按延迟重试(250/500/1000ms),仍失败则生成并按序尝试回退候选(降频至120/60或固定1920x1080@60),首次成功即返回。

Changes

VDD 显示模式重试与回退流程

Layer / File(s) Summary
VDD 辅助函数与候选模式生成
src/platform/windows/display_device/settings.cpp
新增标准库包含并在匿名命名空间实现刷新率数值化、display_mode 相等性比较、全部目标是否为 ZAKO_NAME 的检测、device_display_mode_map 等价比较、make_vdd_fallback_modes(生成降至120/60及固定1080p60的候选)和 set_vdd_display_modes_with_fallback(直接应用→延迟重试→候选逐个尝试)。
配置处理流程中的应用替换
src/platform/windows/display_device/settings.cpp
handle_display_mode_configuration 中将对 set_display_modes(new_display_modes) 的调用替换为 set_vdd_display_modes_with_fallback(new_display_modes),启用上述 VDD 专用重试与回退流程。

评估指标

🎯 3 (Moderate) | ⏱️ ~20 minutes

可能关联的 Issue

可能关联的 PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 22.22% 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 标题清晰准确地概括了主要改动:为 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-mode-fallback

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/platform/windows/display_device/settings.cpp

In file included from src/platform/windows/display_device/settings.cpp:10:
src/platform/windows/display_device/settings_topology.h:4:10: fatal error: 'src/display_device/settings.h' file not found
4 | #include "src/display_device/settings.h"
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
src/platform/windows/display_device/settings.cpp:109:7-14: ERROR translating statement 'ReturnStmt'
Aborting translation of method 'display_device::anonymous_namespace_src_platform_windows_display_device_settings.cpp::determine_new_primary_display' in file 'src/platform/windows/display_device/settings.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, charact

... [truncated 2200 characters] ...

ion_log.(fun) in file "src/clang/cTrans.ml", line 4782, characters 12-47
Re-raised at IStdlib__IExn.reraise_after in file "src/istd/IExn.ml" (inlined), line 13, characters 2-50
Called from ClangFrontend__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/cT


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

@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/platform/windows/display_device/settings.cpp`:
- Around line 220-255: The current implementation of with_display_mode and
make_vdd_fallback_modes abuses a single display_mode_t from requested_modes
(std::begin(requested_modes)->second) and then overwrites every entry in
device_display_mode_map_t with that one mode, which incorrectly forces all
devices to the same fallback; instead either (A) change make_vdd_fallback_modes
to produce a device-specific device_display_mode_map_t (i.e., build per-device
candidates from each entry in requested_modes) and stop using a single prototype
mode, or (B) if you intend to keep a single-mode path, assert early in
make_vdd_fallback_modes that all entries in requested_modes are identical (and
fail/return early otherwise) before calling with_display_mode; update callers
(e.g., any set_display_modes usage noted around the other affected block) to
handle per-device fallbacks accordingly. Ensure references: with_display_mode,
make_vdd_fallback_modes, device_display_mode_map_t, requested_modes,
set_display_modes.
🪄 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: b80822e7-ccaf-4495-ae69-5cbf9efdfc7e

📥 Commits

Reviewing files that changed from the base of the PR and between e316020 and 7be57ca.

📒 Files selected for processing (1)
  • src/platform/windows/display_device/settings.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/platform/windows/display_device/settings.cpp
src/platform/**

⚙️ CodeRabbit configuration file

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

Files:

  • src/platform/windows/display_device/settings.cpp

Comment thread src/platform/windows/display_device/settings.cpp Outdated
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/platform/windows/display_device/settings.cpp`:
- Around line 255-277: The current loops that generate fallback candidates skip
modes like 119.88Hz and 59.94Hz because they use strict >121.0 / >61.0 checks;
update the checks in the candidate generation loops (the loops iterating over
candidate_modes and using refresh_rate_hz(mode.refresh_rate)) to include rates
that are close to the integer targets—e.g. treat a mode as a 120Hz candidate
when refresh_rate_hz(...) >= 119.5 (or fabs(refresh_rate_hz(...) - 120.0) <=
0.5) and as a 60Hz candidate when refresh_rate_hz(...) >= 59.5 (or fabs(... -
60.0) <= 0.5), then set mode.refresh_rate = refresh_rate_t { 120, 1 } / { 60, 1
} and call add_candidate(candidate_modes) exactly as before (symbols:
candidate_modes, requested_modes, refresh_rate_hz, refresh_rate_t,
add_candidate).
🪄 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: ed95c6cf-3765-4544-94c5-10cba7e60d53

📥 Commits

Reviewing files that changed from the base of the PR and between 7be57ca and a0c4e2c.

📒 Files selected for processing (1)
  • src/platform/windows/display_device/settings.cpp
📜 Review details
🧰 Additional context used
📓 Path-based instructions (2)
src/**/*.{cpp,c,h}

⚙️ CodeRabbit configuration file

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

Files:

  • src/platform/windows/display_device/settings.cpp
src/platform/**

⚙️ CodeRabbit configuration file

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

Files:

  • src/platform/windows/display_device/settings.cpp
🔇 Additional comments (1)
src/platform/windows/display_device/settings.cpp (1)

219-252: LGTM!

Also applies to: 313-319

Comment thread src/platform/windows/display_device/settings.cpp
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