This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 127170 - Open project dialog seemed to hang
Summary: Open project dialog seemed to hang
Status: VERIFIED FIXED
Alias: None
Product: projects
Classification: Unclassified
Component: Generic Infrastructure (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Milos Kleint
URL:
Keywords: PERFORMANCE
: 133640 (view as bug list)
Depends on: 106223
Blocks: 109206
  Show dependency tree
 
Reported: 2008-02-11 22:17 UTC by John Baker
Modified: 2008-06-13 17:58 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
stack trace in console (17.63 KB, text/plain)
2008-02-11 22:18 UTC, John Baker
Details
Demo of incrementally updating icons in a JFileChooser (4.70 KB, text/plain)
2008-02-13 18:50 UTC, Jesse Glick
Details

Note You need to log in before you can comment on or make changes to this bug.
Description John Baker 2008-02-11 22:17:37 UTC
Using bits from Feb 10, I built the IDE using
the standard cluster configuration.

Just after first time starting the IDE, the Open project dialog seemed to hang for awhile. It eventually returned, but

A trace was printed in the console. I will attach it.
Comment 1 John Baker 2008-02-11 22:18:23 UTC
Created attachment 56489 [details]
stack trace in console
Comment 2 Milos Kleint 2008-02-12 09:00:57 UTC
there's nothing really suspicious in the stacktraces. Only the job that is supposed to be happening, is performed. It
seems to be instant on my mac. Did you have any other IO intensive tasks on the computer running at the same time? like
hg update etc..

reassigning to apisupport for evaluation. (it could be related to the fact we have 600+ projects in one folder, but I'm
not sure it matters). The issue is most likely IO bound and not much can be done here. One cannot pre-load the contents
of the folder or anything like that..

Comment 3 Jesse Glick 2008-02-13 18:49:25 UTC
Nothing to be done here when using the current ProjectChooserAccessory. In order to display the project badging on
icons, you need to do disk stats. There is no trivial way to ask JFileChooser to _update_ an icon after it has first
been displayed, so the icon needs to be calculated synchronously in EQ.

And if your disk caches are cold, some inodes need to be read in before that can happen. If there are hundreds of
project dirs, that can take a moment.

I will attach a demo showing that at least in Metal L&F it is possible to update icons asynchronously using the trick of
calling setFileView. Maybe this could be used in PCA to badge project nodes asynchronously. You could even do one
relatively fast but asynch pass calling isProject and retaining this info, adding a simple project badge; and then for
every folder for which getIcon is called (i.e. which has been displayed in the scroll viewport?), do a slower second
pass calling loadProject and displaying the actual project icon.
Comment 4 Jesse Glick 2008-02-13 18:50:56 UTC
Created attachment 56637 [details]
Demo of incrementally updating icons in a JFileChooser
Comment 5 Jesse Glick 2008-04-23 15:28:24 UTC
*** Issue 133640 has been marked as a duplicate of this issue. ***
Comment 6 Jesse Glick 2008-04-23 15:30:23 UTC
See issue #109206 for project-type-specific badging.
Comment 7 Jesse Glick 2008-04-23 17:51:52 UTC
It can be fixed pretty easily, giving dramatically better performance for the Open Project dialog, by doing this in
DirectoryChooserUI.java:

        tree = new JTree(new Object[0]) {
            protected void processMouseEvent(MouseEvent e) {...as before...}
            public void setRowHeight(int rowHeight) {
                if (rowHeight > 0) {
                    super.setRowHeight(rowHeight);
                }
            }
            public boolean isLargeModel() {
                return true;
            }
        };

Then the OP dialog only asks isProject for subdirs which are actually displayed, causing far fewer disk accesses.

Unfortunately this then seems to regress issue #106223, easily reproduced by running with --fontsize 18 in Ocean L&F. I
am not sure how to set a fixed cell height appropriately for a tree. For lists, you can set a prototype value, but there
seems to be no similar call for JTree.
Comment 8 rdelaplante 2008-05-28 14:13:20 UTC
I am experiencing this problem with NB 6.1.  I did a fresh install and started opening projects.  After I had about 5-8
projects open, the open project dialog would become frozen.  Every time I click inside the window it would beep at me. 
I found that I could use tab/shift-tab/arrow keys/enter to navigate around, select a project and open it.
Comment 9 Jesse Glick 2008-06-06 20:52:54 UTC
With the help of a trick from Tim (first Google hit for "jtree fixed row height"!) I think I have it working - should
now calculate isProject only for visible folders, while using the correct row height for the desired font size. Seems OK
at least on:

- Ubuntu
-- JDK 5: Metal regular, --fontsize 18
-- JDK 6: Metal regular, --fontsize 18, GTK, GTK with Gnome font size 18
- XP
-- JDK 6: Win32 regular, --fontsize 18 (setting Windows Desktop prefs to use "Extra Large" fonts had no apparent effect
on most text in the IDE)

Tim please review:

http://hg.netbeans.org/core-main/rev/190d195fb7bc
Comment 10 Quality Engineering 2008-06-07 16:08:04 UTC
Integrated into 'main-golden', available in NB_Trunk_Production #243 build
Changeset: http://hg.netbeans.org/main/rev/190d195fb7bc
User: Jesse Glick <jglick@netbeans.org>
Log: #127170: improved performance for Open Project by only inspecting dirs which are currently visible.
Comment 11 _ tboudreau 2008-06-09 05:56:06 UTC
Looks right.  Super-micro-nits, feel free to ignore:
 - Could probably call setLargeModel(tree) instead of overriding isLargeModel() and save a few bytes
 - Slightly more efficient might be g.getFontMetrics(getFont()).getHeight() and skip setting the font on the Graphics object
 - In later iterations of code like this, I moved the resetting of firstPaint to updateUI().  Only could make a difference if icon size changed and you were 
actually using default icons looking up their size and storing that instead hard coding a default height.  Someday might matter for vector based icons and 
high-res displays, but supporting that will require other changes anyway, and updateUI() is going to call setFont() anyway.

BTW, if you want to support "Jesse Mode" for the file chooser (force a short height for all cells), you'll want to look up 
System.getProperty("nb.cellrenderer.fixedheight") (I think that's the string) and use that instead of the font height if present.

Anyway, this will probably help a lot with the performance issue.
Comment 12 Jesse Glick 2008-06-10 00:32:56 UTC
I override isLargeModel() because I think I saw some JRE code calling setLargeModel(false) under certain conditions and
I wanted to make sure this would not happen.

Regarding other points, you clearly know more about the subject than I do - if you see something you think needs to be
fixed, feel free to fix it (or add a comment to the source suggesting that it could be changed in a certain way if
certain problems arise in the future).
Comment 13 Jesse Glick 2008-06-13 17:58:14 UTC
Also fixing for quickfilechooser: contrib #2efa20b0b23c