Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 327214 - UI not responding after TreeViewer refresh
Summary: UI not responding after TreeViewer refresh
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform UI Triaged CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on: 259141
Blocks:
  Show dependency tree
 
Reported: 2010-10-07 07:48 EDT by ralf.boehringer CLA
Modified: 2020-03-20 12:10 EDT (History)
9 users (show)

See Also:


Attachments
Snippet to demonstrate problem after refreshing tree (4.71 KB, application/octet-stream)
2012-02-16 18:18 EST, Steven Darnell CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description ralf.boehringer CLA 2010-10-07 07:48:39 EDT
Build Identifier: 3.5.1

I´m using a tree table with style SWT.VIRTUAL|SWT.MULTI|SWT.FULL_SELECTION with a LazyTreeContentProvider. The Tree contains about 50000 rows. Our application constantly adds and removes rows, which makes a refresh of the tree neccessary. Refreshing the tree together with a simultaneous user interaction like scrolling or page down or row selection makes the UI freeze.
I already tried refreshing via: display.(a)syncExec or encapsulated by a Job or UIJob without success. 
The error seems to happen deep inside SWT´s eventhandling. HandleEvent-methods of the tree are not called.

Reproducible: Always

Steps to Reproduce:
1.Create TreeViewer SWT.VIRTUAL|SWT.MULTI|SWT.FULL_SELECTION 
2.Create LazyTreeContentProvider
3.Create initial list (java.util.List) and set it as input
4.Add about 3 new rows per second to the tree and refresh the tree
5.Make simultaneous user interactions like scrolling or page up/down
Comment 1 Kay Kasemir CLA 2011-07-07 20:43:41 EDT
For what it's worth, this seems related to bugs 289848 and 259141.

It can be reproduced under Eclipse 3.6.2 using the snippet http://wiki.eclipse.org/JFaceSnippets#Snippet047VirtualLazyTreeViewer  

by just adding SWT.MULTI to the table flags.

Without SWT.MULTI (i.e. SWT.SINGLE) it's fast, but with SWT.MULTI it is slow because the mechanism to preserve the multi-element selection is slow.
Comment 2 Steven Darnell CLA 2012-02-16 18:18:26 EST
Created attachment 211148 [details]
Snippet to demonstrate problem after refreshing tree

This code snippet demonstrates that the tree refresh code is not directly responsible for the code; it executes quickly when you step through the code. Use of SWT.MULTI is not the cause of the problem. Note that the use of SWT.SINGLE for the CheckboxTree also shows the performance hit.

It seems that the best diagnosis of the root problem is detailed in Bug 310260 (closed as duplicate of Bug 259141).

@Felipe how do we move forward from here.
Comment 3 Carolyn MacLeod CLA 2012-10-16 16:40:58 EDT
Note that we just made a change in this area that may help. Please see bug 259141 comment 20 for details.
Comment 4 Steven Darnell CLA 2012-10-22 23:03:48 EDT
I do not see a change in behavior when using Attachment 211148 [details] with swt-N20121022-1000-win32-win32-x86 (Windows 7 x64, Java 6u37 x86, SWT 32-bit). The initial tree drawings take ~8 sec and the refreshes take even longer.
Comment 5 Carolyn MacLeod CLA 2012-10-23 12:51:45 EDT
Reassigning this bug to JFace.

SWT does not have a call to get the checked state of all items in a Tree - only  of one TreeItem at a time.

I see that there is a method in JFace's CheckboxTreeViewer called gatherState(CustomHashtable checked, CustomHashtable grayed, Widget widget),
which goes through every single TreeItem in the entire Tree (virtual or not) in order to collect up the checked state of every possible item in the Tree.
This ends up calling CheckboxTreeViewer.updateElement(Object parent, int index) for every item. This should not be done for a virtual Tree. Only items that are visible (i.e. root items or items in expanded branches) need to have their check state updated.
Comment 6 Carolyn MacLeod CLA 2012-11-01 11:17:53 EDT
> Only items that are visible (i.e. root items or items in expanded branches)
> need to have their check state updated.

Actually, does JFace enforce a tri-state (i.e. "checked/unchecked/grayed") on a parent item if some of the child items are checked?
If so, then the fix for this is easy:
- if an item is grayed, then you need to go through its children and look at their state.
- if an item is checked, then you do not need to go through its children because all of them are guaranteed to be checked.
- if an item is neither checked nor grayed, then you do not need to go through its children because all of them are guaranteed to be unchecked.

So enforcing tri-state would save a lot of recursion. (and it is, I believe, the way that most (all?) checkbox-tree UIs work).
Comment 7 Eclipse Genie CLA 2020-03-20 12:10:24 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.