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

Bug 283596

Summary: UIJob can be scheduled, but never run
Product: [RT] RAP Reporter: Ian Bull <irbull>
Component: WorkbenchAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P1    
Version: 1.0   
Target Milestone: 1.3 M2   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Demo
none
Proposed patch
none
Mini-app to that demonstrates the leak
none
Bugfix none

Description Ian Bull CLA 2009-07-15 13:33:52 EDT
UIJob can schedule an async thread  (on the display), but if a user navigates away from the page before the thread runs, the job will remaining in a running state indefinitely.

This is because UIJob returns Job.ASYNC_FINISH to indicate that this is an Async job, but if the actual asynchronous thread never runs, then done() is never called, and the job is never moved from the running state.

This can be seen by using the following demo (that Benny put together).  Simply start the application, and before it entirely loads hit the browser top button (or navigate away from the page).  The UIJob itself runs, but the async thread it schedules never runs.
Comment 1 Ian Bull CLA 2009-07-15 13:34:54 EDT
Created attachment 141679 [details]
Demo
Comment 2 Ian Bull CLA 2009-07-15 18:13:16 EDT
Created attachment 141722 [details]
Proposed patch

This patch runs each waiting async thread before the UIThread ends.  Most of these threads will likely fail, but at least they get a chance to run (and clean up).  In particular, the UIJob will get a chance to run it's finally block and shut down the job.
Comment 3 Rüdiger Herrmann CLA 2009-09-16 05:50:09 EDT
Created attachment 147289 [details]
Mini-app to that demonstrates the leak

I could not find a memory leak with the previously attached demo app.
This is a modified version of the initial demo app. 
Note the extra thread that schedules the Job which itself schedules the UIJob and causes the UIJob to run without a session context.
Comment 4 Rüdiger Herrmann CLA 2009-09-16 05:55:48 EDT
Created attachment 147290 [details]
Bugfix

This patch fixes the memory leak. The JobManagerAdapter now recognizes UIJobs and binds them to the session/display. By doing so, it is ensured that this binding is release if the session terminates.
Previously the Job was attached to the defaultProgressMonitor (application scope) and never unbound.
Comment 5 Rüdiger Herrmann CLA 2009-09-16 06:01:20 EDT
Thanks Ian for pointing at this!
The attached patch is in CVS HEAD.
Please re-open if the proplem persists.