Skip to content

fix: negative splice start corrupts scene order; deleted entries unmount last - #9

Draft
sskyy wants to merge 3 commits into
mainfrom
cursor/fix-splice-and-unmount-priority-9665
Draft

fix: negative splice start corrupts scene order; deleted entries unmount last#9
sskyy wants to merge 3 commits into
mainfrom
cursor/fix-splice-and-unmount-priority-9665

Conversation

@sskyy

@sskyy sskyy commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

深度 review 中发现并实测复现的两个 bug,均已修复并附回归测试;另含 0.1.0 首次发布的版本准备。

1. RxListHost.handleSplice:负数 splice 索引静默破坏场景图顺序

data0 的 RxList.splice原始 argv(含负数 / 越界 start,Array.prototype.splice 语义)透传给 patch。hosts.splice 本身按原生语义处理没问题,但 findAnchor(start + deleteCount) 用的是未规范化的 start:

  • items.splice(-1, 1, 9)(数据 [1,2,3] → [1,2,9])会把锚点算到 findAnchor(0),新行被插到列表头,场景图变成 [9,1,2]
  • 更糟的是 hosts 簿记数组(原生负索引语义)与场景图从此不一致,后续所有 patch 的锚点都会错位

修复:在锚点计算前按原生语义规范化 start(负数从尾部折算、越界 clamp 到 [0, hosts.length])。

2. RxWindowedList:已从索引删除的条目最后才卸载(与注释/文档意图相反)

distanceTo 对已删除条目返回 -1,注释写的是「排到队首」;但卸载队列按 b.distance - a.distance 降序消化(最远优先),-1 是最小值,实际被排到队尾。预算紧张时(正是分帧卸载机制存在的场景),数据层已不存在的幽灵卡反而在画布上停留最久。

修复:deleted 返回 Infinity。挂载/替换队列按升序消化,deleted 排到队尾且出队时会被 buildMountRow 的存在性校验过滤,不受影响。

3. 0.1.0 发布准备

  • 版本号 0.0.0 → 0.1.0package.json + AXLE_VERSION),版本一致性测试改为从 package.json 读取而不是硬编码;
  • 补充 publishConfig.access: public(scoped 包首次发布必需)与 repository 元数据。

注意:npm publish 目前被 @axiijs scope 在 npm 上不存在404 Scope not found)阻塞,需要先在 npmjs.com 上创建 axiijs organization(token 用户 sskyy 认证正常)。

测试

  • 新增 3 个回归用例(负数/越界 splice × 2、deleted 卸载优先级 × 1),已验证在未修复的代码上会失败;
  • npm run check(typecheck + lint + 全部 247 个测试 + build)全部通过。
Open in Web Open in Cursor 

cursoragent and others added 3 commits July 9, 2026 03:19
…anchor lookup

data0 passes raw splice argv through to the patch. A negative start
(Array.prototype.splice semantics, e.g. splice(-1, 1, x)) made
findAnchor compute the anchor from the wrong index, silently inserting
new rows at the head of the list and diverging scene order from data
(and from the hosts bookkeeping, corrupting all subsequent patches).

Co-authored-by: Zhenyu Hou <skyking_H@hotmail.com>
distanceTo returned -1 for entries deleted from the spatial index, but
the unmount queue drains in descending distance order, so deleted
(ghost) entries were unmounted last under budget pressure — the
opposite of the documented intent. Return Infinity instead; mount and
replace queues are unaffected (deleted entries are filtered by
buildMountRow existence checks).

Co-authored-by: Zhenyu Hou <skyking_H@hotmail.com>
Bump version to 0.1.0 for the first npm publish, add publishConfig
(public access for the scoped package) and repository metadata, and
make the AXLE_VERSION test read the version from package.json instead
of hardcoding it.

Co-authored-by: Zhenyu Hou <skyking_H@hotmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants