Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/display_device/session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,17 @@ namespace display_device {
// 初始化会话事件监听器(用于检测解锁事件)
SessionEventListener::init();

session_t::get().restore_state();
// 延迟恢复显示设置,避免在系统启动期间与显示子系统初始化互相阻塞
auto &session = session_t::get();
{
std::lock_guard lock { session.mutex };
session.timer->setup_timer([&session]() {
BOOST_LOG(info) << "尝试恢复显示设置...";
session.restore_state_impl();
return true; // 单次执行
});
Comment on lines +153 to +161
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

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

这里复用 session_t 的 StateRetryTimer 做启动延迟恢复会被后续的 timer->setup_timer(...) 覆盖/取消(例如 configure_display 在成功路径会调用 timer->setup_timer(nullptr)),导致启动时的 crash recovery 可能根本不执行。更严重的是:如果旧的 persistent file 还没被 restore/revert 清理掉,就先进入 apply_config,有可能覆盖掉旧持久化数据,从而丢失“原始显示拓扑”信息。建议把“启动恢复”从共享 retry timer 中解耦(独立的一次性延迟任务/线程,或在第一次 configure_display 前强制完成一次恢复/至少加载并清理旧持久化文件),以保证恢复逻辑必定发生且不会与后续重试定时器互相踩踏。

Copilot uses AI. Check for mistakes.
}

return std::make_unique<deinit_t>();
}

Expand Down