Conversation
Co-authored-by: TRAE CLI <traecli@bytedance.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.
🤔 这个分支是...
🔗 相关 issue 连接
暂无。
🐞 Bugserver 用例 id
暂无。
💡 问题的背景&解决方案
VRender 已通过
Symbol.for(...)在同一页面的多个 bundle 之间共享 application、legacy binding context 和 shared app,但Generator.auto_increment_id仍是每个 bundle 私有的静态变量。当 bundle A 先初始化 legacy
LayerService、bundle B 随后创建 shared app 时,shared app 的StageFactory可能来自 B,而Stage使用的全局LayerService来自 A。此时 Stage 与 Layer 分别从两个独立计数器取_uid;一旦数值相同,Node.appendChild会把两个不同对象误判为同一节点并返回null,导致 Stage 没有 default layer。上层 VChart 随后在Compiler.initView()调用stage.defaultLayer.appendChild(rootGroup)时抛出:真实 UMD 复现路径:
@visactor/vrenderbundle,并创建一次 Stage,使全局 legacy binding context 持有该 bundle 的LayerService。acquireSharedVRenderApp()创建 shared app。_uid。stage.childrenCount === 0、stage.defaultLayer === null,继续执行 VChart 的 root group 挂载即可得到上述异常。本次把 Generator 计数状态放到
globalThis[Symbol.for('@visactor/vrender-core/generator-state')],与现有跨 bundle runtime 状态的共享方式保持一致。每次生成 ID 仍只执行一次对象属性自增,不增加图形树热路径的遍历或对象分配。新增回归测试覆盖:
_uid,并能正常建立父子关系。📝 Changelog
☑️ 自测
generator.test.ts:5 个测试通过;新增用例已确认在修复前失败。rush run -p @visactor/vrender-core -s compile通过。git diff --check通过。🚀 Summary
copilot:summary
🔍 Walkthrough
copilot:walkthrough