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

Bug 65415

Summary: [Progress] Animation error refreshing branches using RC1
Product: [Eclipse Project] Platform Reporter: Olivier Thomann <Olivier_Thomann>
Component: CVSAssignee: Michael Valenta <Michael.Valenta>
Status: VERIFIED FIXED QA Contact:
Severity: critical    
Priority: P2 CC: gunnar, jean-michel_lemieux, john.arthorne, lphillips, michaelvanmeekeren, Tod_Creasey
Version: 3.0   
Target Milestone: 3.0 RC2   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Bug Depends on: 65950, 65951    
Bug Blocks:    
Attachments:
Description Flags
Log file showing various errors (out of handles, NPE, etc) none

Description Olivier Thomann CLA 2004-06-02 14:29:13 EDT
I got this exception using RC1 during refresh branches.

java.lang.NullPointerException
at
org.eclipse.ui.internal.progress.AnimationManager$1.runInUIThread(AnimationManager.java:70)
at org.eclipse.ui.progress.UIJob$1.run(UIJob.java:87)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:106)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:2693)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2385)
at org.eclipse.jface.window.Window.runEventLoop(Window.java:668)
at org.eclipse.jface.window.Window.open(Window.java:648)
at
org.eclipse.team.internal.ccvs.ui.repo.RefreshRemoteProjectWizard.execute(RefreshRemoteProjectWizard.java:68)
at
org.eclipse.team.internal.ccvs.ui.repo.RefreshTagsAction.execute(RefreshTagsAction.java:26)
at org.eclipse.team.internal.ccvs.ui.actions.CVSAction.run(CVSAction.java:70)
at org.eclipse.ui.actions.ActionDelegate.runWithEvent(ActionDelegate.java:71)
at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:266)
at
org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:915)
at
org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:866)
at
org.eclipse.jface.action.ActionContributionItem$7.handleEvent(ActionContributionItem.java:785)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2716)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2382)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1363)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1334)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:253)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:141)
at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:96)
at
org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:334)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:273)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:128)
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:324)
at org.eclipse.core.launcher.Main.basicRun(Main.java:185)
at org.eclipse.core.launcher.Main.run(Main.java:638)
at org.eclipse.core.launcher.Main.main(Main.java:622)


STEPS TO REPRODUCE:
1) Start a fresh workspace
2) Create a CVS location to dev.eclipse.org pserver anonymous to /home/eclipse
3) Select branches and run Refresh Branches...
4) Select all projects and do not use any working set
5) Clikc on Finish.
6) At the end of the process, you will get this error.
Comment 1 Jean-Michel Lemieux CLA 2004-06-02 15:31:33 EDT
moving to UI.
AnimationManager has a null progress monitor and isn't checking.  I'm not sure
how this is spec'd but you should maybe protect against this case. BTW, the
steps will always dupe the problem.

public IStatus runInUIThread(IProgressMonitor monitor) {
				if(monitor.isCanceled())  <===
					return Status.CANCEL_STATUS;
				animationProcessor.animationStarted();
Comment 2 Tod Creasey CLA 2004-06-04 11:31:30 EDT
Should address for RC2
Comment 3 Tod Creasey CLA 2004-06-04 16:53:47 EDT
The problem we are having is that it is possible for the monitor sent to a job 
to be null. I have checked progressFor() in ProgressManager and I could not 
have sent that without a ClassCastException.

Note that the worker count will hit 300 easily with this operation and that 
the progress region gets updated constantly as a result.

Moving to Core as this is a problem the progressMonitor caching.
Comment 4 John Arthorne CLA 2004-06-04 18:09:48 EDT
Did it not occur to anyone that 300 simultaneous worker threads was a sign of
bad things happening?

Here is what happens:

The refresh wizard has a loop to refresh each project in the repository:

for (int i = 0; i < selectedFolders.length; i++) {
  ICVSRemoteResource resource = selectedFolders[i];
  if (resource instanceof ICVSFolder) {
    manager.refreshDefinedTags((ICVSFolder)resource, true /* replace */, true, 
      Policy.subMonitorFor(monitor, 100));
  }
}

After each project is refreshed, a syncExec is fired to refresh the Repositories
view. Each node in the repository view does the fetching of its children using
IProgressService.run(true, true, runnable).

Each invocation of IProgressService.run causes a UI job to be scheduled that is
responsible for opening a progress dialog
(ProgressManager.scheduleProgressMonitorJob). This job looks like this:

public IStatus runInUIThread(IProgressMonitor monitor) {
  setUserInterfaceActive(true);
  if (ProgressManagerUtil.rescheduleIfModalShellOpen(this))
    return Status.CANCEL_STATUS;
  dialog.open();
  return Status.OK_STATUS;
}

The interesting line is the one that reschedules the job if there is a modal
shell open. Of course, there *is* a modal shell open in this example: the
refresh branches dialog.

When I tried this, there were over 1,600 of these "open progress dialog" jobs
scheduled (number of projects times number of children to refresh in repo view).
Every one of them is repeatedly rescheduling itself in a loop for the duration
of the refresh operation. I did see the NPE mentioned above, but I also saw
dozens of other errors in the progress view code (I will attach a log). I
suspect this is causing a complete overload that is revealing timing bugs all
over the place.

Some possible areas of improvement:

 - The CVS refresh operation could just fire a single syncExec at the end of the
refresh to update the repositories view, rather than one refresh per project.
 - IProgressService.run should use a singleton job to open the progress dialog,
to avoid thousands of jobs from being stuck in this rescheduling loop.

I will leave this bug in core until the NPE is understood, but this is a serious
bug in the progress manager code as well.
Comment 5 John Arthorne CLA 2004-06-04 18:10:31 EDT
Created attachment 11622 [details]
Log file showing various errors (out of handles, NPE, etc)
Comment 6 Tod Creasey CLA 2004-06-07 08:11:08 EDT
Added Bug 65950 and Bug 65951 for the issues John is talking about
Comment 7 Tod Creasey CLA 2004-06-10 14:56:52 EDT
*** Bug 66553 has been marked as a duplicate of this bug. ***
Comment 8 John Arthorne CLA 2004-06-10 16:21:34 EDT
The NullPointerException no longer occurs in build I20040609. I suspect the
massive flooding of jobs described in comment #4 was causing all kinds of
problems (see my attached log), of which the NPE was just one. The
ProgressManager code has been improved to no longer repeatedly reschedule the
jobs responsible for opening the progress dialog.

However, I will move this bug to CVS because this test case still causes far
more work than necessary. Steps:

1) Create an anonymous connection to dev.eclipse.org
2) Expand HEAD
3) Refresh Branches
4) Select All
5) Finish

You can see the repository view in the background flashing madly as the
operation progresses. This should be fixed to refresh the tree only at the end
of the operation. Since the operation runs in a modal dialog, the user can't
browse any of the results until the entire refresh completes anyway, so these
refreshes are all wasted.
Comment 9 Michael Valenta CLA 2004-06-10 16:51:27 EDT
Fixed
Comment 10 Tod Creasey CLA 2004-06-11 08:12:56 EDT
*** Bug 66621 has been marked as a duplicate of this bug. ***
Comment 11 Tod Creasey CLA 2004-06-22 13:13:21 EDT
*** Bug 68185 has been marked as a duplicate of this bug. ***