Project: Eclipse_Platform_UI
Bug 292212 [Viewers] Performance issue in doing a TreeViewer.refresh() on a node in expanded state and containing thousands of children
Reported: 2009-10-14 02:17:22 | Status: resolved fixed

User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; InfoPath.2; MS-RTC LM 8; .NET CLR 1.0.3705; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022) Build Identifier: I20090611-1540 On expanding a node in the TreeViewer, the control comes to getChildren() call on the content provider. In cases where we need to make server calls to get the children and so as not to block the UI thread, we spawn a job and return a dummy object. Once the job completes, so as to update the node with the children, if we do a refresh on the treeviewer for the object being expanded, it takes considerable amount of time to render the children and this increases exponentially as the number of children increases. Additional documentation is provided in the .doc file attached this bug report and a sample application containing the code is attached as well. Reproducible: Always Steps to Reproduce: 1. Create a view part with a custom content and label providers 2. In the content-provider's getChildren() method, spawn off a job to load the children for the parent-object and return a dummy object (say "Loading...") so that the UI displays it at the time of expansion 3. In the job, construct the children (say 5000) and once done, fire a TreeViewer.refresh(..) on the parent-object in the ui-thread 4. You would notice that this takes a considerable amount of time to show the children.

Files changed in fix:
bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/AbstractTreeViewer.java