Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Netbeans 14 freezes spuriously when r-clicking at Design View #4231

Closed
rapastranac opened this issue Jun 16, 2022 · 14 comments · Fixed by #4375
Closed

Netbeans 14 freezes spuriously when r-clicking at Design View #4231

rapastranac opened this issue Jun 16, 2022 · 14 comments · Fixed by #4375
Labels
kind:bug Bug report or fix Look and Feel UI User Interface
Milestone

Comments

@rapastranac
Copy link

Apache NetBeans version

Apache NetBeans latest daily build

What happened

When editing forms, when I right-click on the form and the menu is expanded, it suddenly freezes at any of the menu items

How to reproduce

When I right-click on the form and the menu is expanded, it suddenly freezes at any of the menu items, but it does not happens consistently. Maybe a multi-thread issue.

Did this work correctly in an earlier version?

Apache NetBeans 13

Operating System

Windows 10

JDK

13

Apache NetBeans packaging

Apache NetBeans provided installer

Anything else

No response

Are you willing to submit a pull request?

No

Code of Conduct

Yes

@rapastranac rapastranac added kind:bug Bug report or fix needs:triage Requires attention from one of the committers labels Jun 16, 2022
@mbien
Copy link
Member

mbien commented Jun 17, 2022

i believe I saw that too. It happens more often if the context menu is cascaded.

Might have potentially something to do with the FlatLAF update since it added some features specific to context menus (#3983). Have to check if there is a flag for that to toggle it off for testing purposes. (or test with a different look and feel enabled)

@mbien mbien added Look and Feel UI User Interface and removed needs:triage Requires attention from one of the committers labels Jun 17, 2022
@mbien
Copy link
Member

mbien commented Jun 28, 2022

@DevCharly do you know of any issues with context menus? Is it possible to disable the submenu feature via a flag for testing?

@DevCharly
Copy link
Member

Does "Netbeans freezes" mean that the whole IDE is dead and you have to kill it?
Then a thread dump would be very helpful: https://foojay.io/pedia/thread-dump/

do you know of any issues with context menus?

No.

Is it possible to disable the submenu feature via a flag for testing?

Yes, add Menu.useSafeTriangle = false
to platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/FlatLaf.properties

@rapastranac
Copy link
Author

For some reason I could not uploaded the thread dump when filing this issue.

Here it is

threaddump-1655395630439.txt

I captured it with visualvm, whose original extension is tdump. I edited the extension so I could upload it here

@DevCharly
Copy link
Member

@rapastranac thanks for the thread dump.
Did not find any issue in the dump.
The stack of the AWT-EventQueue-0 thread looks normal. (same as in debugger)
No occurrences of flatlaf.
No blocked threads.
Looks like a dump of a working NB process...

Are there any exceptions in the NetBeans log file?
What look and feel do you use? (Tools > Options > Appearance > Look and feel)

I'm still not sure what you mean with "suddenly freezes".
Is the whole IDE dead and you have to kill it?
Or does the UI freeze for some seconds and then works again?

@rapastranac
Copy link
Author

It freezes out of a sudden and the only pattern I found was when r-clicking.

  • The whole IDE freezes and it must be killed.
  • I was using FlatLaf light for the Look and feel.
  • I don't have the log anymore

I stopped using NetBeans 14 after that many interruptions.

@wumpz
Copy link
Contributor

wumpz commented Jul 6, 2022

Same here since Netbeans 14 maybe two times.

@eirikbakke
Copy link
Contributor

Hmm, this problem would be very good to fix. Could either of you try to see if you could manage to reliably reproduce the bug? And perhaps take a screenshot of NetBeans in the frozen state?

It might be good to try another thread dump as well.

@cts93
Copy link

cts93 commented Jul 9, 2022

I'm using Apache NetBeans IDE 14 with this: https://draculatheme.com/netbeans

I had the same issue happen to me once I started creating and editing JFrames. Same thing: change something upon context menu (particularly the Auto Resize option) and it just freezes up everything. You have to kill NetBeans through Task Manager and open again.

I just now changed NetBeans Look and Feel theme from FlatLaf Dark to something else, checked the option "Maximize use of native look and feel". It removed that front color theme I downloaded from Dracula so I added it again and changed Look and Feel back to FlatLaf Dark. I still didn't get any freeze ever since; It seemed to have solved the problem for me.

So what we know from this is it's clearly something to do with themes, perhaps compatibility issues with custom themes.

@DevCharly
Copy link
Member

@cts93 thanks for your report and for mentioning JFrame.

I can now reproduce it. I thought that it could be related to JFrame and played around and had a freeze.
But it turned out that it has nothing to do with JFrame.
It is related to Preview Design. Once showing a preview, then menus that have submenus freeze NB.

Steps to reproduce:

  1. create a new form
  2. click Preview Design button in designer toolbar, which shows an empty design preview window
  3. close the design preview window
  4. right-click on panel in designer shows context menu
  5. move mouse down the context menu over some items that have submenus --> freeze

It is indeed related to FlatLaf submenu usability improvements: JFormDesigner/FlatLaf#490 (used in NB 14 since PR #3983)
If I disable this feature, it does not freeze.

There are no exceptions. The stack looks OK.
ATM have no idea why it is dead 😕

@DevCharly DevCharly added this to the NB15 milestone Jul 9, 2022
@DevCharly
Copy link
Member

Following line in NB form designer causes the problem:

previewLookAndFeel.initialize();

When showing a preview, the designer creates a second instance of the current L&F (either class FlatLightLaf or FlatDarkLaf) and invokes FlatLaf.initialize(), which installs a lot of listeners, factories, etc into the system. Then there are duplicate listeners, which cause problems. In case of FlatLaf, initialize() should be not invoked multiple times.

The freeze happens because there are two listeners that both temporary install event queues:

  1. push first event queue (Toolkit.getDefaultToolkit().getSystemEventQueue().push( ... ))
  2. push second event queue
  3. pop first event queue --> freeze

Will add some checks to FlatLaf to prevent duplicate execution of FlatLaf.initialize() ...

@cts93
Copy link

cts93 commented Jul 9, 2022

@DevCharly Whoa! I didn't know you were the creator himself. Thanks for your reply and effort into improving it for all of us.

@mbien
Copy link
Member

mbien commented Jul 10, 2022

@DevCharly I suppose we could disable the submenu improvements (as you mentioned here) for one release in NB, so that we don't have to rush fixes into FlatLaf (no need to hurry). I had the feeling it might have something to do with it, I just couldn't reproduce the exact conditions - great job for making the connection with the form designer.

Btw when the freeze happens my entire xserver freezes. I have to ctrl+alt+F2 into a second session and terminate the process to recover (cinnamon desktop environment, nv drivers).

DevCharly added a commit to JFormDesigner/FlatLaf that referenced this issue Jul 13, 2022
…times, which can freeze the application caused pushing multiple event queues and popping wrong event queue first

(e.g. NetBeans Form Editor invokes `FlatLaf.initialize()` but not `uninitialize()`)

(PR #490; apache/netbeans#4231)
DevCharly added a commit to JFormDesigner/FlatLaf that referenced this issue Jul 13, 2022
For NetBeans GUI builder, which invokes `FlatLaf.initialize()` multiple times for preview, but never invokes `FlatLaf.uninitialize()`.

(apache/netbeans#4231)
@DevCharly DevCharly linked a pull request Jul 14, 2022 that will close this issue
@DevCharly
Copy link
Member

PR #4375 fixes this issue 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug Bug report or fix Look and Feel UI User Interface
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants