Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » e(fx)clipse » JavaFx event locking problems with JRE 7u40
JavaFx event locking problems with JRE 7u40 [message #1115857] Tue, 24 September 2013 17:28 Go to next message
Timm Baumeister is currently offline Timm BaumeisterFriend
Messages: 14
Registered: July 2012
Junior Member
For an RCP application under eclipse 3.8.2, efxclipse 0.8.1, jre7u40 I have the following problem:

If a JFace dialog with an FxCanvas was opened through a javafx event, all javafx controls in the application lock and don't process events until the dialog closes.

This problem just appeared under 7u40 but didn't happen on the previous jres.

Here is some example code. A JFace Dialog with a javafx 'Open' button in an FxCanvas. Both the 'Open' and the dialog's 'Ok' button open a new instance of the dialog.

https://dl.dropboxusercontent.com/u/44493241/Clipboard01.png


import javafx.embed.swt.FXCanvas;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;

import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Display;

public class TestFx extends Dialog {
	public TestFx(Shell parent) {
		super(parent);
		setShellStyle(SWT.MODELESS | SWT.DIALOG_TRIM);
	}
	@Override
	public void okPressed() {
		TestFx dialog = new TestFx(Display.getDefault().getActiveShell());
		dialog.open();

	}
	@Override
	protected Control createDialogArea(Composite parent) {
		Composite container = (Composite) super.createDialogArea(parent);
		container.setLayout(new FillLayout());
		FXCanvas fxCanvas = new FXCanvas(container, SWT.NONE);
		Scene scene = new Scene(createScene());
		fxCanvas.setScene(scene);
		return container;
	}
	public Parent createScene() {
		StackPane pane = new StackPane();
		pane.setPadding(new Insets(10));
		Button button = new Button("Open");
		button.setOnAction(new EventHandler<ActionEvent>() {
			@Override public void handle(ActionEvent e) {
				TestFx dialog = new TestFx(Display.getDefault().getActiveShell());
				dialog.open();
			}
		});
		pane.getChildren().add(button);
		return pane;
	}		
}


I open the first dialog through an action in the application's menubar.


projectMenu.add(new Action("TestFx"){
	@Override
	public void run() {
		TestFx dialog  = new TestFx(Display.getDefault().getActiveShell());
		dialog.open();
	}
});



The javafx 'open' button works as long as the dialog was created from the menu action or the 'ok' button but not if it was created by the 'Open' button. In the latter case all javafx controls (also the ones in FxCanvas belonging to other shells) freeze until the dialog closes (the swt ui stays responsive). These events however are put into a queue and are processed once the dialog closes. Note also that the layout of the fxcanvas fails as can be seen in the picture above where the right dialog was opened through the 'open' button of the left dialog.

If I run this not from eclipse but from a simple swt application there is no locking and the layout stays correct
public static void main(String[] args) {
	Display display = new Display();
	Shell shell = new Shell(display);
	TestFx dialog  = new TestFx(shell);
	dialog.open();
}


Any ideas what the underlying problems could be and how to fix this?

[Updated on: Tue, 24 September 2013 19:26]

Report message to a moderator

Re: JavaFx event locking problems with JRE 7u40 [message #1115957 is a reply to message #1115857] Tue, 24 September 2013 20:30 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
On what OS? Does it only happen in dialogs? If this fails the
FXML-Preview would fail as well. Your description sounds like FX is not
hooked appropriately into the native event loop.

There was a fix [1] for SWT/Linux maybe this has introduced a regression

Tom

[1]https://javafx-jira.kenai.com/browse/RT-23411

On 24.09.13 19:28, Timm Baumeister wrote:
> Under eclipse 3.8.2, efxclipse 0.8.1, jre7u40 I have the following problem:
>
> If a JFace dialog with an FxCanvas was opened through a javafx event,
> all javafx controls in the application lock and don't accept events
> until the dialog closes.
>
> This problem just appeared under 7u40 but didn't happen on the previous
> jres.
>
> Here is some example code. A JFace Dialog with a javafx 'Open' button in
> an FxCanvas. Both the 'Open' and the dialog's 'Ok' button open a new
> instance of the dialog.
>
>
>
>
> import javafx.embed.swt.FXCanvas;
> import javafx.event.ActionEvent;
> import javafx.event.EventHandler;
> import javafx.geometry.Insets;
> import javafx.scene.Parent;
> import javafx.scene.Scene;
> import javafx.scene.control.Button;
> import javafx.scene.layout.StackPane;
>
> import org.eclipse.jface.dialogs.Dialog;
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.layout.FillLayout;
> import org.eclipse.swt.widgets.Composite;
> import org.eclipse.swt.widgets.Control;
> import org.eclipse.swt.widgets.Shell;
>
> public class TestFx extends Dialog {
> public TestFx(Shell parent) {
> super(parent);
> setShellStyle(SWT.MODELESS | SWT.DIALOG_TRIM);
> }
> @Override
> public void okPressed() {
> TestFx d = new TestFx(getShell());
> d.open();
>
> }
> @Override
> protected Control createDialogArea(Composite parent) {
> Composite container = (Composite) super.createDialogArea(parent);
> container.setLayout(new FillLayout());
> FXCanvas fxCanvas = new FXCanvas(container, SWT.NONE);
> Scene scene = new Scene(createScene());
> fxCanvas.setScene(scene);
> return container;
> }
> public Parent createScene() {
> StackPane pane = new StackPane();
> pane.setPadding(new Insets(10));
> Button button = new Button("Open");
> button.setOnAction(new EventHandler<ActionEvent>() {
> @Override public void handle(ActionEvent e) {
> TestFx d = new
> TestFx(Display.getDefault().getActiveShell());
> d.open();
> }
> });
> pane.getChildren().add(button);
> return pane;
> }
> }
>
>
> I open the first dialog through a menubar action:
>
>
>
> projectMenu.add(new Action("TestFx"){
> @Override
> public void run() {
> logger.info(Thread.currentThread().getName());
> TestFx dialog = new TestFx(Display.getDefault().getActiveShell());
> dialog.open();
> }
> });
>
>
>
> The javafx 'open' button works as long as the dialog was created from
> the menu action or the 'ok' button but not if it was created by the
> 'Open' button. In the latter case all javafx controls (also the ones in
> FxCanvas belonging to other shells) freeze until the dialog closes (the
> swt ui stays responsive). Note also that the layout of the fxcanvas
> fails as can be seen in the picture above where the right dialog was
> opened through the 'open' button of the left dialog.
>
> If I open the dialog not from eclipse but from a simple swt application
> there is no locking:
>
> public static void main(String[] args) {
> Display display = new Display();
> Shell shell = new Shell(display);
> while (true) {
> MyDialog d = new MyDialog(shell);
> d.open();
> }
> }
>
>
> Any ideas what the underlying problems could be and how to fix this?
>
Re: JavaFx event locking problems with JRE 7u40 [message #1116160 is a reply to message #1115957] Wed, 25 September 2013 03:36 Go to previous messageGo to next message
Timm Baumeister is currently offline Timm BaumeisterFriend
Messages: 14
Registered: July 2012
Junior Member
Thomas Schindl wrote on Tue, 24 September 2013 16:30
On what OS? Does it only happen in dialogs? If this fails the
FXML-Preview would fail as well. Your description sounds like FX is not
hooked appropriately into the native event loop.

There was a fix [1] for SWT/Linux maybe this has introduced a regression


I am running it on win32.

After more tests with ViewParts/Dialogs/Shells the pattern seems to be:

The lockup of the javafx event processing under 7u40 happens whenever a Jface Dialog is opened through a javafx event. It does not matter if the Dialog contains an FxCanvas itself, also modality of the dialog doesn't matter. If the JFace Dialog is replaced by a shell, no lockup appears.




[Updated on: Wed, 25 September 2013 03:37]

Report message to a moderator

Re: JavaFx event locking problems with JRE 7u40 [message #1116266 is a reply to message #1116160] Wed, 25 September 2013 07:08 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi,

Can you please file a JIRA against FX? Please cc me on the ticket, I
hope Steve can find out what happens. So the workaround would be to open
only JavaFX-Dialogs from within JavaFX :-)

If you have a snippet to reproduce this in plain SWT I could give it a
spin in OS-X or don't want to create the account i could file a the JIRA
on behalf of you

We have a JFace like dialog classes in e(fx)clipse if you are interested
in. I would BTW suggest you update to the nightly builds - which are
stable - because I've improved the dialog support lately.

Tom

On 25.09.13 05:36, Timm Baumeister wrote:
> Thomas Schindl wrote on Tue, 24 September 2013 16:30
>> On what OS? Does it only happen in dialogs? If this fails the
>> FXML-Preview would fail as well. Your description sounds like FX is not
>> hooked appropriately into the native event loop.
>>
>> There was a fix [1] for SWT/Linux maybe this has introduced a regression
>
>
> I am running it on win32.
>
> After some more tests with ViewParts/Dialogs/Shells the pattern seems to
> be:
>
> The lockup of the javafx event processing under 7u40 happens whenever a
> Jface Dialog is opened through a javafx event. It does not matter if the
> Dialog contains an FxCanvas itself, also modality of the dialog doesn't
> matter. If the JFace Dialog is replaced by a shell, no lockup appears.
>
>
>
>
>
Re: JavaFx event locking problems with JRE 7u40 [message #1116678 is a reply to message #1116266] Wed, 25 September 2013 18:38 Go to previous messageGo to next message
Timm Baumeister is currently offline Timm BaumeisterFriend
Messages: 14
Registered: July 2012
Junior Member
Thomas Schindl wrote on Wed, 25 September 2013 03:08

Can you please file a JIRA against FX? Please cc me on the ticket, I
hope Steve can find out what happens. So the workaround would be to open
only JavaFX-Dialogs from within JavaFX Smile

If you have a snippet to reproduce this in plain SWT I could give it a
spin in OS-X or don't want to create the account i could file a the JIRA
on behalf of you


Are you sure that this is an issue which belongs into the fx jira? To me it looks so far as if it is related to how fx is bound into eclipse (as it is not happening when using plain swt). I can't give you a plain SWT test case, but I can provide a simple eclipse plugin test case. If you tell me that this should be considered as an fx issue I will file it in their jira.

I have a much simpler test case now without the jface dialog. What happens is that an swt event loop doesn't process fx events if created from within fx. Here the test case:

import javafx.embed.swt.FXCanvas;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class TestFx  {
	static public void test() {
		Display display = Display.getDefault();
		
		Shell shell = new Shell(display.getActiveShell(),SWT.MODELESS | SWT.BORDER | SWT.CLOSE);
		shell.setLayout(new FillLayout());
		
		// fx open shell button
		FXCanvas fxCanvas = new FXCanvas(shell, SWT.NONE);
		StackPane pane = new StackPane();
		pane.setPadding(new Insets(10));
		Button button = new Button("FX Open Shell");
		button.setOnAction(new EventHandler<ActionEvent>() {
			@Override public void handle(ActionEvent e) {
				test();
			}
		});
		pane.getChildren().add(button);
		Scene scene = new Scene(pane);
		fxCanvas.setScene(scene);
		// swt open shell button
		org.eclipse.swt.widgets.Button b = new org.eclipse.swt.widgets.Button(shell, SWT.NONE);
		b.setText("SWT Open Shell");
		b.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseDown(MouseEvent e) {
				test();
			}
		});
		shell.pack();
		shell.open ();
		/* event loop 
		 	- processes swt/fx events if test() was called from swt
			- processes only swt but no fx events if test() was called from fx
			  all fx events during this time will be processed only after the event loop terminates */
		while (!shell.isDisposed()) {
			try {
				if (!display.readAndDispatch()) {
					display.sleep();
				}
			} catch (Throwable e) {
				e.printStackTrace();
			}
		}		
	}
	// lockup does not occur if this is run as a standalone swt app
	public static void main(String[] args) {
		test();
	}
}



I looked at the the call stacks when calling this in plain swt and in eclipse, which are identical except for:

Plain SWT
...
PlatformImpl$4.run() line: 176	
OS.DispatchMessageW(MSG) line: not available [native method]	
OS.DispatchMessage(MSG) line: 2546	
Display.readAndDispatch() line: 3756	
...


Eclipse
...
PlatformImpl$4.run() line: 176	
InvokeLaterDispatcher$Future.run() line: 76
OS.DispatchMessageW(MSG) line: not available [native method]	
OS.DispatchMessage(MSG) line: 2546	
Display.readAndDispatch() line: 3756	
...

Re: JavaFx event locking problems with JRE 7u40 [message #1116706 is a reply to message #1116678] Wed, 25 September 2013 19:09 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
FXCanvas is the problem and this is part of JavaFX. So yes I'm sure this
is a problem of FXs FXCanvas implementation.

I'll try to come up with a standalone SWT-App and file a JIRA.

Tom

On 25.09.13 20:38, Timm Baumeister wrote:
> Thomas Schindl wrote on Wed, 25 September 2013 03:08
>> Can you please file a JIRA against FX? Please cc me on the ticket, I
>> hope Steve can find out what happens. So the workaround would be to open
>> only JavaFX-Dialogs from within JavaFX :)
>>
>> If you have a snippet to reproduce this in plain SWT I could give it a
>> spin in OS-X or don't want to create the account i could file a the JIRA
>> on behalf of you
>
>
> Are you sure that this is an issue which belongs into the fx jira? To me
> it looks so far as if it is related to how fx is bound into eclipse (as
> it is not happening when using plain swt). I can't give you a plain SWT
> test case, but I can provide a simple eclipse plugin test case. If you
> tell me that this should be considered as an fx issue I will file it in
> their jira.
>
> I have a much simpler test case now without the jface dialog. What
> happens is that an swt event loop doesn't process fx events if created
> from within fx. Here the test case:
>
>
> import javafx.embed.swt.FXCanvas;
> import javafx.event.ActionEvent;
> import javafx.event.EventHandler;
> import javafx.geometry.Insets;
> import javafx.scene.Scene;
> import javafx.scene.control.Button;
> import javafx.scene.layout.StackPane;
>
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.events.MouseAdapter;
> import org.eclipse.swt.events.MouseEvent;
> import org.eclipse.swt.layout.FillLayout;
> import org.eclipse.swt.widgets.Display;
> import org.eclipse.swt.widgets.Shell;
>
> public class TestFx {
> static public void test() {
> Display display = Display.getDefault();
>
> Shell shell = new Shell(display.getActiveShell(),SWT.MODELESS |
> SWT.BORDER | SWT.CLOSE);
> shell.setLayout(new FillLayout());
>
> // fx open shell button
> FXCanvas fxCanvas = new FXCanvas(shell, SWT.NONE);
> StackPane pane = new StackPane();
> pane.setPadding(new Insets(10));
> Button button = new Button("FX Open Shell");
> button.setOnAction(new EventHandler<ActionEvent>() {
> @Override public void handle(ActionEvent e) {
> test();
> }
> });
> pane.getChildren().add(button);
> Scene scene = new Scene(pane);
> fxCanvas.setScene(scene);
> // swt open shell button
> org.eclipse.swt.widgets.Button b = new
> org.eclipse.swt.widgets.Button(shell, SWT.NONE);
> b.setText("SWT Open Shell");
> b.addMouseListener(new MouseAdapter() {
> @Override
> public void mouseDown(MouseEvent e) {
> test();
> }
> });
> shell.pack();
> shell.open ();
> /* event loop - processes swt/fx events if test()
> was called from swt
> - processes only swt but no fx events if test() was called
> from fx
> all fx events during this time will be processed only
> after the event loop terminates */
> while (!shell.isDisposed()) {
> try {
> if (!display.readAndDispatch()) {
> display.sleep();
> }
> } catch (Throwable e) {
> e.printStackTrace();
> }
> }
> }
> // lockup does not occur if this is run as a standalone swt app
> public static void main(String[] args) {
> test();
> }
> }
>
>
>
> I looked at the the call stacks when calling this in plain swt and in
> eclipse, which are identical except for:
>
> Plain SWT
>
> ..
> PlatformImpl$4.run() line: 176
> OS.DispatchMessageW(MSG) line: not available [native method]
> OS.DispatchMessage(MSG) line: 2546
> Display.readAndDispatch() line: 3756
> ..
>
>
> Eclipse
>
> ..
> PlatformImpl$4.run() line: 176
> InvokeLaterDispatcher$Future.run() line: 76
> OS.DispatchMessageW(MSG) line: not available [native method]
> OS.DispatchMessage(MSG) line: 2546
> Display.readAndDispatch() line: 3756
> ..
>
>
Re: JavaFx event locking problems with JRE 7u40 [message #1121617 is a reply to message #1116706] Mon, 30 September 2013 20:23 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi,

So the bug is accepted by Steve ;-)
https://javafx-jira.kenai.com/browse/RT-33258

Tom

On 25.09.13 21:09, Tom Schindl wrote:
> FXCanvas is the problem and this is part of JavaFX. So yes I'm sure this
> is a problem of FXs FXCanvas implementation.
>
> I'll try to come up with a standalone SWT-App and file a JIRA.
>
> Tom
>
> On 25.09.13 20:38, Timm Baumeister wrote:
>> Thomas Schindl wrote on Wed, 25 September 2013 03:08
>>> Can you please file a JIRA against FX? Please cc me on the ticket, I
>>> hope Steve can find out what happens. So the workaround would be to open
>>> only JavaFX-Dialogs from within JavaFX :)
>>>
>>> If you have a snippet to reproduce this in plain SWT I could give it a
>>> spin in OS-X or don't want to create the account i could file a the JIRA
>>> on behalf of you
>>
>>
>> Are you sure that this is an issue which belongs into the fx jira? To me
>> it looks so far as if it is related to how fx is bound into eclipse (as
>> it is not happening when using plain swt). I can't give you a plain SWT
>> test case, but I can provide a simple eclipse plugin test case. If you
>> tell me that this should be considered as an fx issue I will file it in
>> their jira.
>>
>> I have a much simpler test case now without the jface dialog. What
>> happens is that an swt event loop doesn't process fx events if created
>> from within fx. Here the test case:
>>
>>
>> import javafx.embed.swt.FXCanvas;
>> import javafx.event.ActionEvent;
>> import javafx.event.EventHandler;
>> import javafx.geometry.Insets;
>> import javafx.scene.Scene;
>> import javafx.scene.control.Button;
>> import javafx.scene.layout.StackPane;
>>
>> import org.eclipse.swt.SWT;
>> import org.eclipse.swt.events.MouseAdapter;
>> import org.eclipse.swt.events.MouseEvent;
>> import org.eclipse.swt.layout.FillLayout;
>> import org.eclipse.swt.widgets.Display;
>> import org.eclipse.swt.widgets.Shell;
>>
>> public class TestFx {
>> static public void test() {
>> Display display = Display.getDefault();
>>
>> Shell shell = new Shell(display.getActiveShell(),SWT.MODELESS |
>> SWT.BORDER | SWT.CLOSE);
>> shell.setLayout(new FillLayout());
>>
>> // fx open shell button
>> FXCanvas fxCanvas = new FXCanvas(shell, SWT.NONE);
>> StackPane pane = new StackPane();
>> pane.setPadding(new Insets(10));
>> Button button = new Button("FX Open Shell");
>> button.setOnAction(new EventHandler<ActionEvent>() {
>> @Override public void handle(ActionEvent e) {
>> test();
>> }
>> });
>> pane.getChildren().add(button);
>> Scene scene = new Scene(pane);
>> fxCanvas.setScene(scene);
>> // swt open shell button
>> org.eclipse.swt.widgets.Button b = new
>> org.eclipse.swt.widgets.Button(shell, SWT.NONE);
>> b.setText("SWT Open Shell");
>> b.addMouseListener(new MouseAdapter() {
>> @Override
>> public void mouseDown(MouseEvent e) {
>> test();
>> }
>> });
>> shell.pack();
>> shell.open ();
>> /* event loop - processes swt/fx events if test()
>> was called from swt
>> - processes only swt but no fx events if test() was called
>> from fx
>> all fx events during this time will be processed only
>> after the event loop terminates */
>> while (!shell.isDisposed()) {
>> try {
>> if (!display.readAndDispatch()) {
>> display.sleep();
>> }
>> } catch (Throwable e) {
>> e.printStackTrace();
>> }
>> }
>> }
>> // lockup does not occur if this is run as a standalone swt app
>> public static void main(String[] args) {
>> test();
>> }
>> }
>>
>>
>>
>> I looked at the the call stacks when calling this in plain swt and in
>> eclipse, which are identical except for:
>>
>> Plain SWT
>>
>> ..
>> PlatformImpl$4.run() line: 176
>> OS.DispatchMessageW(MSG) line: not available [native method]
>> OS.DispatchMessage(MSG) line: 2546
>> Display.readAndDispatch() line: 3756
>> ..
>>
>>
>> Eclipse
>>
>> ..
>> PlatformImpl$4.run() line: 176
>> InvokeLaterDispatcher$Future.run() line: 76
>> OS.DispatchMessageW(MSG) line: not available [native method]
>> OS.DispatchMessage(MSG) line: 2546
>> Display.readAndDispatch() line: 3756
>> ..
>>
>>
>
Previous Topic:Deployment to exe
Next Topic:Maven build fails
Goto Forum:
  


Current Time: Tue Apr 16 11:11:09 GMT 2024

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

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

Back to the top