Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 357930

Summary: Thread timed out waiting ... when initializing jsdt.ui plugin
Product: [WebTools] JSDT Reporter: Martin Oberhuber <mober.at+eclipse>
Component: GeneralAssignee: Martin Oberhuber <mober.at+eclipse>
Status: RESOLVED FIXED QA Contact: Nitin Dahyabhai <thatnitind>
Severity: normal    
Priority: P3 CC: benno.baumgartner, daniel_megert, hyukmin0530.kwon, martinae, tjwatson, wbprio
Version: 3.3.1Flags: thatnitind: review+
Target Milestone: 3.3.2   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
patch v1 thatnitind: iplog+

Description Martin Oberhuber CLA 2011-09-16 08:03:14 EDT
+++ This bug was initially created as a clone of Bug #191193 +++

Build ID: JSDT 3.3.1 / o.e.wst.jsdt.ui_1.1.101.v201108151912

I'm getting the following error logged reproducably in my workspace on startup, and I'm assuming that it degrades startup performance:

While loading class "org.eclipse.wst.jsdt.internal.ui.InitializeAfterLoadJob$RealJob", thread "Thread[main,6,main]" timed out waiting (5000ms) for thread "Thread[Worker-4,5,main]" to finish starting bundle "org.eclipse.wst.jsdt.ui_1.1.101.v201108151912 [654]". To avoid deadlock, thread "Thread[main,6,main]" is proceeding but "org.eclipse.wst.jsdt.internal.ui.InitializeAfterLoadJob$RealJob" may not be fully initialized.

Doing a little bit of investigation shows that this is exactly the same problem which JDT fixed in bug 191193 :

The jsdt.ui#start() method schedules InitializeAfterLoadJob, and in some cases it can happen that the UI (Display.asyncExec / main Thread) schedules that Job before the start() method is finished.

The fix is easy -- same as in JDT, just move the 
     new InitializeAfterLoadJob().schedule(); 
to the very end of the start() method.
Comment 1 Martin Oberhuber CLA 2011-09-16 08:06:04 EDT
Created attachment 203483 [details]
patch v1

Attached simple patch fixes the issue.
Comment 2 Martin Oberhuber CLA 2011-09-16 08:12:11 EDT
For more improvements which JDT has already applied to its start() method and which could probably be applied to JSDT as well, see bug 127085:

    // make sure org.eclipse.jdt.core.manipulation is loaded too
    // can be removed if JavaElementPropertyTester is moved down to jdt.core (bug 127085)
    JavaManipulation.class.toString();

As well as bug 199135 -- jdt.ui/JavaPlugin.java v1.206.2.1

   (Encapsulate stuff in PlatformUI.isWorkbenchRunning()
Comment 3 Martin Oberhuber CLA 2011-09-16 08:56:21 EDT
JFYI, JSDT bug 258423 also has the timeout in its backtrace. Not sure it's related to that issue though, but it might be.
Comment 4 Thomas Watson CLA 2011-09-16 10:08:27 EDT
Martin's analysis looks correct.  It would be good to get this fixed.  Note that Java 7 support for parallel class loaders in equinox should avoid this kind of deadlock.
Comment 5 Martin Oberhuber CLA 2011-09-28 04:31:53 EDT
ping
Comment 6 Martin Oberhuber CLA 2011-11-16 15:04:47 EST
Ping, could my patch please be considered ?

Indigo SR 2 is approaching quickly and this should really be in.
Comment 7 Nitin Dahyabhai CLA 2011-11-29 02:37:14 EST
Committed to R3_3_maintenance and HEAD.  Thanks, Martin!