Angular-tree-component: low performance

Created on 21 Jul 2017  路  13Comments  路  Source: CirclonGroup/angular-tree-component

Hi,
Found some performance issue when element is dragging.
FPS is slow down to 6
https://gfycat.com/ScentedExcellentBengaltiger
use
"angular-tree-component": "3.8.0"
"@ angular/core": "4.2.5"

Most helpful comment

You have to intercept dragStart and dragEnd using ITreeOptions:

let treeOptions: ITreeOptions = {
        actionMapping: {
            mouse: {
                dragStart: () => { this.cd.detach(); },
                dragEnd: () => { this.cd.reattach(); },
            }
        }
    };

where this.cd is the ChangeDetectorRef injected in the constructor:

protected cd: ChangeDetectorRef,

All 13 comments

You should try to use virtualscroll and check performance with AOT (prod mode enabled)

I've tried. Looks little bit better but fps drops from 60 to 28 (in angular prod build with virtualscroll in chrome with closed devtools)
I thinks your component has some bottleneck logic. In my case it may has some freezing in canvas drawing

302 #268 #352

upd:
on my personal PC same perfomance as above (5-10 fps with prod build)

Very strange, do you feel that also in the demo example?
Have you tried using enableProdMode()?

Now I do tried prod with aot
And have incredeable 60fps all time
But I am confused why in dev env I still have 4-5 fps. I created minimal project with bare your tree-node-component without any customization. And I have same problem
link Can you investigate this problem?
dragging another component with unfolded nodes 4-5fps
dragging treenode parent component with unfolded nodes 4-5fps
dragging any component with folded nodes 59-60fps

Not sure I understand the videos. What are those windows you are dragging? Is it a component inside an app? Is it inside a browser?

it's look like this:
document
-> dragable container
----> tree component
-> dragable container
----> pixijs component

I have a similar problem. It seems that depends more on the complexity of the DOM in which the treeview reside than the numbers of treeview items.

I found a workaround by detaching the change detection of the parent component during drag/drop.
This is possible using dragStart/dragEnd actionMapping.

I have problems with really bad performance when drag-and-dropping nodes in a tree with 150-200 nodes. It's a shallow tree, maybe two-three sub levels on a handful of nodes.

@GianlucaMaggio could you supply some code to show how you did to avoid change detection? Thanks!

You have to intercept dragStart and dragEnd using ITreeOptions:

let treeOptions: ITreeOptions = {
        actionMapping: {
            mouse: {
                dragStart: () => { this.cd.detach(); },
                dragEnd: () => { this.cd.reattach(); },
            }
        }
    };

where this.cd is the ChangeDetectorRef injected in the constructor:

protected cd: ChangeDetectorRef,

Ah, very nice. I'll try it out.

Thanks!

@GianlucaMaggio , Great! the performance issue sounds gone after your changes are made.

Updated the docs with a hint. Closing this issue. Please open a new issue if the problem still exists.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chpasha picture chpasha  路  5Comments

JanSchuermannPH picture JanSchuermannPH  路  4Comments

CC84 picture CC84  路  4Comments

Shadowlauch picture Shadowlauch  路  5Comments

anoop-chauhan picture anoop-chauhan  路  3Comments