Bug 390329 - UIJob is scheduled but not executed on UI Thread
Summary: UIJob is scheduled but not executed on UI Thread
Status: NEW
Alias: None
Product: RAP
Classification: RT
Component: RWT (show other bugs)
Version: 1.5   Edit
Hardware: Macintosh Mac OS X
: P3 normal with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-25 08:45 EDT by Svend-Anjes Pahl CLA
Modified: 2013-06-22 09:40 EDT (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Svend-Anjes Pahl CLA 2012-09-25 08:45:54 EDT
I've noticed a strange behavior using the UIJob on Eclipse 4.2 (Build id: 20120614-1722) with RAP 1.5. There are multiple jobs containing the same SchedulingRule marking the jobs as conflicting, therefore only one job is executed at the same time. After a few jobs are executed the execution stops even though there are waiting jobs left. I've enabled tracing and added a JobChangeListener to the JobManager logging the scheduling process.

14:06:09.377-[Thread[UIThread [propvt9tkkc7vn1v903t09dx],6,main]]Scheduling job: Job(13)
18561 [UIThread [propvt9tkkc7vn1v903t09dx]] DEBUG MapView  - scheduled Job(13)
18561 [Worker-1] DEBUG MapView  - aboutToRun Job(12)
18561 [Worker-1] DEBUG MapView  - running Job(12)
14:06:09.378-[Thread[Worker-0,5,main]]worker sleeping for: 60000ms
14:06:09.378-[Thread[Worker-1,5,main]]worker sleeping for: 60000ms
18562 [UIThread [propvt9tkkc7vn1v903t09dx]] DEBUG MapView  - execute Job(12)
18634 [UIThread [propvt9tkkc7vn1v903t09dx]] DEBUG MapView  - Job(12) finished after 72 ms
14:06:09.450-[Thread[UIThread [propvt9tkkc7vn1v903t09dx],6,main]]Ending job: Job(12)
18634 [UIThread [propvt9tkkc7vn1v903t09dx]] DEBUG MapView  - done Job(12)
14:06:09.450-[Thread[Worker-0,5,main]]Starting job: Job(13)
18634 [Worker-0] DEBUG MapView  - aboutToRun Job(13)
18635 [Worker-0] DEBUG MapView  - running Job(13)
14:06:09.451-[Thread[Worker-0,5,main]]worker sleeping for: 60000ms
14:07:09.377-[Thread[Worker-1,5,main]]worker sleeping for: 60000ms
14:07:09.450-[Thread[Worker-0,5,main]]worker sleeping for: 60000ms

The JobChangeListener is notified that the job is running but the runInUIThread method of the job isn't executed (The first command in the method is the "execute Job" log message). After an arbitrary ui event occurs the job is executed successfully. 

---ui event---
112822 [UIThread [propvt9tkkc7vn1v903t09dx]] DEBUG MapView  - execute Job(13)
112952 [UIThread [propvt9tkkc7vn1v903t09dx]] DEBUG MapView  - Job(13) finished after 129 ms
14:07:43.768-[Thread[UIThread [propvt9tkkc7vn1v903t09dx],6,main]]Ending job: Job(13)
112952 [UIThread [propvt9tkkc7vn1v903t09dx]] DEBUG MapView  - done Job(13)
Comment 1 Paul Webster CLA 2012-09-25 08:55:06 EDT
org.eclipse.ui.progress.UIJob runs the contents of the job in a display.asyncExec(*).  If there are OS level UI events happening then any newly added asyncExec(*) won't be run ... until the next OS event (key press, mouse move, paint request, etc).

PW
Comment 2 John Arthorne CLA 2012-09-25 14:19:20 EDT
Paul, doesn't the UI run the event loop when idle? Or does readAndDispatch not wakeup when deferred events are scheduled?
Comment 3 Paul Webster CLA 2012-09-25 14:37:18 EDT
Bogdan, I was wondering if there's any API for this case:  The event loop is  completely idle, and someone posts an asyncExec(*).  Right now it just goes into the queue until the next OS event wakes up the event loop, but is there a way to post the asyncExec(*) and tell the event loop "wake up and check your queues"

PW
Comment 4 Szymon Ptaszkiewicz CLA 2013-06-21 11:48:04 EDT
There are some limitations regarding using syncExec and asyncExec with RAP. See the last point here: http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.rap.help%2Fhelp%2Fhtml%2Frwt%2Fdifferences.html

I think that in pure SWT there should be no such problem since the UI thread is waken up to process deferred events (see the implementation of org.eclipse.swt.widgets.Synchronizer.addLast(RunnableLock)).
Comment 5 Szymon Ptaszkiewicz CLA 2013-06-21 11:50:09 EDT
Moving to the RAP team for comment.
Comment 6 Ivan Furnadjiev CLA 2013-06-22 09:40:36 EDT
If you reschedule a job from itself or another job it's possible to run in a situation where the request is already processed (finished) when it's time to execute the job. In this case the job will be executed with the next request as you already mentioned. This is a know limitation in RAP. See also comments in bug 266832 after comment #24.