Perf/image hot path and fixes - #697
Merged
Merged
Conversation
- CustomRBush 增加 queueUpdate/_flushPendingUpdates:图形坐标高频变化时 不再逐条 remove/insert 空间索引,延迟到下一次查询前统一应用; 大批量变更(平移/缩放后)走 clear+load 整树重建。 同一图形在一个查询周期内的多次变更自动合并为一次索引操作, 并顺带修复索引包围盒与子类 bbox(含 padding)不一致的问题 - Shape 增加 batchUpdate API,坐标 Proxy 按点对象身份缓存(WeakMap), 消除渲染热路径上每次索引访问新建 Proxy 的 GC 压力 - Draft.moveByDistance 改用 batchUpdate 批量写入坐标: 整体拖拽 N 点多边形从每次 mousemove 触发 2N 次全量更新(O(N²)) 降为一次。实测拖动 200 点多边形(同屏 500 标注) 从 196ms/mousemove 降至 7.2ms,约 27 倍 - Monitor 在拖拽平移画布期间跳过悬浮命中检测 - 修复 Axis 销毁时 KeyUp 事件解绑遗漏导致的实例泄漏 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- AsideAttributeItem 分组删除的权限判断条件写反(可编辑时反而 return), 与单条删除逻辑对齐为 !requestEditable() - Toolbar 未解构 extra prop,公开 API toolbarExtra 传入后被静默丢弃 - useImageAnnotator 将引擎创建/销毁移出 setState updater: updater 必须是纯函数,React 18 StrictMode 双调用会泄漏引擎实例; 同时依赖数组去掉原始 options 引用,避免内联传入 options 时 每次渲染都销毁重建整个 canvas 引擎 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Tooltip 组件此前在每个实例内部渲染 <GlobalStyle />(createGlobalStyle), 而 createGlobalStyle 会为每个挂载的实例把全部规则重新插入样式表。 标注页面上每个标签、每条标注项都有 Tooltip(EllipsisText 内嵌), 50 个类别 + 30 条标注即产生约 150 个实例、近 4000 次样式表 DOM 插入, 且插入位置索引随规则总数线性增长,总成本呈 O(实例数²) 放大。 实测(50 类别 / 30 标注,React dev 模式): - 进入标注页主线程阻塞:8.9s → 122ms - 更换已标注选框类别:260ms → 26ms - 样式表 DOM 操作:3999 插入 + 840 删除 → 375 插入 修复方式:首个 Tooltip 渲染时将 GlobalStyle 挂到常驻的独立 React root 上, 整个页面生命周期只注入一次,与 Tooltip 实例的挂载/卸载解耦。 DraggableModal 的 GlobalStyle 复用同一 element 引用避免重渲染时重复注入。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
No description provided.