Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Occasional Invalid Thread Access(Occasional Invalid Thread Access)
Occasional Invalid Thread Access [message #1743438] Thu, 15 September 2016 13:09 Go to next message
Setya Nugdjaja is currently offline Setya NugdjajaFriend
Messages: 567
Registered: July 2009
Senior Member
Hi al,,

We're developing a small standalone RAP application.
We often encountered Invalid Thread Access that severely degrades our user experience. The error is still happening eventhough we wrap the ui updates to Display#sync/async like below:

		Display.getDefault().syncExec
		(
			new Runnable()
			{
				@Override
				public void run()
				{
					String message = "No record available";
					if (pagination != null)
					{
						if (pagination.getTotalRecordCount() > 0)
							message = MessageFormat.format("Page {0} of {1}", new Object[] { Integer.valueOf(pagination.getCurrentPage()), Integer.valueOf(pagination.getTotalPageCount()) });
					}

					AbstractTabularForm.this.lblPageNumber.setText(message);
				}
			}
		);


The error seems to be spreaded all over in our code, but above part is the most often.

Is there any other way we should do to prevent this error ?

Any help would be greatly appreciated.

Thanks & Regards,
Setya
Re: Occasional Invalid Thread Access [message #1743456 is a reply to message #1743438] Thu, 15 September 2016 14:43 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,
you should not call Display#getDefault as it can't be used outside UI thread, but provide a display instance outside background thread. Look also at RWT.getUISession().exec(Runnable).
HTH,
Ivan
Re: Occasional Invalid Thread Access [message #1743642 is a reply to message #1743456] Sat, 17 September 2016 17:06 Go to previous messageGo to next message
Setya Nugdjaja is currently offline Setya NugdjajaFriend
Messages: 567
Registered: July 2009
Senior Member
Hi Ivan,

Thank you very much.

RWT.getUISession().exec(Runnable) seems to do the trick.

Regards,
Setya
Re: Occasional Invalid Thread Access [message #1743872 is a reply to message #1743642] Tue, 20 September 2016 10:32 Go to previous messageGo to next message
Dmitry Dukhov is currently offline Dmitry DukhovFriend
Messages: 192
Registered: February 2013
Senior Member
"you should not call Display#getDefault as it can't be used outside UI thread"
Ivan, small question
If understood right Setya they want to update any form
AbstractTabularForm.this.lblPageNumber.setText(message);

read guide
"But when the UI needs to be updated, Display#asyncExec must be used, as it runs the code in the UI thread and thereby gives access to session scope and widgets."

Does RWT.getUISession().exec(Runnable) work well?
Re: Occasional Invalid Thread Access [message #1744031 is a reply to message #1743642] Wed, 21 September 2016 14:34 Go to previous messageGo to next message
Setya Nugdjaja is currently offline Setya NugdjajaFriend
Messages: 567
Registered: July 2009
Senior Member
Hi Ivan,

The problem still happens and easily reproduced when user opens the same URL on 2nd browser tab or the 2nd instance of the same browser.

The error occurs at editor#dispose of the following code:

RWT.getUISession().exec
(
	new Runnable()
	{
		@Override
		public void run()
		{
			for (TableEditor tableEditor : DefaultColumnLabelProvider.this.TABLE_EDITORS)
			{
				final Control editor = tableEditor.getEditor();
							
				if (editor == null) continue;
						
				if (!editor.isDisposed())
					editor.dispose();
			}
		}
	}
);


I've also tried Display#syncExec w/ display instance from outside background thread. Nothing worked.

But the problem did not occur when user opens the 2nd same URL on different browser brand.

Thanks & Regards,
Setya
Re: Occasional Invalid Thread Access [message #1744087 is a reply to message #1744031] Thu, 22 September 2016 09:38 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,
class DefaultColumnLabelProvider is not RAP (JFace class). What is this filed DefaultColumnLabelProvider.this.TABLE_EDITORS? Is it static? Do you keep there all table editor instances from all UI sessions?
Regards,
Ivan
Re: Occasional Invalid Thread Access [message #1744105 is a reply to message #1744031] Thu, 22 September 2016 11:07 Go to previous messageGo to next message
Dmitry Dukhov is currently offline Dmitry DukhovFriend
Messages: 192
Registered: February 2013
Senior Member
try so with async
Quote:
Display.getDefault().asyncExec(new Runnable() {
public void run() {
your_action_code
}
});
Re: Occasional Invalid Thread Access [message #1744146 is a reply to message #1744087] Thu, 22 September 2016 17:28 Go to previous messageGo to next message
Setya Nugdjaja is currently offline Setya NugdjajaFriend
Messages: 567
Registered: July 2009
Senior Member
Hi Ivan,

DefaultColumnLabelProvider extends ColumnLabelProvider and I instantiate this class for each table column that I use. TABLE_EDITORS is a final non-static field in DefaultColumnLabelProvider.

I use TABLE_EDITORS to contain all table editors created so that I can dispose them later when I rebuild the table items.

Finally I configure the form that contains this table in Spring using session scope.

Thanks & Regards,
Setya
Re: Occasional Invalid Thread Access [message #1744149 is a reply to message #1744105] Thu, 22 September 2016 17:55 Go to previous messageGo to next message
Setya Nugdjaja is currently offline Setya NugdjajaFriend
Messages: 567
Registered: July 2009
Senior Member
Hi Dmitry,

Thank you for your suggestion.

The error indeed gone, but new problem arises, where app in the 1st tab does not get updated properly every time there's UI updates.

Should I block user from opening the same app on the same session ?

Thanks & Regards,
Setya
Re: Occasional Invalid Thread Access [message #1744151 is a reply to message #1744149] Thu, 22 September 2016 20:00 Go to previous messageGo to next message
Dmitry Dukhov is currently offline Dmitry DukhovFriend
Messages: 192
Registered: February 2013
Senior Member
>where app in the 1st tab does not get updated properly every time there's UI updates.
use thread and put inside method "run" your code with sleep for every time. don't forget set condition for stop thread

>Should I block user from opening the same app on the same session ?
Why?

[Updated on: Thu, 22 September 2016 20:02]

Report message to a moderator

Re: Occasional Invalid Thread Access [message #1744301 is a reply to message #1744151] Sat, 24 September 2016 11:33 Go to previous messageGo to next message
Setya Nugdjaja is currently offline Setya NugdjajaFriend
Messages: 567
Registered: July 2009
Senior Member
Hi Dmitry,

Quote:
Should I block user from opening the same app on the same session ?
Why?


Since I configure the application in Spring bean using 'session' scope and it seems that all this problem occurs when application is shared with the same session.

I was wondering how other RAP applications handle this situation.

Thanks & Regards,
Setya
Re: Occasional Invalid Thread Access [message #1744326 is a reply to message #1744301] Sun, 25 September 2016 14:29 Go to previous messageGo to next message
Dmitry Dukhov is currently offline Dmitry DukhovFriend
Messages: 192
Registered: February 2013
Senior Member
I didn't deep dive to RAP but sessions works stable. New browser-tab is new UI-session .
Re: Occasional Invalid Thread Access [message #1744330 is a reply to message #1744326] Sun, 25 September 2016 18:26 Go to previous message
Setya Nugdjaja is currently offline Setya NugdjajaFriend
Messages: 567
Registered: July 2009
Senior Member
Hi Dmitry,

It seems that for every browser tab I have to limit the scope to RAP's UISession scope so that each tab will get it's own instance. I've found this which I'll give a try.

Regards,
Setya
Previous Topic:Running RAP on WebSphere 8.5 for z/OS
Next Topic:What happened to patch fragments?
Goto Forum:
  


Current Time: Fri Mar 29 04:30:41 GMT 2024

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

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

Back to the top