Home » Eclipse Projects » Remote Application Platform (RAP) » Current UI update is always triggered by the next UI event
Current UI update is always triggered by the next UI event [message #552125] |
Tue, 10 August 2010 23:55 |
Owen Messages: 17 Registered: May 2010 |
Junior Member |
|
|
Hi,
I have a background job to load stuff from the database and update the TreeViewer. The scenario of the background job is
1. a TreeItem is expanded
2. loads data from DB
3. updated the UI by populating the children of the TreeItem using Display.async
It is pretty much similar to the background job example from here http://wiki.eclipse.org/RAP/FAQ#How_to_update_the_UI_from_a_ background_thread_using_Jobs.3F
In Safari and Opera, the UI is not refreshed (#3) until the next UI event comes, e.g., clicking any other widget to trigger the next UI event. In the debug mode, I saw that the body of the Runnable from Display.async is not executed until the next event comes. Even if I manually execute Display.readAndDispatch, it fails to execute the current UI update. The current UI update is always triggered by the next UI event. Here is what the code looks like:
private class ResourceLoadingJob extends Job {
...
private void loadResource() {
// running get children in session;
UICallBack.runNonUIThreadWithFakeContext(display, new Runnable() {
@Override
public void run() {
// load the resource with session on
}
});
display.asyncExec(new Runnable() {
@Override
public void run() {
try {
if (!treeViewer.getControl().isDisposed()) {
treeViewer.refresh(resource, true);
}
} catch (Exception e) {
// handle exception
}
}
});
This issue doesn't happen on other browsers. I am wondering how can I fix it? It looks like a defect in RAP's UI update thread which sleeps and forgets about the UI update.
Thanks,
Owen
|
|
|
Re: Current UI update is always triggered by the next UI event [message #552172 is a reply to message #552125] |
Wed, 11 August 2010 07:13 |
Ivan Furnadjiev Messages: 2429 Registered: July 2009 Location: Sofia, Bulgaria |
Senior Member |
|
|
Hi Owen,
what is the RAP version used? Did you try to activate the UICallback
manually? Does your code work in Firefox and IE, and you have problems
only with Safari and Opera?
Best,
Ivan
On 08/11/2010 2:55 AM, Owen wrote:
> Hi,
>
> I have a background job to load stuff from the database and update the
> TreeViewer. The scenario of the background job is
>
> 1. a TreeItem is expanded
> 2. loads data from DB
> 3. updated the UI by populating the children of the TreeItem using
> Display.async
>
> It is pretty much similar to the background job example from here
> http://wiki.eclipse.org/RAP/FAQ#How_to_update_the_UI_from_a_
> background_thread_using_Jobs.3F
>
> In Safari and Opera, the UI is not refreshed (#3) until the next UI
> event comes, e.g., clicking any other widget to trigger the next UI
> event. In the debug mode, I saw that the body of the Runnable from
> Display.async is not executed until the next event comes. Even if I
> manually execute Display.readAndDispatch, it fails to execute the
> current UI update. The current UI update is always triggered by the
> next UI event. Here is what the code looks like:
>
> private class ResourceLoadingJob extends Job {
>
> ..
>
> private void loadResource() {
> // running get children in session;
> UICallBack.runNonUIThreadWithFakeContext(display, new Runnable() {
> @Override
> public void run() {
> // load the resource with session on
> }
> });
>
> display.asyncExec(new Runnable() {
> @Override
> public void run() {
> try {
> if (!treeViewer.getControl().isDisposed()) {
> treeViewer.refresh(resource, true);
> }
> } catch (Exception e) {
> // handle exception
> }
> }
> });
>
> This issue doesn't happen on other browsers. I am wondering how can I
> fix it? It looks like a defect in RAP's UI update thread which sleeps
> and forgets about the UI update.
>
> Thanks,
> Owen
|
|
|
Re: Current UI update is always triggered by the next UI event [message #552174 is a reply to message #552172] |
Wed, 11 August 2010 07:40 |
Owen Messages: 17 Registered: May 2010 |
Junior Member |
|
|
Hi Ivan,
I am using RAP 1.3. I didn't manually invoke UICallback but I am using Display.async. From the FAQ, isn't it that I either update the UI with the Display API ( http://wiki.eclipse.org/RAP/FAQ#How_to_update_the_UI_from_a_ background_thread_using_Jobs.3F) or use UICallback to activate the UI ( http://wiki.eclipse.org/RAP/FAQ#How_to_update_the_UI_from_a_ background_thread).
Yeah, the problem is not obvious in Firefox. Not sure about IE. But it happens on Safari 5 and Opera 10.
Is there anyway I can fix this?
Thanks,
Owen
Ivan Furnadjiev wrote on Wed, 11 August 2010 03:13 | Hi Owen,
what is the RAP version used? Did you try to activate the UICallback
manually? Does your code work in Firefox and IE, and you have problems
only with Safari and Opera?
Best,
Ivan
On 08/11/2010 2:55 AM, Owen wrote:
> Hi,
>
> I have a background job to load stuff from the database and update the
> TreeViewer. The scenario of the background job is
>
> 1. a TreeItem is expanded
> 2. loads data from DB
> 3. updated the UI by populating the children of the TreeItem using
> Display.async
>
> It is pretty much similar to the background job example from here
> http://wiki.eclipse.org/RAP/FAQ#How_to_update_the_UI_from_a_
> background_thread_using_Jobs.3F
>
> In Safari and Opera, the UI is not refreshed (#3) until the next UI
> event comes, e.g., clicking any other widget to trigger the next UI
> event. In the debug mode, I saw that the body of the Runnable from
> Display.async is not executed until the next event comes. Even if I
> manually execute Display.readAndDispatch, it fails to execute the
> current UI update. The current UI update is always triggered by the
> next UI event. Here is what the code looks like:
>
> private class ResourceLoadingJob extends Job {
>
> ..
>
> private void loadResource() {
> // running get children in session;
> UICallBack.runNonUIThreadWithFakeContext(display, new Runnable() {
> @Override
> public void run() {
> // load the resource with session on
> }
> });
>
> display.asyncExec(new Runnable() {
> @Override
> public void run() {
> try {
> if (!treeViewer.getControl().isDisposed()) {
> treeViewer.refresh(resource, true);
> }
> } catch (Exception e) {
> // handle exception
> }
> }
> });
>
> This issue doesn't happen on other browsers. I am wondering how can I
> fix it? It looks like a defect in RAP's UI update thread which sleeps
> and forgets about the UI update.
>
> Thanks,
> Owen
|
|
|
|
Re: Current UI update is always triggered by the next UI event [message #552181 is a reply to message #552174] |
Wed, 11 August 2010 07:50 |
Ivan Furnadjiev Messages: 2429 Registered: July 2009 Location: Sofia, Bulgaria |
Senior Member |
|
|
Hi Owen,
please file a bugzilla with a self running snippet/project to reproduce it.
Best,
Ivan
On 08/11/2010 10:40 AM, Owen wrote:
> Hi Ivan,
>
> I am using RAP 1.3. I didn't manually invoke UICallback but I am using
> Display.async. From the FAQ, isn't it that I either update the UI with
> the Display API
> ( http://wiki.eclipse.org/RAP/FAQ#How_to_update_the_UI_from_a_ background_thread_using_Jobs.3F)
> or use UICallback to activate the UI
> ( http://wiki.eclipse.org/RAP/FAQ#How_to_update_the_UI_from_a_ background_thread).
>
> Yeah, the problem is not obvious in Firefox. Not sure about IE. But it
> happens on Safari 5 and Opera 10.
>
> Is there anyway I can fix this?
>
> Thanks,
> Owen
>
> Ivan Furnadjiev wrote on Wed, 11 August 2010 03:13
>> Hi Owen,
>>
>> what is the RAP version used? Did you try to activate the UICallback
>> manually? Does your code work in Firefox and IE, and you have
>> problems only with Safari and Opera?
>>
>> Best,
>> Ivan
>>
>> On 08/11/2010 2:55 AM, Owen wrote:
>> > Hi,
>> >
>> > I have a background job to load stuff from the database and update
>> the > TreeViewer. The scenario of the background job is
>> >
>> > 1. a TreeItem is expanded
>> > 2. loads data from DB
>> > 3. updated the UI by populating the children of the TreeItem using
>> > Display.async
>> >
>> > It is pretty much similar to the background job example from here
>> > http://wiki.eclipse.org/RAP/FAQ#How_to_update_the_UI_from_a_ >
>> background_thread_using_Jobs.3F
>> >
>> > In Safari and Opera, the UI is not refreshed (#3) until the next UI
>> > event comes, e.g., clicking any other widget to trigger the next UI
>> > event. In the debug mode, I saw that the body of the Runnable from
>> > Display.async is not executed until the next event comes. Even if I
>> > manually execute Display.readAndDispatch, it fails to execute the >
>> current UI update. The current UI update is always triggered by the >
>> next UI event. Here is what the code looks like:
>> >
>> > private class ResourceLoadingJob extends Job {
>> >
>> > ..
>> >
>> > private void loadResource() {
>> > // running get children in session;
>> > UICallBack.runNonUIThreadWithFakeContext(display, new Runnable() {
>> > @Override
>> > public void run() {
>> > // load the resource with session on
>> > }
>> > });
>> >
>> > display.asyncExec(new Runnable() {
>> > @Override
>> > public void run() {
>> > try {
>> > if (!treeViewer.getControl().isDisposed()) {
>> > treeViewer.refresh(resource, true);
>> > }
>> > } catch (Exception e) {
>> > // handle exception
>> > }
>> > }
>> > });
>> >
>> > This issue doesn't happen on other browsers. I am wondering how can
>> I > fix it? It looks like a defect in RAP's UI update thread which
>> sleeps > and forgets about the UI update.
>> >
>> > Thanks,
>> > Owen
>
>
|
|
|
Re: Current UI update is always triggered by the next UI event [message #552320 is a reply to message #552174] |
Wed, 11 August 2010 17:30 |
Rüdiger Herrmann Messages: 581 Registered: July 2009 |
Senior Member |
|
|
Owen,
just to clarify: if you are *not* using Jobs you will have to
activate/deactivate the UICallBack yourself.
Display#asyncExec() just puts your code in a list that gets processed
when readAndDipach() is called the next time. The UICallBack takes care
that the client is informed that there is code to be executed on the UI
thread.
HTH
Rüdiger
On 11.08.2010 09:40, Owen wrote:
> Hi Ivan,
>
> I am using RAP 1.3. I didn't manually invoke UICallback but I am using
> Display.async. From the FAQ, isn't it that I either update the UI with
> the Display API
> ( http://wiki.eclipse.org/RAP/FAQ#How_to_update_the_UI_from_a_ background_thread_using_Jobs.3F)
> or use UICallback to activate the UI
> ( http://wiki.eclipse.org/RAP/FAQ#How_to_update_the_UI_from_a_ background_thread).
>
> Yeah, the problem is not obvious in Firefox. Not sure about IE. But it
> happens on Safari 5 and Opera 10.
>
> Is there anyway I can fix this?
>
> Thanks,
> Owen
>
> Ivan Furnadjiev wrote on Wed, 11 August 2010 03:13
>> Hi Owen,
>>
>> what is the RAP version used? Did you try to activate the UICallback
>> manually? Does your code work in Firefox and IE, and you have problems
>> only with Safari and Opera?
>>
>> Best,
>> Ivan
>>
>> On 08/11/2010 2:55 AM, Owen wrote:
>> > Hi,
>> >
>> > I have a background job to load stuff from the database and update
>> the > TreeViewer. The scenario of the background job is
>> >
>> > 1. a TreeItem is expanded
>> > 2. loads data from DB
>> > 3. updated the UI by populating the children of the TreeItem using >
>> Display.async
>> >
>> > It is pretty much similar to the background job example from here >
>> http://wiki.eclipse.org/RAP/FAQ#How_to_update_the_UI_from_a_ >
>> background_thread_using_Jobs.3F
>> >
>> > In Safari and Opera, the UI is not refreshed (#3) until the next UI
>> > event comes, e.g., clicking any other widget to trigger the next UI
>> > event. In the debug mode, I saw that the body of the Runnable from >
>> Display.async is not executed until the next event comes. Even if I >
>> manually execute Display.readAndDispatch, it fails to execute the >
>> current UI update. The current UI update is always triggered by the >
>> next UI event. Here is what the code looks like:
>> >
>> > private class ResourceLoadingJob extends Job {
>> >
>> > ..
>> >
>> > private void loadResource() {
>> > // running get children in session;
>> > UICallBack.runNonUIThreadWithFakeContext(display, new Runnable() {
>> > @Override
>> > public void run() {
>> > // load the resource with session on
>> > }
>> > });
>> >
>> > display.asyncExec(new Runnable() {
>> > @Override
>> > public void run() {
>> > try {
>> > if (!treeViewer.getControl().isDisposed()) {
>> > treeViewer.refresh(resource, true);
>> > }
>> > } catch (Exception e) {
>> > // handle exception
>> > }
>> > }
>> > });
>> >
>> > This issue doesn't happen on other browsers. I am wondering how can
>> I > fix it? It looks like a defect in RAP's UI update thread which
>> sleeps > and forgets about the UI update.
>> >
>> > Thanks,
>> > Owen
>
>
--
Rüdiger Herrmann
http://eclipsesource.com
|
|
|
Re: Current UI update is always triggered by the next UI event [message #552326 is a reply to message #552320] |
Wed, 11 August 2010 18:04 |
Owen Messages: 17 Registered: May 2010 |
Junior Member |
|
|
Hi Rudiger,
Yes, I am using Job. But the Job is running on the background and it never ends (pretty much as a daemon). That's why I didn't activate with the UICallBack. Can I do something like that with Job in RAP? Or I have to switch to the Thread & UICallBack way as indicated in example?
Thanks,
Owen
Rüdiger Herrmann wrote on Wed, 11 August 2010 13:30 | Owen,
just to clarify: if you are *not* using Jobs you will have to
activate/deactivate the UICallBack yourself.
Display#asyncExec() just puts your code in a list that gets processed
when readAndDipach() is called the next time. The UICallBack takes care
that the client is informed that there is code to be executed on the UI
thread.
HTH
Rüdiger
On 11.08.2010 09:40, Owen wrote:
> Hi Ivan,
>
> I am using RAP 1.3. I didn't manually invoke UICallback but I am using
> Display.async. From the FAQ, isn't it that I either update the UI with
> the Display API
> ( http://wiki.eclipse.org/RAP/FAQ#How_to_update_the_UI_from_a_ background_thread_using_Jobs.3F)
> or use UICallback to activate the UI
> ( http://wiki.eclipse.org/RAP/FAQ#How_to_update_the_UI_from_a_ background_thread).
>
> Yeah, the problem is not obvious in Firefox. Not sure about IE. But it
> happens on Safari 5 and Opera 10.
>
> Is there anyway I can fix this?
>
> Thanks,
> Owen
>
> Ivan Furnadjiev wrote on Wed, 11 August 2010 03:13
>> Hi Owen,
>>
>> what is the RAP version used? Did you try to activate the UICallback
>> manually? Does your code work in Firefox and IE, and you have problems
>> only with Safari and Opera?
>>
>> Best,
>> Ivan
>>
>> On 08/11/2010 2:55 AM, Owen wrote:
>> > Hi,
>> >
>> > I have a background job to load stuff from the database and update
>> the > TreeViewer. The scenario of the background job is
>> >
>> > 1. a TreeItem is expanded
>> > 2. loads data from DB
>> > 3. updated the UI by populating the children of the TreeItem using >
>> Display.async
>> >
>> > It is pretty much similar to the background job example from here >
>> http://wiki.eclipse.org/RAP/FAQ#How_to_update_the_UI_from_a_ >
>> background_thread_using_Jobs.3F
>> >
>> > In Safari and Opera, the UI is not refreshed (#3) until the next UI
>> > event comes, e.g., clicking any other widget to trigger the next UI
>> > event. In the debug mode, I saw that the body of the Runnable from >
>> Display.async is not executed until the next event comes. Even if I >
>> manually execute Display.readAndDispatch, it fails to execute the >
>> current UI update. The current UI update is always triggered by the >
>> next UI event. Here is what the code looks like:
>> >
>> > private class ResourceLoadingJob extends Job {
>> >
>> > ..
>> >
>> > private void loadResource() {
>> > // running get children in session;
>> > UICallBack.runNonUIThreadWithFakeContext(display, new Runnable() {
>> > @Override
>> > public void run() {
>> > // load the resource with session on
>> > }
>> > });
>> >
>> > display.asyncExec(new Runnable() {
>> > @Override
>> > public void run() {
>> > try {
>> > if (!treeViewer.getControl().isDisposed()) {
>> > treeViewer.refresh(resource, true);
>> > }
>> > } catch (Exception e) {
>> > // handle exception
>> > }
>> > }
>> > });
>> >
>> > This issue doesn't happen on other browsers. I am wondering how can
>> I > fix it? It looks like a defect in RAP's UI update thread which
>> sleeps > and forgets about the UI update.
>> >
>> > Thanks,
>> > Owen
>
>
--
Rüdiger Herrmann
http://eclipsesource.com
|
|
|
|
Re: Current UI update is always triggered by the next UI event [message #552602 is a reply to message #552326] |
Thu, 12 August 2010 18:28 |
Rüdiger Herrmann Messages: 581 Registered: July 2009 |
Senior Member |
|
|
Owen,
for a Job to be able to "update" the UI it must be started from the UI
thread. The common pattern to reschedule jobs at their end with a
JobListener doesn't work in RAP.
The UICallBack (that is used by Jobs in RAP under the hood) must be
called from the UI thread in order to instruct the client that there is
a background thread that potentially calls Display#asyncExec().
If your code is free from such obstacles, you may have run into this bug:
315418: Progress Dialog will not automatically close during UICallback
https://bugs.eclipse.org/bugs/show_bug.cgi?id=315418
HTHJ
Rüdiger
On 11.08.2010 20:04, Owen wrote:
> Hi Rudiger,
>
> Yes, I am using Job. But the Job is running on the background and it
> never ends (pretty much as a daemon). That's why I didn't activate with
> the UICallBack. Can I do something like that with Job in RAP? Or I have
> to switch to the Thread & UICallBack way as indicated in example?
>
> Thanks,
> Owen
>
> Rüdiger Herrmann wrote on Wed, 11 August 2010 13:30
>> Owen,
>>
>> just to clarify: if you are *not* using Jobs you will have to
>> activate/deactivate the UICallBack yourself.
>> Display#asyncExec() just puts your code in a list that gets processed
>> when readAndDipach() is called the next time. The UICallBack takes
>> care that the client is informed that there is code to be executed on
>> the UI thread.
>>
>> HTH
>> Rüdiger
>>
>> On 11.08.2010 09:40, Owen wrote:
>> > Hi Ivan,
>> >
>> > I am using RAP 1.3. I didn't manually invoke UICallback but I am using
>> > Display.async. From the FAQ, isn't it that I either update the UI with
>> > the Display API
>> > ( http://wiki.eclipse.org/RAP/FAQ#How_to_update_the_UI_from_a_
>> background_thread_using_Jobs.3F)
>> > or use UICallback to activate the UI
>> > ( http://wiki.eclipse.org/RAP/FAQ#How_to_update_the_UI_from_a_
>> background_thread).
>> >
>> > Yeah, the problem is not obvious in Firefox. Not sure about IE. But it
>> > happens on Safari 5 and Opera 10.
>> >
>> > Is there anyway I can fix this?
>> >
>> > Thanks,
>> > Owen
>> >
>> > Ivan Furnadjiev wrote on Wed, 11 August 2010 03:13
>> >> Hi Owen,
>> >>
>> >> what is the RAP version used? Did you try to activate the UICallback
>> >> manually? Does your code work in Firefox and IE, and you have problems
>> >> only with Safari and Opera?
>> >>
>> >> Best,
>> >> Ivan
>> >>
>> >> On 08/11/2010 2:55 AM, Owen wrote:
>> >> > Hi,
>> >> >
>> >> > I have a background job to load stuff from the database and update
>> >> the > TreeViewer. The scenario of the background job is
>> >> >
>> >> > 1. a TreeItem is expanded
>> >> > 2. loads data from DB
>> >> > 3. updated the UI by populating the children of the TreeItem using >
>> >> Display.async
>> >> >
>> >> > It is pretty much similar to the background job example from here >
>> >> http://wiki.eclipse.org/RAP/FAQ#How_to_update_the_UI_from_a_ >
>> >> background_thread_using_Jobs.3F
>> >> >
>> >> > In Safari and Opera, the UI is not refreshed (#3) until the next UI
>> >> > event comes, e.g., clicking any other widget to trigger the next UI
>> >> > event. In the debug mode, I saw that the body of the Runnable from >
>> >> Display.async is not executed until the next event comes. Even if I >
>> >> manually execute Display.readAndDispatch, it fails to execute the >
>> >> current UI update. The current UI update is always triggered by the >
>> >> next UI event. Here is what the code looks like:
>> >> >
>> >> > private class ResourceLoadingJob extends Job {
>> >> >
>> >> > ..
>> >> >
>> >> > private void loadResource() {
>> >> > // running get children in session;
>> >> > UICallBack.runNonUIThreadWithFakeContext(display, new Runnable() {
>> >> > @Override
>> >> > public void run() {
>> >> > // load the resource with session on
>> >> > }
>> >> > });
>> >> >
>> >> > display.asyncExec(new Runnable() {
>> >> > @Override
>> >> > public void run() {
>> >> > try {
>> >> > if (!treeViewer.getControl().isDisposed()) {
>> >> > treeViewer.refresh(resource, true);
>> >> > }
>> >> > } catch (Exception e) {
>> >> > // handle exception
>> >> > }
>> >> > }
>> >> > });
>> >> >
>> >> > This issue doesn't happen on other browsers. I am wondering how can
>> >> I > fix it? It looks like a defect in RAP's UI update thread which
>> >> sleeps > and forgets about the UI update.
>> >> >
>> >> > Thanks,
>> >> > Owen
>> >
>> >
>>
>>
>> --
>> Rüdiger Herrmann
>> http://eclipsesource.com
>
>
--
Rüdiger Herrmann
http://eclipsesource.com
|
|
|
Goto Forum:
Current Time: Thu Dec 26 13:49:40 GMT 2024
Powered by FUDForum. Page generated in 0.02689 seconds
|