Skip to content

树形table在销毁时页面卡死 #3531

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task done
TaoHuaXia opened this issue Jan 13, 2021 · 14 comments
Closed
1 task done

树形table在销毁时页面卡死 #3531

TaoHuaXia opened this issue Jan 13, 2021 · 14 comments

Comments

@TaoHuaXia
Copy link

TaoHuaXia commented Jan 13, 2021

  • I have searched the issues of this repository and believe that this is not a duplicate.

Version

2.0.0-rc.8

Environment

[email protected] [email protected]

Reproduction link

https://codesandbox.io/s/trusting-leaf-hmrxh?fontsize=14&hidenavigation=1&theme=dark

Steps to reproduce

1.使用树形table展示数据(约1000条左右)
2.对组件进行销毁

What is expected?

可以迅速销毁

What is actually happening?

页面卡死大约10s以上


通过issue可看到类似的https://github.com/vueComponent/ant-design-vue/issues/2508,虽然issue已被关闭,但是感觉没有进行解决(包括查看了后面的合并的代码,也没有解决此问题的提交)

@TaoHuaXia
Copy link
Author

补充:tableData从1000条数据(叶子节点)更新为空数组,也会直接卡死

@TaoHuaXia
Copy link
Author

TaoHuaXia commented Jan 13, 2021

卡顿例子:10 * 10 * 10的数据,重置tableData就会卡死:https://codesandbox.io/s/trusting-leaf-hmrxh?fontsize=14&hidenavigation=1&theme=dark

@TaoHuaXia
Copy link
Author

现在已经在项目中使用,所以望大佬们能给个解决方案

@TaoHuaXia
Copy link
Author

暂时先用了element的table,等修复后再切换回来

@betgar
Copy link

betgar commented Jan 20, 2021

@TaoHuaXia
Copy link
Author

@TaoHuaXia 可以试试这个https://github.com/x-extends/vxe-table

@betgar 感谢老哥,我已经先用element的table顶着了

@eeeqxxtg
Copy link

eeeqxxtg commented Feb 27, 2021

我可能定位到了性能问题:

function setState(partial) {

  function setState(partial) {
    state = { ...state, ...partial };
    for (let i = 0; i < listeners.length; i++) {
      listeners[i]();
    }
  }

1000行的table,每一个row都subscribe了store。

这1000行数据,每一行的变化除了触发自己注册的事件还会同时触发其他999行注册的事件。
极端情况下,性能就被吃掉太多了。

比如卸载这1000行数据,会触发1000+999+998+...1=500500次注册事件。
就算每个注册事件耗时0.02ms,整个卸载过程也会耗时超过10s。

建议这里的store考虑使用vue的响应式设计

@eeeqxxtg
Copy link

eeeqxxtg commented Feb 27, 2021

this.store.setState({ expandedRowKeys });

注释掉这行代码,可以极大提高楼主的卸载速度。

win10 chrome 88.0.4324.182(正式版本) (64 位)

注释之前,卸载楼主的1000条数据,耗时44s
image

注释之后,卸载同样的1000条数据,耗时217ms
image

tangjinzhou added a commit that referenced this issue Feb 27, 2021
@tangjinzhou
Copy link
Member

update to 2.0.1

@cnguu
Copy link

cnguu commented Mar 1, 2021

update to 2.0.1

1.x版本存在同样的销毁性能问题

@betgar
Copy link

betgar commented Mar 1, 2021

希望能够移植回到1.x

@zkwolf
Copy link
Member

zkwolf commented Mar 1, 2021

1.x应该发版到1.7.4了

@AlexZhong22c
Copy link

@zkwolf 老哥,这个bug分配了给你。现在1.x还是有问题的

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants