Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Display.(a)syncExec() execution problem(the runnable is executed only after a resize-event)
Display.(a)syncExec() execution problem [message #662384] Wed, 30 March 2011 13:32 Go to next message
Dimitri Jeske is currently offline Dimitri JeskeFriend
Messages: 4
Registered: March 2011
Junior Member
Hi RAP developers and community,

I am relatively new to this topic, but nevertheless I am trying to implement an application consisting of several bundles in RAP. One of them acts as a GUI (GUI bundle) and another one (monitoring bundle) is meant for collecting data from sensors attached to a platform running OSGi.
Among others the GUI consits of several views and one of them is used for displaying the informaiton received from the monitoring bundle in tabular mode (using org.eclipse.jface.viewers.TableViewer). For this purpose the GUI bundle registers a service which is used by the monitoring bundle for transmitting the collected data in an appropriate way. This is done periodically by implementing a java.util.Timer. Upon receiving new data, the data model of the GUI bundle gets updated and Display.asyncExec(runnable) is called. But the execution of the runnable occurs only after a user interaction with the browser window (e.g. resizing it, scrolling up/down or reordering the collumns of a table).

The corresponding pieces of code are listed below:

GUI bundle
public void updateRegularData(final String sensorclassID, final Node[] nodes) {
  //create a list for the sensor data
  List<SimpleSensor> sensorList = new ArrayList<SimpleSensor>();
  //traverse all nodes of the sensorclass
  for(Node node : nodes) {
    //and every sensor of a node
    for(Sensor sensor : node.getSensors()) {
      //create new simplesensor with its properties
      SimpleSensor newSensor = new SimpleSensor();
      newSensor.setId(sensor.getID());
      newSensor.setName(sensor.getName());
      newSensor.setValue(sensor.getSensorValue().getValue());
      newSensor.setMax(sensor.getSensorValue().getMax());
      newSensor.setMin(sensor.getSensorValue().getMin());
      newSensor.setUnit(sensor.getSensorValue().getUnit());
      newSensor.setOnline(!sensor.isOffline());
      newSensor.setParent(node.getID());
      //and put it into the list
      sensorList.add(newSensor);
    }
  }
  //update the data of the model with the newly created list
  SensorModelProvider.INSTANCE.updateData(sensorclassID, sensorList);
  MonitoringView.defaultDisplay.asyncExec(new MyRunnable(sensorclassID));
}


private class MyRunnable implements Runnable {
  private final String sensorclassID;
  MyRunnable(String sensorclassID) {
    this.sensorclassID = sensorclassID;
  }
  @Override
  public void run() {
    //this call does not affect anything
    UICallBack.activate(sensorclassID);
    //check whether there is already a view for displaying the data
    if(!manager.containsViewer(sensorclassID)) {
      //if not, create a new one
      manager.createViewer(MonitoringView.TOP_CONTAINER, sensorclassID);
    }
    else {
      //otherwise just update the view
      manager.updateViewer(sensorclassID);
    }
    //this call does not affect anything
    UICallBack.deactivate(sensorclassID);
  }
}

As stated above, the execution of run()s occurs only after a user interaction with the GUI, meaning that the corresponding threads are waiting for an event, which is not intended.
Is there any possibility to force the execution, so that the GUI gets updated immediately after receiving new data?
Every helpful suggestion for solving this behavior is greatly appreciated.

Greetings,
Dimitri

[Updated on: Wed, 30 March 2011 13:32]

Report message to a moderator

Re: Display.(a)syncExec() execution problem [message #662613 is a reply to message #662384] Thu, 31 March 2011 09:45 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2426
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi Dimitri,
activate the UICallBack outside the runnable... something like this:
SensorModelProvider.INSTANCE.updateData(sensorclassID, sensorList);
UICallBack.activate(sensorclassID);
MonitoringView.defaultDisplay.asyncExec(new MyRunnable(sensorclassID));
HTH,
Ivan

On 3/30/2011 4:32 PM, Dimitri Jeske wrote:
> Hi RAP developers and community,
>
> I am relatively new to this topic, but nevertheless I am trying to
> implement an application consisting of several bundles in RAP. One of
> them acts as a GUI (GUI bundle) and another one (monitoring bundle) is
> meant for collecting data from sensors attached to a platform running
> OSGi.
> Among others the GUI consits of several views and one of them is used
> for displaying the informaiton received from the monitoring bundle in
> tabular mode (using org.eclipse.jface.viewers.TableViewer). For this
> purpose the GUI bundle registers a service which is used by the
> monitoring bundle for transmitting the collected data in an
> appropriate way. This is done periodically by implementing a
> java.util.Timer. Upon receiving new data, the data model of the GUI
> bundle gets updated and Display.asyncExec(runnable) is called. But the
> execution of the runnable occurs only after a user interaction with
> the browser window (e.g. resizing it, scrolling up/down or reordering
> the collumns of a table).
>
> The corresponding pieces of code are listed below:
>
> GUI bundle
> public void updateRegularData(final String sensorclassID, final Node[]
> nodes) {
> //create a list for the sensor data
> List<SimpleSensor> sensorList = new ArrayList<SimpleSensor>();
> //traverse all nodes of the sensorclass
> for(Node node : nodes) {
> //and every sensor of a node
> for(Sensor sensor : node.getSensors()) {
> //create new simplesensor with its properties
> SimpleSensor newSensor = new SimpleSensor();
> newSensor.setId(sensor.getID());
> newSensor.setName(sensor.getName());
> newSensor.setValue(sensor.getSensorValue().getValue());
> newSensor.setMax(sensor.getSensorValue().getMax());
> newSensor.setMin(sensor.getSensorValue().getMin());
> newSensor.setUnit(sensor.getSensorValue().getUnit());
> newSensor.setOnline(!sensor.isOffline());
> newSensor.setParent(node.getID());
> //and put it into the list
> sensorList.add(newSensor);
> }
> }
> //update the data of the model with the newly created list
> SensorModelProvider.INSTANCE.updateData(sensorclassID, sensorList);
> MonitoringView.defaultDisplay.asyncExec(new MyRunnable(sensorclassID));
> }
>
> private class MyRunnable implements Runnable {
> private final String sensorclassID;
> MyRunnable(String sensorclassID) {
> this.sensorclassID = sensorclassID;
> }
> @Override
> public void run() {
> //this call does not affect anything
> UICallBack.activate(sensorclassID);
> //check whether there is already a view for displaying the data
> if(!manager.containsViewer(sensorclassID)) {
> //if not, create a new one
> manager.createViewer(MonitoringView.TOP_CONTAINER, sensorclassID);
> }
> else {
> //otherwise just update the view
> manager.updateViewer(sensorclassID);
> }
> //this call does not affect anything
> UICallBack.deactivate(sensorclassID);
> }
> }
> As stated above, the execution of run()s occurs only after a user
> interaction with the GUI, meaning that the corresponding threads are
> waiting for an event, which is not intended.
> Is there any possibility to force the execution, so that the GUI gets
> updated immediately after receiving new data?
> Every helpful suggestion for solving this behavior is greatly
> appreciated.
>
> Greetings,
> Dimitri
Re: Display.(a)syncExec() execution problem [message #662736 is a reply to message #662613] Thu, 31 March 2011 17:26 Go to previous messageGo to next message
Dimitri Jeske is currently offline Dimitri JeskeFriend
Messages: 4
Registered: March 2011
Junior Member
Thanks for the advice Ivan.
I already tried to do that - with the same result. Now I figured out, that it is possible to activate the callback globally pasting it in the createUI() method of IEntryPoint. But this approach causes the osgi framework to freeze when trying to exit it using the close command. This is an already known bug which occurs by deploying the rap application with jetty (aka self-hosting) and shall not occur when using tomcat.
Unfotunatelly, for my purposes I have to use the self-hosting approach and therefore the only way to shutdown the framework is to use the exit command.

Greetings,
Dimitri
Re: Display.(a)syncExec() execution problem [message #662770 is a reply to message #662736] Thu, 31 March 2011 20:56 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2426
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi Dimitri,
moreover, activation of the UICallBack globally (without deactivate it)
may cause session to not expire due to blocking UICallBack request.
Best,
Ivan

On 3/31/2011 8:26 PM, Dimitri Jeske wrote:
> Thanks for the advice Ivan.
> I already tried to do that - with the same result. Now I figured out,
> that it is possible to activate the callback globally pasting it in
> the createUI() method of IEntryPoint. But this approach causes the
> osgi framework to freeze when trying to exit it using the close
> command. This is an already known bug which occurs by deploying the
> rap application with jetty (aka self-hosting) and shall not occur when
> using tomcat.
> Unfotunatelly, for my purposes I have to use the self-hosting approach
> and therefore the only way to shutdown the framework is to use the
> exit command.
>
> Greetings,
> Dimitri
Re: Display.(a)syncExec() execution problem [message #662948 is a reply to message #662770] Fri, 01 April 2011 14:39 Go to previous messageGo to next message
Dimitri Jeske is currently offline Dimitri JeskeFriend
Messages: 4
Registered: March 2011
Junior Member
Is there a way to deactivate the UICallBack when closing the framework or is exit the only possibility to finish?

Greetings,
Dimitri
Re: Display.(a)syncExec() execution problem [message #663142 is a reply to message #662948] Mon, 04 April 2011 03:45 Go to previous messageGo to next message
Yury Mising name is currently offline Yury Mising nameFriend
Messages: 95
Registered: May 2010
Location: Russia
Member
Hi, Dimitri.

Try to add listener to session destroy event.

        ISessionStore sessionStore = RWT.getSessionStore();
        sessionStore.addSessionStoreListener(new SessionStoreListener()
        {
            public void beforeDestroy(SessionStoreEvent event)
            {
              UICallBack.deactivate(key);
            }
        });
Re: Display.(a)syncExec() execution problem [message #663239 is a reply to message #663142] Mon, 04 April 2011 12:46 Go to previous messageGo to next message
Dimitri Jeske is currently offline Dimitri JeskeFriend
Messages: 4
Registered: March 2011
Junior Member
Adding it to createUI() in a subclass of IEntryPoint does not help either Sad.
It seems, that the session doesn't get destroyed even if I close the browser or try to stop the corresponding bundle.
Re: Display.(a)syncExec() execution problem [message #665735 is a reply to message #662613] Fri, 15 April 2011 16:35 Go to previous message
Tiber Sept is currently offline Tiber SeptFriend
Messages: 32
Registered: February 2010
Member
Hi all,

first of all sorry for hijacking this thread, but I am dealing with a (remotely) related issue.
The issue is this:

1. UICallback is active
2. We are using Display.syncExec() to run some UI code within a background thread
3. The UI is updated just fine
4. But, it's quite slow
5. In some cases syncExec() has a delay of more than 900ms before runnnig the UI code
6. Multiple syncExec() calls result in accumulative 3-4s to run 100 ms code

I've got three questions:

1. Is there any way to force syncExec() to run with a shorter delay? Does the browser
need to send requests faster for that purpose? The desirable delay would be
less than 100ms.

2. The purpose of having the background thread with the syncExec() calls is to split the
generated JS code into smaller chunks. Otherwise the script takes too long to execute.
Could you propose an alternative way of sending smaller JS chunks to the browser,
which avoids the delays of syncExec calls?

3. Is my approach generally wrong? Like could higher latency make the syncExec() delay multiple times longer?

Thanks & Regards,
tibersept
Previous Topic:Maximizing properties view issue
Next Topic:Key Bindings (RAP/FAQ)
Goto Forum:
  


Current Time: Thu Apr 25 20:40:31 GMT 2024

Powered by FUDForum. Page generated in 0.03766 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top