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

Bug 313899

Summary: [Progress] Every user-job causes a busy cursor to be shown for a minimum of 250ms
Product: [Eclipse Project] Platform Reporter: Markus Schorn <mschorn.eclipse>
Component: UIAssignee: Prakash Rangaraj <prakash>
Status: VERIFIED FIXED QA Contact: Prakash Rangaraj <prakash>
Severity: normal    
Priority: P3 CC: bokowski, daniel_megert, eclipse, jamesblackburn+eclipse, john.arthorne, mober.at+eclipse, prakash, wb-rel, yevshif
Version: 3.6   
Target Milestone: 3.7 M6   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Bug Depends on:    
Bug Blocks: 339311, 440304    
Attachments:
Description Flags
Stops the busy cursor when the job is done.
none
Improved patch none

Description Markus Schorn CLA 2010-05-21 07:35:53 EDT
When I run a user job ('job.setUser(true)') the UI shows a busy cursor for 250ms, even if the job does not do anything. This becomes apparent when I schedule 20 user-jobs that complete immediately, then the UI shows a busy-cursor for 5 seconds.

My expectation is, that the busy cursor is at the maximum shown as long as the job is actually running.


Here is a test-case:

public class UIJobTest extends TestCase {
	
	public void testUIJob() {
		int count= 20;
		
		assertTrue(runEventLoop() < 1000);
		for (int i=0; i<count; i++) {
			Job j= new Job("dummy") {
				@Override
				protected IStatus run(IProgressMonitor monitor) {
					return Status.OK_STATUS;
				}
			};
			j.setUser(true);
			j.schedule();
		}
		long time = runEventLoop();
		assertTrue("Main thread busy for " + time + 
                           " ms when runnning " + count + " user jobs.", 
                           time < 1000);
	}

	private long runEventLoop() {
		long startTime= System.currentTimeMillis();
		
		Display disp= Display.getCurrent();
		assertNotNull(disp);
		while(disp.readAndDispatch()) {
		}
		
		return System.currentTimeMillis() - startTime;
	}			
}
Comment 1 Markus Schorn CLA 2010-05-21 08:13:13 EDT
Created attachment 169491 [details]
Stops the busy cursor when the job is done.
Comment 2 Markus Schorn CLA 2010-05-21 09:01:32 EDT
Created attachment 169496 [details]
Improved patch

The job change listener needs to be removed from the job.
Comment 3 Martin Oberhuber CLA 2011-01-26 09:56:33 EST
Ping, does anybody listen here?

We provided a patch for this issue on 21-May and would appreciate a comment.
Comment 4 John Arthorne CLA 2011-01-26 14:47:02 EST
+1, this patch looks good to me. It's a simple and safe fix. The worst case is that someone notifies the UI thread and we don't sleep long enough, but that was a problem in the old code too. In this case you would just get the progress dialog a bit earlier.

Prakash, if you can't take this for M6, let me know and I'll take it.
Comment 5 Prakash Rangaraj CLA 2011-01-27 03:44:50 EST
Sorry, this slipped off my radar. Will target for 3.7
Comment 6 Prakash Rangaraj CLA 2011-02-14 05:01:46 EST
Patch is good. Released to HEAD
Comment 7 Martin Oberhuber CLA 2011-03-08 15:27:59 EST
Could a backport to 3.6.2+ be considered? It's not top important for us but nice to have.
Comment 8 Prakash Rangaraj CLA 2011-03-09 00:03:03 EST
Verified in I20110307-2110