Repository navigation
perf(shell): native restart path + UI-thread hygiene (black-frame freezes) - #2
Merged
Merged
Conversation
added 2 commits
September 25, 2026 20:34
…ezes) 重启/黑屏 两个问题的 P0 修复(详细证据见 CHANGELOG v2.0.7): - src-tauri/src/wproc.rs(新增, 裸 Win32 FFI, 零新依赖): GetExtendedTcpTable 取代 netstat spawn(实测单次 311ms 冷/44ms 热), Toolhelp32 快照 + TerminateProcess 树杀取代 taskkill /T /F, OpenProcess(SYNCHRONIZE)+WaitForSingleObject 精确等待被杀 PID 退出, 取代 HTTP 探测(3s 超时)与 netstat 轮询; 固定 settle 1s→250ms, 轮询 300ms→50ms。非 Windows 保留旧 spawn 实现(cfg 回落)。 - src-tauri/src/dsh.rs: port_listener_pid / kill_tree / kill_port_listeners / wait_for_backend_stop 全部重接 wproc; teardown 与清端口把 PID 记入 PENDING_EXIT_PIDS 供精确等待; log_tail 只读文件尾 256KB。 - src-tauri/src/lib.rs: dsh_custom_path / app_full_restart / dsh_exit 移出 UI 线程(同步命令体跑在主线程, 阻塞即窗口黑屏/标题栏透明/ 任务栏预览黑, 与用户反馈吻合); log_tail 改 async + spawn_blocking。 - src-tauri/src/lib.rs: [hangwatch] 独立线程每 2s 探主窗口消息泵 (SendMessageTimeout WM_NULL + GetLastError==ERROR_TIMEOUT 判定), 停转即落日志(含 listeners/可见性), 供偶发问题定位; 窗口获得焦点 与从托盘恢复时强制重组窗口表面(RedrawWindow + SWP_FRAMECHANGED), 1s 冷却。
…ed import (CI 实证) 第一轮 PR 构建(CI)暴露两个问题, 本 commit 修正: 1. error E0599: `WebviewWindow` 没有 `set_outer_size`(仅 `Window` 有; WebviewWindow 未 Deref 到 Window)。tauri 2.11.5 源码核实 `WebviewWindow::set_size` 委托 `Window::set_size` → tao set_size, 其 Windows 语义为外框尺寸, 传 inner_size 会让窗口每次缩一截标题栏, 风险大于收益 —— 黑屏恢复改为纯原生帧重组(RedrawWindow + SetWindowPos(SWP_FRAMECHANGED)), 本就是主机制且零语义歧义。 2. 未用的 import(`Emitter`@lib.rs, `uuid::Uuid`@dsh.rs, `crate::dsh`@update.rs, 均为历史遗留/全限定路径替代), 清理让构建零警告。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景(证据)
dsh.log实测"重启清理→启动尝试"间隔 6~20s; 关键路径上netstat -ano -p tcpspawn 本机实测 311ms 冷/44ms 热,wait_for_backend_stop每 300ms 轮询一次(最坏 8s), HTTP 就绪探测每 400ms 一次且单次最坏 3s 超时, 另有固定 1s settledsh_custom_path(最坏 ~19s)、app_full_restart、log_tail(整读日志且每 2s 轮询)改动
src-tauri/src/wproc.rs(裸 Win32 FFI, 零新依赖, 沿用 memtok.rs 风格并显式#[link]):GetExtendedTcpTable取代 netstat; Toolhelp32 快照 +TerminateProcess树杀取代taskkill /T;OpenProcess(SYNCHRONIZE)+WaitForSingleObject精确等待被杀 PID; 非 Windows 保留旧 spawn 实现作 cfg 回落src-tauri/src/dsh.rs: port_listener_pid / kill_tree / kill_port_listeners / wait_for_backend_stop 重接 wproc; teardown 与清端口把 PID 记入PENDING_EXIT_PIDS供精确等待; 固定 settle 1s→250ms, 兜底轮询 300ms→50ms; log_tail 只读文件尾 256KBsrc-tauri/src/lib.rs:dsh_custom_path/app_full_restart/dsh_exit移出 UI 线程(spawn_blocking);log_tail改 async; 新增[hangwatch]独立线程每 2s 探主窗口消息泵(SendMessageTimeout WM_NULL +GetLastError()==ERROR_TIMEOUT判定), 停转即落日志; 窗口获得焦点/从托盘恢复时强制重组窗口表面(RedrawWindow + SWP_FRAMECHANGED + 同值 bounds 回写, 1s 冷却)验证
dw_size预置/非对齐读