Repository navigation
fix(history): 旧版会话迁移按字节预算分页,避免 WebView 内存溢出 - #1137
Merged
Merged
Conversation
旧版会话迁移每页固定导出 20 个会话,连同全部 segment 的 messages_json 和 checkpoint 文件一次性经 IPC 发给 WebView, WebView 内还会再复制几份(解析、转换、导入请求体)。历史中 有大会话或内嵌图片时,一页就让渲染进程 Out of Memory, 重启后从同一页重试,始终卡在「正在读取旧数据」。 导出改为每页最多约 8 MB 会话数据(仍最多 20 个),超出时 把当前会话留到下一页;单个超出预算的会话独占一页。 Closes #1136
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.
Closes #1136
现象:从 1.x 升级到 2.0.2 后,启动页停在「正在迁移旧版会话 · 正在读取旧数据」,随后 WebView 报
Out of Memory,重启后依旧。原因:
legacy_history_migration_page每页固定导出 20 个会话,连同每个会话全部 segment 的messages_json和 checkpoint 文件(base64)一次性经 IPC 发给 WebView。WebView 里还会再复制几份(解析 IPC 结果、canonicalMessagesForMigration转换、fingerprint序列化、导入请求体里的source_metadata.original和segments[].messages_json)。历史里有长会话或内嵌图片时,一页的数据就能让渲染进程内存溢出;重启后又从同一页开始,所以始终失败。改动(只改 Rust 导出端,前端与 K-brain 导入协议不变)
complete改为:没有因预算提前截断且本次查询不足 20 行。测试
page_stops_at_byte_budget_and_resumes_after_last_exported_conversation:小预算下逐页导出、游标连续、超大会话独占一页、最终complete;默认预算下小会话仍合并在一页。cargo test -p liveagent --lib migration:12 passed。已知限制:单个会话本身就有几百 MB 时,它独占的那一页仍可能超出 WebView 内存,要进一步拆小需要改前端导入流程和 K-brain 导入协议,这次没有做。