Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 188810 - [performance] task activation should not happen in UI thread
Summary: [performance] task activation should not happen in UI thread
Status: CLOSED MOVED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Mylyn (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 minor (vote)
Target Milestone: ---   Edit
Assignee: Shawn Minto CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 247092
  Show dependency tree
 
Reported: 2007-05-23 23:43 EDT by Eugene Kuleshov CLA
Modified: 2013-05-17 14:38 EDT (History)
1 user (show)

See Also:


Attachments
mylar/context/zip (1.13 KB, application/octet-stream)
2007-05-24 14:09 EDT, Mik Kersten CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Eugene Kuleshov CLA 2007-05-23 23:43:16 EDT
I accidentally restarted Eclipse Workbench with activated task and it froze UI for quite some time after that restart. From the thread dump there is some JDT code triggered from within UI thread. I think this stuff should be moved out of the UI thread.

On the other hand, JDT and generally workbench is trying to minimize startup time, so maybe Mylar should not reactivate task after startup.

"main" prio=6 tid=0x00296000 nid=0xc70 in Object.wait() [0x0090e000..0x0090fe5c]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <0x0e0bca48> (a org.eclipse.core.internal.jobs.Semaphore)
        at org.eclipse.core.internal.jobs.Semaphore.acquire(Semaphore.java:38)
        - locked <0x0e0bca48> (a org.eclipse.core.internal.jobs.Semaphore)
        at org.eclipse.core.internal.jobs.OrderedLock.doAcquire(OrderedLock.java:169)
        at org.eclipse.core.internal.jobs.OrderedLock.acquire(OrderedLock.java:105)
        at org.eclipse.core.internal.jobs.OrderedLock.acquire(OrderedLock.java:82)
        at org.eclipse.core.internal.resources.WorkManager.checkIn(WorkManager.java:118)
        at org.eclipse.core.internal.resources.Workspace.prepareOperation(Workspace.java:1744)
        at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1792)
        at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:785)
        at org.eclipse.jdt.core.JavaCore.setClasspathContainer(JavaCore.java:4519)
        at org.eclipse.jdt.internal.launching.JREContainerInitializer.initialize(JREContainerInitializer.java:69)
        at org.eclipse.jdt.internal.core.JavaModelManager.initializeContainer(JavaModelManager.java:2203)
        at org.eclipse.jdt.internal.core.JavaModelManager.getClasspathContainer(JavaModelManager.java:1545)
        at org.eclipse.jdt.core.JavaCore.getClasspathContainer(JavaCore.java:1571)
        at org.eclipse.jdt.internal.core.JavaProject.resolveClasspath(JavaProject.java:2558)
        at org.eclipse.jdt.internal.core.JavaProject.getResolvedClasspath(JavaProject.java:1848)
        at org.eclipse.jdt.internal.core.JavaProject.buildStructure(JavaProject.java:395)
        at org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:229)
        at org.eclipse.jdt.internal.core.Openable.openParent(Openable.java:423)
        at org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:218)
        at org.eclipse.jdt.internal.core.Openable.openParent(Openable.java:423)
        at org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:218)
        at org.eclipse.jdt.internal.core.Openable.openParent(Openable.java:423)
        at org.eclipse.jdt.internal.core.CompilationUnit.openParent(CompilationUnit.java:1102)
        at org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:218)
        at org.eclipse.jdt.internal.core.SourceRefElement.generateInfos(SourceRefElement.java:107)
        at org.eclipse.jdt.internal.core.JavaElement.openWhenClosed(JavaElement.java:505)
        at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:249)
        at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:235)
        at org.eclipse.jdt.internal.core.JavaElement.exists(JavaElement.java:153)
        at org.eclipse.mylar.internal.java.ui.JavaUiBridge.open(JavaUiBridge.java:60)
        at org.eclipse.mylar.internal.resources.ui.ContextEditorManager.contextActivated(ContextEditorManager.java:101)
        at org.eclipse.mylar.internal.context.core.ContextManager.activateContext(ContextManager.java:443)
        at org.eclipse.mylar.tasks.ui.TasksUiPlugin$1.taskActivated(TasksUiPlugin.java:208)
        at org.eclipse.mylar.tasks.ui.TaskListManager.activateTask(TaskListManager.java:848)
        at org.eclipse.mylar.tasks.ui.TasksUiPlugin$8.run(TasksUiPlugin.java:446)
        at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
        at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:123)
        - locked <0x0daba068> (a org.eclipse.swt.widgets.RunnableLock)
        at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3650)
        at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3287)
        at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2389)
        at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2353)
        at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2219)
        at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:466)
        at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:289)
        at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:461)
        at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
        at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:106)
        at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:153)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:106)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:363)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:176)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:497)
        at org.eclipse.equinox.launcher.Main.basicRun(Main.java:436)
        at org.eclipse.equinox.launcher.Main.run(Main.java:1162)
        at org.eclipse.equinox.launcher.Main.main(Main.java:1137)
Comment 1 Mik Kersten CLA 2007-05-24 03:04:13 EDT
Yes, reactivating a task can trigger JDT and other activation.  But I think that it is required given the rule that the workbench should be restored to the state that it was left in when closed.  If we don't re-activate the task we are forcing the user to figure out what they were last doing when they closed.  Also, if the user wants a faster startup they can deactivate the task before shutdown (although that's not a great answer).  
Comment 2 Eugene Kuleshov CLA 2007-05-24 03:09:47 EDT
Mik, the ContextManager.activateContext() call in the shown stack trace should not be happening from the UI thread. So, workbench window won't go gray for several minutes. So, please reconsider priority of this issue.
Comment 3 Mik Kersten CLA 2007-05-24 14:08:56 EDT
Sounds good, took task activation and deactivation out of the UI thread.  After today's dev build comes out let me know if you see any change in the performance profile or startup/activation.
Comment 4 Mik Kersten CLA 2007-05-24 14:09:00 EDT
Created attachment 68626 [details]
mylar/context/zip
Comment 5 Eugene Kuleshov CLA 2007-05-24 14:43:51 EDT
Mik, your change to wrap activation into PlatformUI.getWorkbench().getDisplay().asyncExec(...); don't move execution out of the UI thread. From the javadoc of that method: Causes the run() method of the runnable to be invoked by the user-interface thread at the next reasonable opportunity.

I you probably should use a background job instead.
Comment 6 Mik Kersten CLA 2007-05-24 15:46:04 EDT
Argh, I did this too rushed and made it asynchronous in the UI thread instead of taking it out of the UI thread as expected.  The UI is intended to effectively block during task activation, so I'm not planning on making it run in a background thread and instead we can look at optimizing task activation times since no specific optimization has been done (beyond the editor memento work).
Comment 7 Mik Kersten CLA 2007-05-24 15:46:27 EDT
Btw, I removed those useless async execs.
Comment 8 Mik Kersten CLA 2007-05-24 15:46:47 EDT
And thanks for catching this mistake.
Comment 9 Eugene Kuleshov CLA 2007-05-24 16:06:26 EDT
 (In reply to comment #6)
> The UI is intended to effectively block during task activation, so I'm not planning on making it run in a
> background thread and instead we can look at optimizing task activation times
> since no specific optimization has been done (beyond the editor memento work).

Hmm. I would agree that UI need to be blocked when editors are being restored, but stuff that loading context and kicking JDT activation could happens in the background job. There are plenty activities that user can do in the ide during that time. I.e. review and update from sync view or browse trough task list.
Comment 10 C. Thompson CLA 2013-05-17 14:38:18 EDT
Should this be closed? from the comments it seems to have been completed.
Comment 11 Eclipse Webmaster CLA 2022-11-15 11:45:08 EST
Mylyn has been restructured, and our issue tracking has moved to GitHub [1].

We are closing ~14K Bugzilla issues to give the new team a fresh start. If you feel that this issue is still relevant, please create a new one on GitHub.

[1] https://github.com/orgs/eclipse-mylyn