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 46287 - IDE hangs during JSP debugging with Swing browser
Summary: IDE hangs during JSP debugging with Swing browser
Status: CLOSED FIXED
Alias: None
Product: debugger
Classification: Unclassified
Component: Java (show other bugs)
Version: 4.x
Hardware: PC All
: P1 blocker (vote)
Assignee: issues@debugger
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-07-19 14:01 UTC by L Martinek
Modified: 2006-03-24 10:34 UTC (History)
6 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Thread dump (14.36 KB, text/plain)
2004-07-19 14:02 UTC, L Martinek
Details
new stack trace (11.12 KB, text/plain)
2004-07-26 14:53 UTC, Martin Grebac
Details
really new trace (9.46 KB, text/plain)
2004-07-26 15:50 UTC, Martin Grebac
Details
A patch - something to try (1.47 KB, patch)
2004-07-26 16:09 UTC, _ tboudreau
Details | Diff
patched trace - no better (10.32 KB, text/plain)
2004-07-26 16:38 UTC, Martin Grebac
Details

Note You need to log in before you can comment on or make changes to this bug.
Description L Martinek 2004-07-19 14:01:23 UTC
Set browser to Swing Browser.
Put breakpoint to JSP.
Start debugger. IDE hangs.
Comment 1 L Martinek 2004-07-19 14:02:08 UTC
Created attachment 16317 [details]
Thread dump
Comment 2 L Martinek 2004-07-19 14:33:15 UTC
You don't have to put breakpoint to JSP, IDE will hang anyway. Same
for debugging servlets. Running JSP or Servlet works without hang.
Comment 3 _ rkubacki 2004-07-20 09:56:17 UTC
We had a workaround for debugging in org.openide.awt.SwingBrowserImpl.
Look for org.openide.awt.SwingBrowserImpl.do-not-block-awt property
here and check if debugger sets it.
Comment 4 Martin Grebac 2004-07-20 10:39:32 UTC
Cool, thanks for help Radime. Debugger does not set the property -
there used to be this code in DelegatingDebugger in 36:

System.setProperty("org.openide.awt.SwingBrowserImpl.do-not-block-awt",
String.valueOf(state != DEBUGGER_NOT_RUNNING));

but there's no such code in 4.0 - ressigning to dbgjpda - please set
the property when debugger running.
Comment 5 Jan Jancura 2004-07-20 14:59:40 UTC
It must be some mistake. Debugger does not use Swing Browser.
Feel free to set this property if your module runs Swing Browser
inside the debugger.
Comment 6 Martin Grebac 2004-07-20 15:37:04 UTC
What about if user does attach to some server and uses swing browser
to reach some page? What then? I believe this must be set for all dbg
sessions.
Comment 7 Jan Jancura 2004-07-21 16:56:05 UTC
I do not understand this request. Looks like some patching of Swing
Browser functionality. But Patches for SwingBrowser should be in
module providing SwingBrowser. Moving SwingBrowser patches to debugger
code is not a good practise...
Comment 8 _ ttran 2004-07-21 22:51:57 UTC
we can't do it from inside SwingBrowserImpl.  This is a special case
for debugger.  Truely we should have an official API for that but it's
not and we're after feature freeze.  Either the JSP debbuger or the
JDPA debugger will have to initiate the special case, using this hack
at least for D.

Tim has already at least once suggested to kill SwingBrowser entirely.
 It doesn't really live up to what the user expects from a web browser
anyway
Comment 9 Jan Jancura 2004-07-26 09:18:10 UTC
Looks like architecture problem in web module.
1) Do not open SwingBrowser if it does not work, or open it externally
- not inside the NetBeans JVM.
2) If you sill needs do it internally - provide patch in your code for
debugging.
3) If its not possible to implement patch in your code, feel free to
suggest patch to some other module.
Comment 10 Martin Grebac 2004-07-26 09:35:25 UTC
I don't understand your assumptions - where did you get them from??
What architecture problem in web mdoule are you talking about??

In web code, we are not able to solve the problem I described above:

"What about if user does attach to some server (manually using Attach
action) creates some real Java breakpoint and uses swing browser
(manually) to reach some page? What then? Then there's no web code in
the process, only debugger and swing browser are in the way. I believe
this patch must be set for all dbg sessions."

So according to 3) of your "axioms" I still suggest patch in
debuggerjpda or swing browser.
Comment 11 _ rkubacki 2004-07-26 10:26:24 UTC
Two points:

It is a regression caused by commits in debugger modules. Though it
was a poor hack it worked in the past. 

I see three attempts from Hanz to assign this bug to a different
modules than debugger.
Comment 12 _ tboudreau 2004-07-26 12:13:59 UTC
Note that a few days ago I committed code to make the Swing browser not call 
JEditorPane.setPage() from the AWT thread, which is what the AWT thread is doing in the 
stack trace.  This issue may no longer be a problem.  Please test it.
Comment 13 Martin Grebac 2004-07-26 12:19:36 UTC
I was able to reproduce in todays build.
Comment 14 _ tboudreau 2004-07-26 12:57:56 UTC
Please post a new thread dump - it should definitely be different.  Also:  Is there an actual 
deadlock here?

"AWT-EventQueue-1" prio=7 tid=0x034a6800 nid=0x890 runnable 
[0x0439f000..0x0439fce8]
        at java.net.SocketInputStream.socketRead0(Native Method)

doesn't look like one (not to mention that it should not happen in AWT at all any more).  If 
the synchronization of reloadDocument() is an issue, that could probably be handled a 
different way - the only things that need their access protected are the fields "loadingURL" 
and "pendingURL".
Comment 15 _ rkubacki 2004-07-26 13:30:40 UTC
Tim. this is not usual deadlock. The problem is that there is a
debugged server that stopped at a breakpoint. Our IDE read the stream
from URL connection but now it cannot read further as the stream
producer is stopped. It might be resumed when we update our UI and we
let the server run again. But the debugger needs AWT thread to run the
continue/step actions:
Comment 16 Jan Jancura 2004-07-26 14:15:37 UTC
So, Tim. Will you fix it in SB, or should I apply this old patch in
debugger code?
And do you think that this patch is safe? I have heard that it has
some secondary impact (html redirection does not work).
Comment 17 _ rkubacki 2004-07-26 14:41:29 UTC
Libor, can you try it with JDK1.5 builds? I saw some changes to avoid
URL connection redirecting performed in AWT thread.

The only build containg the Tim's change in Swing browser so far is
tagged BLD200407222055. Did you Martin tested with this build?
Comment 18 Martin Grebac 2004-07-26 14:43:27 UTC
I tested with my own build - built from today's updated sources.
Comment 19 _ tboudreau 2004-07-26 14:50:52 UTC
Please reproduce the hang and attach a thread dump to this issue - it should definitely be 
different now, so I'd like to know where it's hanging.

Hans, am I correct that you could solve this problem simply by adding 1-2 
System.setProperty calls to the debugger's code?
Comment 20 Martin Grebac 2004-07-26 14:53:43 UTC
Created attachment 16451 [details]
new stack trace
Comment 21 L Martinek 2004-07-26 15:09:04 UTC
I always ran it on JDK1.5.0.
Comment 22 Jan Jancura 2004-07-26 15:09:26 UTC
Tim, as I wrote, I can apply some old patch provided by Jesse. But I
am not sure if the patch is safe, and if its the best solution.
Comment 23 _ tboudreau 2004-07-26 15:24:02 UTC
The new thread dump is not from the current trunk:

        at javax.swing.JEditorPane.setPage(JEditorPane.java:392)
        at org.openide.awt.SwingBrowserImpl.setURL(SwingBrowserImpl.java:189)

Here is line 189 of SwingBrowserImpl:

    }

There is no call to setPage() from SwingBrowserImpl.setURL() anymore, this is done in 
another thread.

In summary:  Please do a cvs update and a clean build of openide, and try it again.

Then, if it's *really* still a problem, I think the debugger should use the existing 
workaround.  I suspect you won't need to, but maybe some other blocking call still 
happens on the AWT thread later.  This is far too much time for three people to be 
spending on something this trivial, when there are far more serious bugs for all of us to 
work on.  We have a fix, it was safe before, there's no reason to think it isn't now.
Comment 24 Martin Grebac 2004-07-26 15:50:16 UTC
Created attachment 16454 [details]
really new trace
Comment 25 _ tboudreau 2004-07-26 16:09:20 UTC
Created attachment 16456 [details]
A patch - something to try
Comment 26 _ tboudreau 2004-07-26 16:11:53 UTC
You can try the attached patch - it depends on two things:  1.  That boolean writes are 
atomic, and thus thread-safe.  2.  That the code will enter updateTitle() first and 
getStream() second, and if that happens, it will use FilteredInputStream, just as the patch 
does.  I'm not sure such black magic is at all a good idea.

Hans, as far as I can tell, Jesse's patch is perfectly safe.  The most sensible thing to do 
here would be to use it.
Comment 27 Martin Grebac 2004-07-26 16:38:57 UTC
Created attachment 16458 [details]
patched trace - no better
Comment 28 Jan Jancura 2004-07-26 16:51:41 UTC
OK. Jesse's patch is back. But I can not verify it - JSP Line
breakpoint does not work for me. 

cvs commit -m "46287: IDE hangs during JSP debugging with Swing
browser" JPDADebuggerImpl.java (in directory
C:\Hanz\Dev\trunk\debuggerjpda\src\org\netbeans\modules\debugger\jpda)
Checking in JPDADebuggerImpl.java;
/cvs/debuggerjpda/src/org/netbeans/modules/debugger/jpda/JPDADebuggerImpl.java,v
 <--  JPDADebuggerImpl.java
new revision: 1.45; previous revision: 1.44
done
Comment 29 Martin Grebac 2004-07-26 17:01:46 UTC
Works well for me with Hanz's patch. Hanzi, it could have taken 2
minutes, so this could have been already fixed 6 days ago!
Comment 30 Jan Jancura 2004-07-26 17:21:32 UTC
Not correct.
1) This is not solution, this is not very correct path. Html
redirection does not work when debugger is running, as I know. We
should try to find some real solution.

2) I can not simply take some code I am not author of, and put it
somewhere. SwingBrower maintainer should maintain SwingBrowser patches.

Comment 31 Jesse Glick 2004-07-26 19:41:35 UTC
Maybe we should just remove the Swing browser option from the IDE's
GUI. I can't think of any compelling reason to use it. It's not a very
good browser at all, and everyone is going to have a better one. As
this bug demonstrates, it is inherently not implemented safely: it
makes network calls from EQ.
Comment 32 L Martinek 2004-09-30 14:59:54 UTC
forgot to mark as verified