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 166548 - fix imports fails with multiple processes and beeps
Summary: fix imports fails with multiple processes and beeps
Status: VERIFIED FIXED
Alias: None
Product: editor
Classification: Unclassified
Component: Actions/Menu/Toolbar (show other bugs)
Version: 6.x
Hardware: All Linux
: P1 blocker with 1 vote (vote)
Assignee: Vitezslav Stejskal
URL:
Keywords: PERFORMANCE, REGRESSION
Depends on:
Blocks:
 
Reported: 2009-06-04 13:24 UTC by jbfaden
Modified: 2009-06-10 10:40 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
screen shot showing my desktop (563.62 KB, image/png)
2009-06-04 13:28 UTC, jbfaden
Details
stack trace after invoking "Fix Imports" action from menu bar (26.81 KB, text/plain)
2009-06-04 14:44 UTC, jbfaden
Details

Note You need to log in before you can comment on or make changes to this bug.
Description jbfaden 2009-06-04 13:24:55 UTC
Twice this morning I've tried to fix imports and it fails.  I get the fix import dialog, then if I accept, Netbeans
pauses for a short while, then my gnome desktop starts beeping irregularly.  If I look at the fix imports progress I can
see multiple fix imports processes running.  I wait a short while, and I try to close netbeans.  Now it appears that
there are many fix imports processes going.
Comment 1 jbfaden 2009-06-04 13:28:51 UTC
Created attachment 83203 [details]
screen shot showing my desktop
Comment 2 Marian Mirilovic 2009-06-04 14:19:00 UTC
jbfaden,
could you please generate thread-dump
http://wiki.netbeans.org/GenerateThreadDump#section-GenerateThreadDump-UnixLinuxMacOSX

... and attach output into this issue ?

Thanks in advance.
Comment 3 jbfaden 2009-06-04 14:44:05 UTC
Created attachment 83206 [details]
stack trace after invoking "Fix Imports" action from menu bar
Comment 4 Vitezslav Stejskal 2009-06-04 16:05:10 UTC
Something very strange must have been going on. The progress bar says '729 tasks running'?! What are the other tasks? Do
you know how to get the IDE to this state? The threaddump shows that the fix imports task is running. But it would not
show if and what other tasks there may have been pending. Was 'Scanning projects...' task running as well? Does this
happen always when you debug your app? Also could you please attach <ide-userdir>/var/log/messages.log here? Thanks

Marian, this may take time to track down and fix. Especially if we don't find a reproducible testcase.
Comment 5 Vitezslav Stejskal 2009-06-04 16:12:54 UTC
Umm, I just found out that holding 'Ctrl+Shift+I' will simply flood the IDE with many fix-imports tasks, which could be
the reason for having too many of them shown in the progress bar. They'll eventually finish, but it may take some time.
We could probably create an easy fix for this, which would simply ignore new fix-imports requests for the same file
while the fix-imports task is already running on that file.
Comment 6 Marian Mirilovic 2009-06-04 16:39:57 UTC
> We could probably create an easy fix for this, which would simply ignore new fix-imports requests for the same file
while the fix-imports task is already running on that file.

Vita, is it doable in NB 6.7 timeframe ? If so please do it. We can solve the rest after NB 6.7 . Anyway this is the
only report we've got so far about this particular problem, so do not expect this is really easy to reproduce case.
Thanks in advance.
Comment 7 Rastislav Komara 2009-06-04 16:40:07 UTC
I fetched last sources and try to reproduce this. Fix Imports works perfectly. BUT! After analysis of symptoms I think
there is several windows opened behind main window and it causes beeping of gnome. You are talking about accepting
dialog for fix imports. It means the each running Fix imports opened dialog. is there possibility that you pressed more
Fix Imports shortcuts more then one time? I noticed running debuger. Can you succesfully replicate this issue? Provide
steps to reproduce and messages.log from your userdir. I'm marking this as incomplete and lowering priority. 
Comment 8 Rastislav Komara 2009-06-04 16:42:25 UTC
Sorry, no lower priority :D
Comment 9 jbfaden 2009-06-04 17:13:36 UTC
> The progress bar says '729 tasks running'?! 
Indeed there appear to be hundreds of "Fix Imports" tasks running.  I'll see if I can reproduce the bug from my office
on campus later today.

Comment 10 jbfaden 2009-06-04 17:21:12 UTC
Quick-n-dirty attempt to create a means of demonstrating the problem: I close all my projects.  I create a new project.
 I add "Color c" to the main method of the new project.  I invoke "fix imports" from the menubar.  The bug occurs,
beeping many times (50-200) until it stops about a minute later.

This is on Ubuntu 9.04, using Gnome 2.26.1.  64 bit Java 6.

Jeremy
Comment 11 Rastislav Komara 2009-06-05 09:24:57 UTC
Please attach messages.log a uigestures log. Thank you.
Comment 12 Marian Mirilovic 2009-06-05 09:36:50 UTC
Ok, after discussion with Rasta(moonko) and explanation the problem .. looks like we are able to reproduce the problem
and we'll try to fix it into NB 6.7 FCS (definitely not for RC2).
Comment 13 Vitezslav Stejskal 2009-06-05 11:54:41 UTC
Yeah, I think I know what the problem is. It seems to be an absolutely nasty regression introduced by 6f7991353307. IMO
all editor main menu actions suffer from this and there are probably also severe memory leaks. I'll fix it asap. In the
mean time please avoid using editor related main menu actions. Instead try remembering their shortcuts and invoke them
directly from the editor pane using their shortcuts. It should avoid the problem. The editor popup menu actions should
also be safe to use.

Marian, since the fix won't make it to RC2 we may want to mention the problem to the users.
Comment 14 Marian Mirilovic 2009-06-05 12:03:13 UTC
http://hg.netbeans.org/release67/rev/6f7991353307

> Marian, since the fix won't make it to RC2 we may want to mention the problem to the users.

Any chance to get it fixed in RC3 (next week) ? Are you able to fix also memory leaks you mentioned ?

BTW: We are living with this issue since May/5 ... so don't think we need to mention it in RN just for RC2 (if fixed in
RC3).
Comment 15 Vitezslav Stejskal 2009-06-05 13:03:51 UTC
Yes, I think the fix should not be hard, but is likely to involve changes in many places (all MainMenuAction subclasses)
unless I figure out something more clever. The memory leaks should get fixed too. Thinking more about it the leaks may
not be so bad. I suspected that somehow editor documents could be held in memory through the MainMenuAction instances,
but that's not the case and I think we would have noticed.
Comment 16 Vitezslav Stejskal 2009-06-05 16:38:39 UTC
Simple steps how to reproduce it:

1. clean userdir, start ide
2. open or create a java project with at least 2 java sources
3. open those two sources in the editor
4. keep switching between them eg 30-40 times or more if you have the patience
5. type (!) without using code completion "public void aaa() { Color c; }" to one of the sources, the IDE should
underline the 'Color' work, because the Color class is not imported
6. in the main menu (!) select Source -> Fix imports

You should see the progress bar showing multiple Fix imports tasks and if you are fast enough and hover your mouse over
the progress bar it'll say in the tooltip how many there is. The number should loosely correspond to the number of
switches in step #4.
Comment 17 Vitezslav Stejskal 2009-06-05 16:45:31 UTC
Other symptom is missing shortcut in the main menu item (eg. Fix Imports has Ctrl+Shift+I in the default shortcuts
profile and the Source -> Fix imports menu item should show it if there is a java editor opened and selected).
Comment 18 Marian Mirilovic 2009-06-05 16:48:28 UTC
... for missing shortcuts I reported issue 166583
Comment 19 Vitezslav Stejskal 2009-06-05 17:26:55 UTC
This should fix it - http://hg.netbeans.org/jet-main/rev/806fd8073a9e.
Comment 20 Quality Engineering 2009-06-08 18:45:42 UTC
Integrated into 'main-golden', will be available in build *200906081401* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/806fd8073a9e
User: Vita Stejskal <vstejskal@netbeans.org>
Log: #166548: single MainMenuAction instance was hooked up with its menu presenter many times, causing the action instance to be called multiple times when user invoked the action from the main menu
Comment 21 Jiri Prox 2009-06-09 14:58:45 UTC
verified in trunk
Comment 22 Miloslav Metelka 2009-06-09 15:13:11 UTC
I approve the fix.
Comment 23 Vitezslav Stejskal 2009-06-09 16:25:55 UTC
Transplanted to release67 clone as http://hg.netbeans.org/release67/rev/31e79bb1e626.
Comment 24 Jiri Prox 2009-06-10 10:40:41 UTC
verified in 6.7