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

Bug 252446

Summary: SubMonitor.newChild passes zero ticks to child
Product: [Eclipse Project] Equinox Reporter: Susan McCourt <susan>
Component: ComponentsAssignee: John Arthorne <john.arthorne>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: john.arthorne, ob1.eclipse, pascal, sxenos, tjwatson
Version: 3.5   
Target Milestone: 3.5 M5   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
sample command handler that uses submonitors
none
Potential fix
none
Patch with a JUnit test none

Description Susan McCourt CLA 2008-10-28 13:32:34 EDT
When you choose Help->Check for Updates... or Help->Install New Software..., the progress dialog sits at 0% for a long time.  The details show that the ganymede content.jar is being downloaded, but the top level progress is not updated until the repo is loaded.

Need to review why the top level progress is not updated and at a minimum show some progress right away or else it looks like we are hung.

I'd like to do something for M3 as this is a bad first impression for the new workflows.
Comment 1 Susan McCourt CLA 2008-10-28 13:44:27 EDT
quick glance at the progress monitor code - everything seems to be handled properly all the way down, although the UI code that sets up the monitor uses N for number of monitor ticks where N is the number of repos being loaded.  Possible rounding error?  Many clients use N*100, etc. 

Will debug after test pass.
Comment 2 Susan McCourt CLA 2008-10-28 16:50:31 EDT
marking M3, with only two repos in the repo list and nothing ever loaded (which is the state of a fresh SDK), it can make you think you are hung while the ganymede content.jar downloads.
Comment 3 Pascal Rapicault CLA 2008-10-29 12:20:28 EDT
Changing the target milestone as we are not contributing to M3. However please make sure these bugs are addressed early in M4 or tomorrow Testing Thursday for the test related ones.
Comment 4 Susan McCourt CLA 2008-12-08 14:42:10 EST
For some reason, I expected that a parent monitor's ticks would be updated appropriately if a submonitor were being updated.  I wrote a snippet to play with this and now realize that the updating of the parent is atomic.  The submonitor's progress won't affect the parent monitor's progress until the submonitor is done.

From a p2 point of view, it means that our progress can sit at 0 for a long time while the first repo is loading, even though the details of the download can be seen progressing in the details view or progress view.  If there are lots of repos, you'll see progress updating after each repo loads.  But if you only have one repo, you sit at 0 until the very end when you update to 100%.

The only thing I can think of to do here is to indicate a little bit of progress before the download starts.  The UI code could do this, or even IMetadataRepository.loadRepository(URI, IProgressMonitor) could work the monitor before passing the rest of it down.
Comment 5 Susan McCourt CLA 2008-12-08 14:44:07 EST
Another idea might be for the UI to special case when only one repo will be loaded, and rather than creating a submonitor, it could pass the monitor directly.  At least then the load of one repo could proceed in the top level progress.  Not sure if this helps or not, as it depends on the pattern used all the way down the call chain.
Comment 6 John Arthorne CLA 2008-12-08 17:16:40 EST
I mentioned this to Susan offline, but this isn't the expected behaviour of SubMonitor. It should be sending units of work to the parent monitor as work is being done.
Comment 7 Susan McCourt CLA 2008-12-08 17:51:11 EST
Created attachment 119846 [details]
sample command handler that uses submonitors

Ok, so it *should* be working the way I had assumed.

John said he could take a look, but I can open a platform bug if this is anything other than me making a dumb mistake.

Attached is a simple command handler that starts a job and runs a submonitor.  I had hoped to see the parent monitor tick for every unit of work.  It only updates when the child monitor completes.  

I tried to debug this and I don't see how using SubMonitor.newChild would ever cause the right thing to happen, because it creates the new child using 0 for "availableToChildren" and that in turn causes no work to ever be consumed in this child.
Comment 8 John Arthorne CLA 2008-12-09 18:19:01 EST
This looks like a bug in SubMonitor to me. SubMonitor.newChild always instantiates the child monitor with 0 units of work available.
Comment 9 John Arthorne CLA 2008-12-09 18:20:25 EST
Created attachment 119985 [details]
Potential fix

With this patch the progress in Susan's example runs smoothly. I haven't run further tests on it yet.
Comment 10 Thomas Watson CLA 2008-12-10 09:28:31 EST
Assigning to John to release for M5.
Comment 11 John Arthorne CLA 2008-12-10 09:31:08 EST
Oleg, I'd appreciate a second look from you since you've worked with SubMonitor in the past. It really surprised me that there would be a bug like this and I want to make sure I'm not missing something.
Comment 12 Oleg Besedin CLA 2008-12-10 12:51:10 EST
Created attachment 120084 [details]
Patch with a JUnit test

Yes, this seems like a bug. John's fix look good.

I added JUnit and updated copyrights.
Comment 13 John Arthorne CLA 2008-12-12 15:37:32 EST
Fix and test released.
Comment 14 Stefan Xenos CLA 2015-11-13 15:56:24 EST
Reopening.

This was not a bug in SubMonitor -- it was a bug in whatever code invoked newChild but failed to invoke setWorkRemaining or beginTask to allocate ticks.

The fix is making it harder to detect this class of bugs using the new progress error detection.
Comment 15 Stefan Xenos CLA 2015-11-13 15:57:18 EST
Changing resolution to WONTFIX. I plan to revert the fix with the patch to bug 482062.