Re: Swing and JavaFX thread merge
On 8/13/2013 7:17 PM, Werner Lehmann wrote: Artem, we already tested with 7u40 b35 - same thing: Java Web Start 10.40.2.35 Using JRE version 1.7.0_40-ea-b35 Java HotSpot(TM) 64-Bit Server VM ... runTest in AWT-EventQueue-2 jfx button click in JavaFX Application Thread invokeLater from jfx button click in AWT-EventQueue-0 jbutton click in AWT-EventQueue-2 jfx button click in JavaFX Application Thread invokeLater from jfx button click in AWT-EventQueue-0 jbutton click in AWT-EventQueue-2 OK. Thanks for confirmation. It's not related to AWT changes then. Yesterday I spent an hour trying to understand, what thread group JavaFX event thread is created in. It seems there is no consistency between Windows, X11, and Mac OS X, which can be the source of the problems you observe. Multiple AWT event dispatch threads is not a bug, it's a valid case, when running as an applet or as a JNLP application. The bug is when applet/application code is run on the wrong EDT, and this is what we have here. BTW, it's not related to merging Swing and JavaFX threads, so we should either change the subject, or start a new discussion :) Thanks, Artem Werner On 13.08.2013 16:31, Artem Ananiev wrote: Jeff, Werner, thank you very much for detailed evaluation. The issues you observe may be related to recent changes in AWT/Swing in 7u25. If my guess is correct, they should be fixed in the latest 7u40 builds. I know it's not released yet, but early access builds are available at java.net. Could you run your apps with 7u40 and check if the problems are gone, please? Thanks, Artem
Re: Swing and JavaFX thread merge
Same here. jeff On Aug 13, 2013, at 10:17 AM, Werner Lehmann wrote: > Artem, > > we already tested with 7u40 b35 - same thing: > >> Java Web Start 10.40.2.35 >> Using JRE version 1.7.0_40-ea-b35 Java HotSpot(TM) 64-Bit Server VM > ... >> runTest in AWT-EventQueue-2 >> jfx button click in JavaFX Application Thread >> invokeLater from jfx button click in AWT-EventQueue-0 >> jbutton click in AWT-EventQueue-2 >> jfx button click in JavaFX Application Thread >> invokeLater from jfx button click in AWT-EventQueue-0 >> jbutton click in AWT-EventQueue-2 > > Werner > > On 13.08.2013 16:31, Artem Ananiev wrote: >> Jeff, Werner, >> >> thank you very much for detailed evaluation. The issues you observe may >> be related to recent changes in AWT/Swing in 7u25. If my guess is >> correct, they should be fixed in the latest 7u40 builds. I know it's not >> released yet, but early access builds are available at java.net. Could >> you run your apps with 7u40 and check if the problems are gone, please? >> >> Thanks, >> >> Artem
Re: Swing and JavaFX thread merge
Artem, we already tested with 7u40 b35 - same thing: Java Web Start 10.40.2.35 Using JRE version 1.7.0_40-ea-b35 Java HotSpot(TM) 64-Bit Server VM ... runTest in AWT-EventQueue-2 jfx button click in JavaFX Application Thread invokeLater from jfx button click in AWT-EventQueue-0 jbutton click in AWT-EventQueue-2 jfx button click in JavaFX Application Thread invokeLater from jfx button click in AWT-EventQueue-0 jbutton click in AWT-EventQueue-2 Werner On 13.08.2013 16:31, Artem Ananiev wrote: Jeff, Werner, thank you very much for detailed evaluation. The issues you observe may be related to recent changes in AWT/Swing in 7u25. If my guess is correct, they should be fixed in the latest 7u40 builds. I know it's not released yet, but early access builds are available at java.net. Could you run your apps with 7u40 and check if the problems are gone, please? Thanks, Artem
Re: Swing and JavaFX thread merge
Jeff, Werner, thank you very much for detailed evaluation. The issues you observe may be related to recent changes in AWT/Swing in 7u25. If my guess is correct, they should be fixed in the latest 7u40 builds. I know it's not released yet, but early access builds are available at java.net. Could you run your apps with 7u40 and check if the problems are gone, please? Thanks, Artem On 8/12/2013 4:51 PM, Werner Lehmann wrote: Hi, coincidentally we were experiencing the exact same problem with the combination 7u25, OSX, Webstart. Also, we arrived at pretty much the same workaround. Investigation showed that multiple Swing eventqueues were created in the above configuration. This would cause threading issues (NPE), paint issues (flicker etc), drag-drop issues. See below for a testcase: JFrame with a JButton and an fx button. When clicked, the former prints its current thread, while the later switches to EDT first (invokeLater) and then also prints the thread. On Windows, this turns out to be the same thread as expected. On WebStart 7u25 OSX we are getting different AWT-EventQueue-X threads. Werner public class TestSwingEDT extends JFrame{ public static void main(final String[] args){ SwingUtilities.invokeLater(new Runnable() { @Override public void run() { new TestSwingEDT().runTest(args); } }); } private void runTest(String[] args){ System.out.println("runTest in " + Thread.currentThread().getName()); this.setDefaultCloseOperation(EXIT_ON_CLOSE); this.setSize(300, 200); final JFXPanel jfxPanel = new JFXPanel(); Platform.runLater(new Runnable(){ @Override public void run() { Button btn = new Button("click me"); btn.onActionProperty().set(new EventHandler() { @Override public void handle(ActionEvent ae) { System.out.println("jfx button click in " + Thread.currentThread().getName()); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { System.out.println("invokeLater from jfx button click in " + Thread.currentThread().getName()); } }); } }); HBox hbox = new HBox(); hbox.getChildren().add(btn); jfxPanel.setScene(new Scene(hbox)); } }); JButton jbutton = new JButton("click me"); jbutton.addActionListener(new ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent e) { System.out.println("jbutton click in " + Thread.currentThread().getName()); } }); JPanel rootPanel = new JPanel(); rootPanel.add(jbutton); this.getContentPane().add(jfxPanel, BorderLayout.NORTH); this.getContentPane().add(rootPanel, BorderLayout.CENTER); this.setVisible(true); Platform.runLater(new Runnable(){ @Override public void run() { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { System.out.println("invokeLater in Platform.runLater in " + Thread.currentThread().getName()); } }); } }); } }
Re: Swing and JavaFX thread merge
Hi, coincidentally we were experiencing the exact same problem with the combination 7u25, OSX, Webstart. Also, we arrived at pretty much the same workaround. Investigation showed that multiple Swing eventqueues were created in the above configuration. This would cause threading issues (NPE), paint issues (flicker etc), drag-drop issues. See below for a testcase: JFrame with a JButton and an fx button. When clicked, the former prints its current thread, while the later switches to EDT first (invokeLater) and then also prints the thread. On Windows, this turns out to be the same thread as expected. On WebStart 7u25 OSX we are getting different AWT-EventQueue-X threads. Werner public class TestSwingEDT extends JFrame{ public static void main(final String[] args){ SwingUtilities.invokeLater(new Runnable() { @Override public void run() { new TestSwingEDT().runTest(args); } }); } private void runTest(String[] args){ System.out.println("runTest in " + Thread.currentThread().getName()); this.setDefaultCloseOperation(EXIT_ON_CLOSE); this.setSize(300, 200); final JFXPanel jfxPanel = new JFXPanel(); Platform.runLater(new Runnable(){ @Override public void run() { Button btn = new Button("click me"); btn.onActionProperty().set(new EventHandler() { @Override public void handle(ActionEvent ae) { System.out.println("jfx button click in " + Thread.currentThread().getName()); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { System.out.println("invokeLater from jfx button click in " + Thread.currentThread().getName()); } }); } }); HBox hbox = new HBox(); hbox.getChildren().add(btn); jfxPanel.setScene(new Scene(hbox)); } }); JButton jbutton = new JButton("click me"); jbutton.addActionListener(new ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent e) { System.out.println("jbutton click in " + Thread.currentThread().getName()); } }); JPanel rootPanel = new JPanel(); rootPanel.add(jbutton); this.getContentPane().add(jfxPanel, BorderLayout.NORTH); this.getContentPane().add(rootPanel, BorderLayout.CENTER); this.setVisible(true); Platform.runLater(new Runnable(){ @Override public void run() { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { System.out.println("invokeLater in Platform.runLater in " + Thread.currentThread().getName()); } }); } }); } }
Re: Swing and JavaFX thread merge
So I found a workaround, though I don't understand the why of the problem or workaround. What I found was that on MacOSX 7u25+, my app mainSwing() (executed via invokeLater() from main()) was being called on AWT-EventQueue-2 from the JAWS startup thread (javawsApplicationMain) instead of AWT-EventQueue-0. So I added code to force JavaFX init, switch over to the FX thread, and switch back to Swing, which is then AWT-EventQueue-0: if(Thread.currentThread().getName().equals("AWT-EventQueue-2")) { new JFXPanel(); Platform.runLater(new Runnable() { public void run() { SwingUtilities.invokeLater(new Runnable() { public void run() { mainSwing(args); }}); }}); return; } And now my JOptionPane correctly blocks events outside of the dialog! jeff On Aug 8, 2013, at 9:56 AM, Jeff Martin wrote: > Addendum: it turns out that the JOptionPane is not blocking any of the UI > (Swing included). So maybe this isn't strictly a JavaFX problem. > > jeff > > > On Aug 8, 2013, at 8:17 AM, Jeff Martin wrote: > >> It looks like this is specific to MacOSX 7u25+, if you run Java Inventor >> from the JAWS link on MacOSX (I'm using JVM 1.7.0_25 or 40-ea): >> >> prompt> javaws http://reportmill.com/javi/javi1/JavaInventor1.jnlp >> >> Here are the steps: >> >> 1. Create New Project and Open >> 2. Click on large, animated "New Java Starter File" to bring up >> JOptionPane >> >> Then if you move the mouse around, you should see the other buttons on the >> screen still animate or illuminate in the FX thread. Whereas on 7u20 or >> Windows or non-JAWS launch, the JavaFX effects are not triggered while the >> modal panel is up. If you dismiss the option pane with the escape key and >> quickly re-click the New Starter File button repeatedly, eventually the >> SwingUtilities.computeIntersection NPE will manifest (sooner if you are >> doing a sales demo). >> >> Any thoughts on what would make the FX thread ignore the modal state in this >> configuration? >> >> jeff >> >> >> On Aug 8, 2013, at 6:50 AM, Artem Ananiev wrote: >> >>> >>> On 8/8/2013 1:45 AM, Jeff Martin wrote: I thought I was getting this automatically - when I run on my desktop, I can bring up a JOptionPane from a Swing thread and JFXPanels (correctly) block. But when I run from Java Web Start, they don't, and I end up with sporadic SwingUtilities.computeIntersection NullPointerException. >>> >>> Once these two JDK/JavaFX bugs are resolved, scenario with JOptionPane you >>> described will work. As I wrote, it won't work by default in JDK8, you'll >>> need to run your app with certain system property (something like >>> -Djavafx.swing.singlethreaded=true). >>> Is there a secret setting that has a different default with JAWS? >>> >>> NPEs look like a bug, either in AWT/FX, or in your application. I really >>> doubt it's related to Java Web Start. Could you provide a test to reproduce >>> the exceptions, please? >>> >>> Thanks, >>> >>> Artem >>> jeff On Aug 7, 2013, at 5:06 AM, Artem Ananiev wrote: > Hi, Pedro Duque Vieira, > > this is in progress. JDK part is tracked in 8015477: > > http://bugs.sun.com/view_bug.do?bug_id=8015477 > > JavaFX part is described in RT-30694: > > https://javafx-jira.kenai.com/browse/RT-30694 > > Note that in JDK8/JavaFX8 single-threaded mode will not be a part of > public API, it will be an experimental feature. > > Thanks, > > Artem > > On 8/7/2013 2:43 AM, Pedro Duque Vieira wrote: >> Hi, >> >> Some time ago there was a patch submitted which for all purposes merged >> the >> swing and javafx thread, making it easier for developers working on a >> swing/javafx app - http://wiki.apidesign.org/wiki/JavaFX >> >> Is this available now (I was under the impression it is)? How do I use >> it? >> >> Thanks in advance, >
Re: Swing and JavaFX thread merge
Addendum: it turns out that the JOptionPane is not blocking any of the UI (Swing included). So maybe this isn't strictly a JavaFX problem. jeff On Aug 8, 2013, at 8:17 AM, Jeff Martin wrote: > It looks like this is specific to MacOSX 7u25+, if you run Java Inventor from > the JAWS link on MacOSX (I'm using JVM 1.7.0_25 or 40-ea): > > prompt> javaws http://reportmill.com/javi/javi1/JavaInventor1.jnlp > > Here are the steps: > > 1. Create New Project and Open > 2. Click on large, animated "New Java Starter File" to bring up > JOptionPane > > Then if you move the mouse around, you should see the other buttons on the > screen still animate or illuminate in the FX thread. Whereas on 7u20 or > Windows or non-JAWS launch, the JavaFX effects are not triggered while the > modal panel is up. If you dismiss the option pane with the escape key and > quickly re-click the New Starter File button repeatedly, eventually the > SwingUtilities.computeIntersection NPE will manifest (sooner if you are doing > a sales demo). > > Any thoughts on what would make the FX thread ignore the modal state in this > configuration? > > jeff > > > On Aug 8, 2013, at 6:50 AM, Artem Ananiev wrote: > >> >> On 8/8/2013 1:45 AM, Jeff Martin wrote: >>> I thought I was getting this automatically - when I run on my >>> desktop, I can bring up a JOptionPane from a Swing thread and >>> JFXPanels (correctly) block. But when I run from Java Web Start, they >>> don't, and I end up with sporadic SwingUtilities.computeIntersection >>> NullPointerException. >> >> Once these two JDK/JavaFX bugs are resolved, scenario with JOptionPane you >> described will work. As I wrote, it won't work by default in JDK8, you'll >> need to run your app with certain system property (something like >> -Djavafx.swing.singlethreaded=true). >> >>> Is there a secret setting that has a different default with JAWS? >> >> NPEs look like a bug, either in AWT/FX, or in your application. I really >> doubt it's related to Java Web Start. Could you provide a test to reproduce >> the exceptions, please? >> >> Thanks, >> >> Artem >> >>> jeff >>> >>> >>> On Aug 7, 2013, at 5:06 AM, Artem Ananiev wrote: >>> Hi, Pedro Duque Vieira, this is in progress. JDK part is tracked in 8015477: http://bugs.sun.com/view_bug.do?bug_id=8015477 JavaFX part is described in RT-30694: https://javafx-jira.kenai.com/browse/RT-30694 Note that in JDK8/JavaFX8 single-threaded mode will not be a part of public API, it will be an experimental feature. Thanks, Artem On 8/7/2013 2:43 AM, Pedro Duque Vieira wrote: > Hi, > > Some time ago there was a patch submitted which for all purposes merged > the > swing and javafx thread, making it easier for developers working on a > swing/javafx app - http://wiki.apidesign.org/wiki/JavaFX > > Is this available now (I was under the impression it is)? How do I use it? > > Thanks in advance,
Re: Swing and JavaFX thread merge
It looks like this is specific to MacOSX 7u25+, if you run Java Inventor from the JAWS link on MacOSX (I'm using JVM 1.7.0_25 or 40-ea): prompt> javaws http://reportmill.com/javi/javi1/JavaInventor1.jnlp Here are the steps: 1. Create New Project and Open 2. Click on large, animated "New Java Starter File" to bring up JOptionPane Then if you move the mouse around, you should see the other buttons on the screen still animate or illuminate in the FX thread. Whereas on 7u20 or Windows or non-JAWS launch, the JavaFX effects are not triggered while the modal panel is up. If you dismiss the option pane with the escape key and quickly re-click the New Starter File button repeatedly, eventually the SwingUtilities.computeIntersection NPE will manifest (sooner if you are doing a sales demo). Any thoughts on what would make the FX thread ignore the modal state in this configuration? jeff On Aug 8, 2013, at 6:50 AM, Artem Ananiev wrote: > > On 8/8/2013 1:45 AM, Jeff Martin wrote: >> I thought I was getting this automatically - when I run on my >> desktop, I can bring up a JOptionPane from a Swing thread and >> JFXPanels (correctly) block. But when I run from Java Web Start, they >> don't, and I end up with sporadic SwingUtilities.computeIntersection >> NullPointerException. > > Once these two JDK/JavaFX bugs are resolved, scenario with JOptionPane you > described will work. As I wrote, it won't work by default in JDK8, you'll > need to run your app with certain system property (something like > -Djavafx.swing.singlethreaded=true). > >> Is there a secret setting that has a different default with JAWS? > > NPEs look like a bug, either in AWT/FX, or in your application. I really > doubt it's related to Java Web Start. Could you provide a test to reproduce > the exceptions, please? > > Thanks, > > Artem > >> jeff >> >> >> On Aug 7, 2013, at 5:06 AM, Artem Ananiev wrote: >> >>> Hi, Pedro Duque Vieira, >>> >>> this is in progress. JDK part is tracked in 8015477: >>> >>> http://bugs.sun.com/view_bug.do?bug_id=8015477 >>> >>> JavaFX part is described in RT-30694: >>> >>> https://javafx-jira.kenai.com/browse/RT-30694 >>> >>> Note that in JDK8/JavaFX8 single-threaded mode will not be a part of public >>> API, it will be an experimental feature. >>> >>> Thanks, >>> >>> Artem >>> >>> On 8/7/2013 2:43 AM, Pedro Duque Vieira wrote: Hi, Some time ago there was a patch submitted which for all purposes merged the swing and javafx thread, making it easier for developers working on a swing/javafx app - http://wiki.apidesign.org/wiki/JavaFX Is this available now (I was under the impression it is)? How do I use it? Thanks in advance,
Re: Swing and JavaFX thread merge
Hello. I've just pushed the fix to the repo, so it should be available in a couple of builds. However, it is an experimental feature, so we lack the documentation or examples on it. If you experience any issues with it - please contact me. > As I wrote, it won't work by default in JDK8, you'll need to run your app > with certain system property (something like > -Djavafx.swing.singlethreaded=true) It's -Djavafx.embed.singleThread=true With best regards. Petr. On Aug 8, 2013, at 3:50 PM, Artem Ananiev wrote: > > On 8/8/2013 1:45 AM, Jeff Martin wrote: >> I thought I was getting this automatically - when I run on my >> desktop, I can bring up a JOptionPane from a Swing thread and >> JFXPanels (correctly) block. But when I run from Java Web Start, they >> don't, and I end up with sporadic SwingUtilities.computeIntersection >> NullPointerException. > > Once these two JDK/JavaFX bugs are resolved, scenario with JOptionPane you > described will work. As I wrote, it won't work by default in JDK8, you'll > need to run your app with certain system property (something like > -Djavafx.swing.singlethreaded=true). > >> Is there a secret setting that has a different default with JAWS? > > NPEs look like a bug, either in AWT/FX, or in your application. I really > doubt it's related to Java Web Start. Could you provide a test to reproduce > the exceptions, please? > > Thanks, > > Artem > >> jeff >> >> >> On Aug 7, 2013, at 5:06 AM, Artem Ananiev wrote: >> >>> Hi, Pedro Duque Vieira, >>> >>> this is in progress. JDK part is tracked in 8015477: >>> >>> http://bugs.sun.com/view_bug.do?bug_id=8015477 >>> >>> JavaFX part is described in RT-30694: >>> >>> https://javafx-jira.kenai.com/browse/RT-30694 >>> >>> Note that in JDK8/JavaFX8 single-threaded mode will not be a part of public >>> API, it will be an experimental feature. >>> >>> Thanks, >>> >>> Artem >>> >>> On 8/7/2013 2:43 AM, Pedro Duque Vieira wrote: Hi, Some time ago there was a patch submitted which for all purposes merged the swing and javafx thread, making it easier for developers working on a swing/javafx app - http://wiki.apidesign.org/wiki/JavaFX Is this available now (I was under the impression it is)? How do I use it? Thanks in advance, >>
Re: Swing and JavaFX thread merge
On 8/8/2013 1:45 AM, Jeff Martin wrote: I thought I was getting this automatically - when I run on my desktop, I can bring up a JOptionPane from a Swing thread and JFXPanels (correctly) block. But when I run from Java Web Start, they don't, and I end up with sporadic SwingUtilities.computeIntersection NullPointerException. Once these two JDK/JavaFX bugs are resolved, scenario with JOptionPane you described will work. As I wrote, it won't work by default in JDK8, you'll need to run your app with certain system property (something like -Djavafx.swing.singlethreaded=true). Is there a secret setting that has a different default with JAWS? NPEs look like a bug, either in AWT/FX, or in your application. I really doubt it's related to Java Web Start. Could you provide a test to reproduce the exceptions, please? Thanks, Artem jeff On Aug 7, 2013, at 5:06 AM, Artem Ananiev wrote: Hi, Pedro Duque Vieira, this is in progress. JDK part is tracked in 8015477: http://bugs.sun.com/view_bug.do?bug_id=8015477 JavaFX part is described in RT-30694: https://javafx-jira.kenai.com/browse/RT-30694 Note that in JDK8/JavaFX8 single-threaded mode will not be a part of public API, it will be an experimental feature. Thanks, Artem On 8/7/2013 2:43 AM, Pedro Duque Vieira wrote: Hi, Some time ago there was a patch submitted which for all purposes merged the swing and javafx thread, making it easier for developers working on a swing/javafx app - http://wiki.apidesign.org/wiki/JavaFX Is this available now (I was under the impression it is)? How do I use it? Thanks in advance,
Re: Swing and JavaFX thread merge
I thought I was getting this automatically - when I run on my desktop, I can bring up a JOptionPane from a Swing thread and JFXPanels (correctly) block. But when I run from Java Web Start, they don't, and I end up with sporadic SwingUtilities.computeIntersection NullPointerException. Is there a secret setting that has a different default with JAWS? jeff On Aug 7, 2013, at 5:06 AM, Artem Ananiev wrote: > Hi, Pedro Duque Vieira, > > this is in progress. JDK part is tracked in 8015477: > > http://bugs.sun.com/view_bug.do?bug_id=8015477 > > JavaFX part is described in RT-30694: > > https://javafx-jira.kenai.com/browse/RT-30694 > > Note that in JDK8/JavaFX8 single-threaded mode will not be a part of public > API, it will be an experimental feature. > > Thanks, > > Artem > > On 8/7/2013 2:43 AM, Pedro Duque Vieira wrote: >> Hi, >> >> Some time ago there was a patch submitted which for all purposes merged the >> swing and javafx thread, making it easier for developers working on a >> swing/javafx app - http://wiki.apidesign.org/wiki/JavaFX >> >> Is this available now (I was under the impression it is)? How do I use it? >> >> Thanks in advance, >>
Re: Swing and JavaFX thread merge
Hi, Pedro Duque Vieira, this is in progress. JDK part is tracked in 8015477: http://bugs.sun.com/view_bug.do?bug_id=8015477 JavaFX part is described in RT-30694: https://javafx-jira.kenai.com/browse/RT-30694 Note that in JDK8/JavaFX8 single-threaded mode will not be a part of public API, it will be an experimental feature. Thanks, Artem On 8/7/2013 2:43 AM, Pedro Duque Vieira wrote: Hi, Some time ago there was a patch submitted which for all purposes merged the swing and javafx thread, making it easier for developers working on a swing/javafx app - http://wiki.apidesign.org/wiki/JavaFX Is this available now (I was under the impression it is)? How do I use it? Thanks in advance,
Swing and JavaFX thread merge
Hi, Some time ago there was a patch submitted which for all purposes merged the swing and javafx thread, making it easier for developers working on a swing/javafx app - http://wiki.apidesign.org/wiki/JavaFX Is this available now (I was under the impression it is)? How do I use it? Thanks in advance, -- Pedro Duque Vieira