修复扫描稳定性与数据显示异常,恢复多语言切换并修复仪表盘控件重叠#4
Conversation
There was a problem hiding this comment.
Pull request overview
该 PR 聚焦于提升系统扫描/Hook IPC 的稳定性与结果语义(减少连锁 N/A/0ms、降低误判断连),并补回多语言切换能力,同时修复 Dashboard 工具栏控件重叠问题。
Changes:
- 调整 Hook IPC 客户端与 Hook 状态判定逻辑:增加重试/超时策略与“宽限窗口”,降低扫描期间状态抖动与阻塞影响
- 扫描/展示语义优化:新增“仅看已测量”过滤开关,补充“未测量/不支持”等状态与本地化文本
- 注入器与扫描器调整:注入/弹出支持多进程匹配,注册表扫描限制并行度避免 CPU 饱和
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| ContextMenuProfiler.UI/Views/Pages/DashboardPage.xaml | 调整工具栏布局,引入“仅看已测量”开关并避免控件重叠 |
| ContextMenuProfiler.UI/ViewModels/DashboardViewModel.cs | 新增 ShowMeasuredOnly 过滤逻辑并触发重新筛选 |
| ContextMenuProfiler.UI/Core/Services/LocalizationService.cs | 为新增过滤开关补充中英文文案 |
| ContextMenuProfiler.UI/Core/Services/HookService.cs | 增强 Hook 状态判定与宽限窗口,降低误判断连/抖动 |
| ContextMenuProfiler.UI/Core/RegistryScanner.cs | 限制并行度,减少深度扫描时的资源争抢 |
| ContextMenuProfiler.UI/Core/HookIpcClient.cs | 调整 IPC 锁/超时/重试策略与 JSON 提取容错 |
| ContextMenuProfiler.UI/Core/BenchmarkService.cs | 引入不稳定处理器跳过策略、UWP 命名稳定化、未测量/不支持结果语义 |
| ContextMenuProfiler.UI/Converters/LoadTimeToTextConverter.cs | 扩展 N/A 展示条件以匹配新增状态 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| var swRoundTrip = Stopwatch.StartNew(); | ||
| // Format: "CLSID|Path[|DllHint]" | ||
| string requestStr = string.IsNullOrEmpty(dllHint) ? $"{clsid}|{path}" : $"{clsid}|{path}|{dllHint}"; | ||
| byte[] request = Encoding.UTF8.GetBytes(requestStr); | ||
| await client.WriteAsync(request, 0, request.Length); | ||
|
|
There was a problem hiding this comment.
GetHookDataAsync applies a timeout to the read via WaitAsync, but the preceding WriteAsync has no timeout/cancellation. If the server side stops draining the pipe (or the pipe becomes back-pressured), this write can block indefinitely and reintroduce scan stalls. Consider using a single CancellationTokenSource with the round-trip timeout and pass its token to ConnectAsync/WriteAsync/ReadAsync (or wrap WriteAsync with WaitAsync as well) so the whole IPC attempt is time-bounded.
| _consecutiveStatusFailures++; | ||
|
|
||
| if (CurrentStatus == HookStatus.Active && | ||
| _consecutiveStatusFailures < StatusFailureThreshold && | ||
| (DateTime.UtcNow - _lastKnownActiveAtUtc) <= ActiveGraceWindow) |
There was a problem hiding this comment.
GetStatusAsync mutates _consecutiveStatusFailures / _lastKnownActiveAtUtc and CurrentStatus, but it can be invoked concurrently (background polling started in the constructor plus explicit calls from the UI like AutoEnsureHook/ReconnectHook). Without synchronization, concurrent calls can race and produce inconsistent status transitions (e.g., miscounted failures or stale _lastKnownActiveAtUtc). Consider serializing GetStatusAsync with a private SemaphoreSlim/lock so only one status evaluation runs at a time.
| status.Contains("Not Measured", StringComparison.OrdinalIgnoreCase) || | ||
| status.Contains("Unsupported", StringComparison.OrdinalIgnoreCase) || | ||
| status.Contains("No Menu", StringComparison.OrdinalIgnoreCase); |
There was a problem hiding this comment.
BenchmarkService can now set Status = "Skipped (Known Unstable)" with TotalTime = 0, but ShouldShowNa doesn’t treat "Skipped" as a non-measured outcome. This will display "0 ms" for skipped entries, reintroducing the misleading 0ms case the PR is trying to eliminate. Consider updating ShouldShowNa to return true for skipped entries (e.g., status.Contains("Skipped", ...)) and align the indentation of the added conditions with the surrounding lines.
| status.Contains("Not Measured", StringComparison.OrdinalIgnoreCase) || | |
| status.Contains("Unsupported", StringComparison.OrdinalIgnoreCase) || | |
| status.Contains("No Menu", StringComparison.OrdinalIgnoreCase); | |
| status.Contains("Not Measured", StringComparison.OrdinalIgnoreCase) || | |
| status.Contains("Unsupported", StringComparison.OrdinalIgnoreCase) || | |
| status.Contains("No Menu", StringComparison.OrdinalIgnoreCase) || | |
| status.Contains("Skipped", StringComparison.OrdinalIgnoreCase); |
修复 #3
变更概述
本 PR 主要解决扫描过程中卡顿、批量 N/A/0ms、Hook 状态误判等问题;同时恢复从 main 分支丢失的多语言/语言切换功能,并修复仪表盘工具栏控件重叠。
具体修改
验证结果
手工验证:
备注
本分支已先与上游 main 同步并在本地解决冲突后提交。