Files
mnote/design/05-editor-mainline/reference/5-36-tiptap-real-shell-cold-load-followup-v1.md
T

73 lines
4.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 5-36 Tiptap real shell cold-load follow-up v1
> 创建时间:2026-06-06
>
> 状态:`reference`
>
> Owner05-editor-mainline / leptos-tiptap island / mnote-web document shell
>
> 来源:`design/05-editor-mainline/done/5-13-tiptap-runtime-cold-load-mindmap-split-checklist-v1.md`
>
> 2026-06-06 复核结论:当前 checkout 未复现 18 秒冷加载。临时真实浏览器复测打开 `design/07-ai/done/7-45-chatonly-api-provider-runtime-v1.md`,结果为 `domContentLoadedMs=102`、`editorVisibleMs=271`、`tableVisibleMs=274`、`mindmapRuntimeRequested=false`、1 个约 97ms longtask;截图和结果见 `tmp/tmp-7-45-current-cold-open-check/`。因此本文件不再作为 active process,只保留为性能问题复现时的参考 checklist。
## 1. 背景
`5-13` 已确认普通 paragraph runtime 不再捆绑 mindmap/simple-mind-map 重包:`tiptap_paragraph.js` 从约 1,025,978 bytes 降到约 7,619 bytes,普通 7-45 页面不再请求 `tiptap_mindmap_paragraph_runtime.js`
历史记录中,真实文档壳打开 `design/07-ai/done/7-45-chatonly-api-provider-runtime-v1.md` 曾观测到 `editorVisibleMs/tableVisibleMs≈18.55s`;同源空页面单独 `import + init + mount` 同一份 Tiptap document 约 166ms。2026-06-06 当前 checkout 复核未复现该问题,表格约 274ms 可见。因此本文件只作为“若再次复现 18 秒冷加载时如何取证”的参考,不应直接派发实现任务。
## 2. 目标
- 建立可重复的冷浏览器性能 smoke,记录 editor visible、table visible、runtime asset waterfall 和主线程长任务。
- 区分 Tiptap document render、wasm-bindgen snippets import、document shell bootstrap、sidebar/page settings/Page AI 初始化之间的耗时。
- 给普通 Markdown 文档首屏设定可执行预算,先以 `tableVisibleMs < 3s` 作为 P0 目标。
- 保持 `5-13` 的 mindmap 懒加载成果,不重新把 mindmap runtime 放回普通 paragraph 主包。
## 3. 非目标
- 不改 FileTree view-state / lazy reveal;该问题已由 `4-25` 归档。
- 不在本轮实现完整 mindmap plugin host;正文内 mindmap 长期形态另拆 Resource/Object tab 或 plugin host checklist。
- 不通过新增轮询、定时刷新或隐藏首屏内容来掩盖加载问题。
## 4. 复现时 Checklist
### Phase ARED smoke 与证据
- [ ] 新增或复用冷浏览器 smoke,固定打开 7-45 或等价大 Markdown 文档。
- [ ] 记录 `domContentLoadedMs``editorVisibleMs``tableVisibleMs`、wasm snippets 请求开始/结束、Tiptap island mount 开始/结束。
- [ ] 截取 Performance trace 或至少记录 `PerformanceObserver longtask` 摘要。
- [ ] 断言普通 Markdown 页面不请求 `tiptap_mindmap_paragraph_runtime.js`
验收:
- [ ] smoke 在当前基线下能稳定复现 `tableVisibleMs` 远高于同源空页面 import。
- [ ] 结果 JSON 写入 `tmp/`,包含网络、longtask 和 runtime 阶段字段。
### Phase B:根因切分
- [ ] 对比真实 document shell 与同源空页面 import 的 module graph。
- [ ] 关掉非必要首屏 surface 的实验开关做只读对照:Page AI drawer、page settings、resource tab prewarm、sidebar secondary pane。
- [ ] 检查是否存在 modulepreload 缺失、重复 import、deferred script 排队或 wasm-bindgen init 被其他任务阻塞。
- [ ] 确认 `document-editor-adapter-runtime.js` 中 runtime prewarm 的 `setTimeout` 不影响首屏关键路径。
验收:
- [ ] 给出一个可被代码改动验证的根因假设,例如具体 runtime asset、init 阶段或主线程长任务来源。
### Phase C:小范围修复
- [ ] 只修改根因对应模块,不做编辑器大重构。
- [ ] 如果需要预加载,只用明确 asset hint 或模块加载顺序调整,不新增周期任务。
- [ ] 如果需要推迟非关键 surface 初始化,必须保持功能入口可用并补 smoke。
验收:
- [ ] 冷浏览器 smoke 达到 `tableVisibleMs < 3s`,或至少给出明确的剩余瓶颈和下一轮预算。
- [ ] `5-13` 的 mindmap 懒加载断言继续通过。
## 5. 重新激活条件
- 用户或 smoke 再次稳定复现 `tableVisibleMs > 3s`
- 复现结果包含真实浏览器 result JSON、截图、runtime asset waterfall 和 longtask 摘要。
- 确认不是冷编译、服务刚启动、临时网络/磁盘抖动或非当前 checkout 造成。