🟡 [M16] TUI 渲染无 MAX_WRAP_INPUT_LEN 保护,巨大单行可冻结 UI #26
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
文件:
tui/app.rs:196-207分类: 渲染 / 性能
问题: Core 的 visual-height 计算有
MAX_WRAP_INPUT_LEN保护,但 TUI viewport 渲染直接对完整行内容调用wrap_line_chars,巨大单行可冻结 UI。建议修复: TUI 侧也应用
MAX_WRAP_INPUT_LEN保护,超大行截断或作为一行显示。修复方案
根因分析
compute_line_entry和compute_visual_height在渲染路径中直接调用wrap_line_chars,未检查输入长度。当单行日志超过 10MB 时,逐字符遍历和 Vec 构建会冻结主线程。此外
detect_level在超长 JSON 上也会触发 O(n) 解析,以及format_json_line可能将 <10MB 的原始 JSON 展开为 >10MB 的 pretty-print 输出。修复内容 (
e99861c)三层防护:
raw.len() > MAX_WRAP_INPUT_LEN时跳过detect_level和 JSON 格式化,直接返回截断预览display_text.len() > MAX_WRAP_INPUT_LENcompute_line_visual_height增加 post-format guard改动文件:
crates/tui/src/app.rs— 双层 guard + truncate_to_columnscrates/core/src/io/progressive_reader.rs— post-format guardcrates/core/src/io/wrap.rs— 修正 docstring测试:6 个新测试,全部 358 测试通过。