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 146336 - IDE hangs if window is minimized and restored
Summary: IDE hangs if window is minimized and restored
Status: VERIFIED FIXED
Alias: None
Product: editor
Classification: Unclassified
Component: -- Other -- (show other bugs)
Version: 6.x
Hardware: PC Windows Vista
: P2 blocker (vote)
Assignee: issues@editor
URL:
Keywords: RANDOM, THREAD
: 146516 146761 147290 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-09-05 15:51 UTC by _ gtzabari
Modified: 2008-09-22 11:28 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
thread dump (19.85 KB, text/plain)
2008-09-05 16:09 UTC, _ gtzabari
Details

Note You need to log in before you can comment on or make changes to this bug.
Description _ gtzabari 2008-09-05 15:51:45 UTC
dev build 200809050201

1) Open Netbeans
2) In Windows Vista go to "Appearance Settings" -> "Effects" -> "Use the following method to smooth edges of screen
fonts" and change from "ClearType" to "Standard" (or vice-versa)
3) Minimize and restore the Netbeans window
4) Netbeans hangs and must be killed

This is probably related to issue 137845 which states that we must listen for anti-aliasing changes in the OS and
respond accordingly
Comment 1 _ gtzabari 2008-09-05 16:00:48 UTC
Sorry in step 2 you need to go to "Control Panel" -> "Windows Color and Appearance" before the rest of the items I listed.

PS: SwingSet2 handles this perfectly, you can even see the font anti-aliasing setting changing in real-time.
Comment 2 _ gtzabari 2008-09-05 16:08:19 UTC
I stand corrected, this has nothing to do with anti-aliasing. I can reproduce this hang 100% of the time simply by
minimizing and restoring the window. I'm attaching a thread dump.
Comment 3 _ gtzabari 2008-09-05 16:09:47 UTC
Created attachment 69166 [details]
thread dump
Comment 4 _ gtzabari 2008-09-05 16:16:05 UTC
build 1.6.0_10-rc-b28, Windows Vista 64-bit
Comment 5 Petr Chytil 2008-09-08 09:22:51 UTC
reassigning to core for evaluation
Comment 6 Lukas Hasik 2008-09-08 09:35:43 UTC
reassigning to editor

it seems that the AWT thread is locked 
- locked <0x0000000006eafeb8> (a java.lang.Class for org.netbeans.api.editor.EditorRegistry)
	at org.netbeans.api.editor.EditorRegistry$FocusL.focusGained(EditorRegistry.java:555)

pchytil, could you try to reproduce on Vista?
Comment 7 Vitezslav Stejskal 2008-09-08 10:27:40 UTC
I'm not sure why exactly the IDE deadlocked or if the threaddump actually shows a deadlock. But I tried to improve the
situation by fixing EditorRegistry not to fire events when holding a lock. http://hg.netbeans.org/main/rev/1ede45ab9729
Comment 8 Petr Chytil 2008-09-08 12:48:04 UTC
I am unable to reproduce it on 32bit Vista (I do not have 64bit Vista available for testing):

Product Version: NetBeans IDE Dev (Build 200809050201)
Java: 1.6.0_10-beta; Java HotSpot(TM) Client VM 11.0-b11
System: Windows Vista version 6.0 running on x86; Cp1250; cs_CZ (nb)
Userdir: C:\Users\Petr\.netbeans\dev

I also played around with ClearType settings, but without any success.
Comment 9 mslama 2008-09-08 13:42:49 UTC
Lukas why did you assign this to openide/editor? It does not seem to be deadlock. I would need more thread dumps to see
if there is any change in AWT thread state. It could be some live lock that AWT thread does not free lock on
org.netbeans.api.editor.EditorRegistry. At this moment I believe from thread dump that AWT thread is RUNNABLE. It looks
like problem with gsf which waits for some locks. Passing back to editor.
Comment 10 mslama 2008-09-08 13:56:48 UTC
I checked thread dump. Firing events from EditorRegistry out of lock should help in this case but it is not clear if it
is real cause in this case. Reporter please generate more thread dumps and attach it here so I can check status of AWT
thread. Thanks.
Comment 11 Vitezslav Stejskal 2008-09-08 14:11:32 UTC
I discussed this with Hozna Lahoda and as he pointed out the deadlock is likely to be between 'AWT-EventQueue-1' and
'gsf module install' threads and involves class loading. The 'gsf module install' thread is loading
o.n.napi.gsfret.source.Source, which accesses EditorRegistry from its static initializer. The two locks that are locked
at this moment are JVM's lock for classloading and EditorRegistry.class. In the 'AWT-EventQueue-1' thread the
EditorRegistry fires an event when holding the EditorRegistry.class lock. The event reaches
o.n.napi.gsfret.source.support.OpenedEditors, which needs to access o.n.napi.gsfret.source.Source class. So, the
'AWT-EventQueue-1' thread locks the two above mentioned locks in the opposite order. 

I believe that my fix mentioned earlier in this issue resolves the problem. Gili, could you please try a newer build and
confirm that the deadlock is really fixed? Thanks
Comment 12 mslama 2008-09-08 14:17:15 UTC
I surprised that AWT thread state is RUNNABLE. It is weird.
Comment 13 mslama 2008-09-08 14:18:15 UTC
I am surprised that AWT thread state is RUNNABLE. It is weird.
Comment 14 Vitezslav Stejskal 2008-09-08 14:45:30 UTC
Yes, it looks weired. But since there is no lock for classloading explicitly mentioned in the stacktrace either the JVM
probably does not detect the thread status correctly in this case. 
Comment 15 _ gtzabari 2008-09-08 16:59:47 UTC
Do you have a specific changeset handy? It would be good to look up what "golden" build it ended up in to make sure I
don't download the wrong version.
Comment 16 mslama 2008-09-08 17:12:30 UTC
Changeset was given by Vita above. It is http://hg.netbeans.org/main/rev/1ede45ab9729. Or do you need anything else? It
modifies editor.lib2/src/org/netbeans/api/editor/EditorRegistry.java. It changes synchronization when events are fired.
Comment 17 Quality Engineering 2008-09-08 17:19:42 UTC
Integrated into 'main-golden', will be available in build *200809081401* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/1ede45ab9729
User: Vita Stejskal <vstejskal@netbeans.org>
Log: #146336: trying to prevent a deadlock; EditorRegistry does not fire events when holding a lock
Comment 18 _ gtzabari 2008-09-08 23:49:02 UTC
Works for me. Thanks guys!
Comment 19 Vitezslav Stejskal 2008-09-09 10:19:18 UTC
*** Issue 146516 has been marked as a duplicate of this issue. ***
Comment 20 Jan Lahoda 2008-09-10 12:47:06 UTC
*** Issue 146761 has been marked as a duplicate of this issue. ***
Comment 21 Vitezslav Stejskal 2008-09-22 11:28:01 UTC
*** Issue 147290 has been marked as a duplicate of this issue. ***