antvis/G6

图在快速 addShape/removeShape 的时候出现报错: Uncaught TypeError: Cannot read property 'length' of undefined #5285

HuColin posted onGitHub

G6 Version

4.x

Describe the bug

@antv/G6 4.8.24 同出现这个问题,在自定义节点的 setState 中,在对 group 进行 addShape 的时候 我的操作是(通过 addShape 给自定义节点添加边框)快速 hover 自定义节点来快速重复执行 setState,期间有大量 shape 的创建/销毁行为 之后浏览器爆出Uncaught TypeError: Cannot read property 'length' of undefined 的异常,通过定位发现如下位置抛出异常 <img width="833" alt="image" src="https://github.com/antvis/G6/assets/16102181/485b5077-03f2-40a8-bf6f-858d09f1db29"> 这里 cfg.children 为 undefined,但是仍然调用自身递归,在下一步 for 循环的时候, undefined.length 报错 定位到应该是 g-canvas 库中 clearChanged 函数在 for 循环的时候没有对 children 判断是否为空 <img width="738" alt="image" src="https://github.com/antvis/G6/assets/16102181/929bf3f2-a3a8-459a-894a-ef532199da79">

报错是定位在压缩后的代码 → https://g.alicdn.com/code/lib/antv-g6/4.8.24/g6.min.js:1:127018

在源码中,在递归调用 clearChanged 的时候,是有判断元素是否被销毁,但是构建后的代码里面似乎没有......,这个不确定是什么原因导致的

Your Example Website or App

Steps to Reproduce the Bug or Issue

Expected behavior

在递归调用时需要判断空值

Screenshots or Videos

No response

Platform

  • OS: macOS
  • Browser: Chrome
  • Version: 120

Additional context

No response


hi @HuColin, welcome!

posted by github-actions[bot] over 1 year ago

Hi @HuColin, Please star this repo if you find it useful! Thanks :star:! 你好 @HuColin。如果该仓库对你有用,可以 star 一下,感谢你的 :star:!

posted by github-actions[bot] over 1 year ago

相关 issue https://github.com/antvis/G6/issues/3243 这个 Issue 应该是相同的问题

posted by HuColin over 1 year ago

This issue has been closed because it has been outdate for a long time. Please open a new issue if you still need help.

这个 issue 已经被关闭,因为 它已经过期很久了。 如果你仍然需要帮助,请创建一个新的 issue。

posted by github-actions[bot] 10 months ago

Fund this Issue

$0.00
Funded

Pull requests