genericworkflownodes / GenericKnimeNodes

Base package for GenericKnimeNodes
https://github.com/genericworkflownodes/GenericKnimeNodes
Other
15 stars 16 forks source link

Config dialog for GKNodes crashes under Linux with GTK3 #134

Closed kneubert closed 7 years ago

kneubert commented 8 years ago

When not using the fallback solution to use GTK2 by setting an environment variable, some (presumably all) Generic Knime Nodes crash when opening the configuration dialog. All extension nodes like the Input File node (...) that do not implement the GnericKnimeNodeModel interface work fine. I debugged a bit into the code and it fails at https://github.com/genericworkflownodes/GenericKnimeNodes/blob/develop/com.genericworkflownodes.knime/src/com/genericworkflownodes/knime/generic_node/dialogs/param_dialog/ParameterDialog.java#L217

Seems like the JXTreeTable is not supported by the KNIME3.1.2/Debian8 combination that I have. The same crashes occur on other KNIME 3.x versions and on other Linuxes.

You can find the log here: https://gist.github.com/kneubert/a9edab99e5bc2d90ce0ca7a450f580a2

jpfeuffer commented 8 years ago

Okay. Doing some heavy googling, the most probable reason that I found is the one from here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=438598

It seems like JXTreeTable is an AWT/Swing component and with certain Java versions (presumably > 1.8.0) AWT is linked to/using the GTK2 libraries when using the "Native GTK+ Look and Feel" of the widgets. Since Eclipse, which is using SWT, is using GTK3 (unless you disable it with the environment variable) you have your crash.

If that is the true reason, there are two solutions:

jpfeuffer commented 8 years ago

@AlexanderFillbrunn Can you comment on (or ask one of your colleagues) what the preferred GUI libraries for the configuration dialogues are?

jpfeuffer commented 8 years ago

@aiche @chahuistle Maybe you can say something about the origins of this code and potential pitfalls changing it.

aiche commented 8 years ago

If I remember correctly, at the time of writing the code, KNIME supported only swing based dialogues (and the Developer Guide still says so) which lead to us to using JXTreeTable to implement the hierarchical, tree-like parameter dialog. So from that point of view, switching to SWT is not possible. Which leaves only option b

Quick: Change the look and feel away from the GTK one, using methods here http://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html

jpfeuffer commented 8 years ago

Ah, I see @aiche . You are right. I think changing the Look and Feel would be the correct way to go forward on this one. @kneubert Since I know that you have everything set up already on your machine, can you try the fix by adding something like this:

    try {
            // Set cross-platform Java L&F (also called "Metal")
        UIManager.setLookAndFeel(
            UIManager.getCrossPlatformLookAndFeelClassName());
    } 
    catch (UnsupportedLookAndFeelException e) {
       // handle exception
    }
    catch (ClassNotFoundException e) {
       // handle exception
    }
    catch (InstantiationException e) {
       // handle exception
    }
    catch (IllegalAccessException e) {
       // handle exception
    }

before the dialog is created? We can then file a pull request together.

kneubert commented 8 years ago

@jpfeuffer: I changed the L&F to the "Metal" L&F (javax.swing.plaf.metal.MetalLookAndFeel) before the dialog is created, but it did not prevent the crash. A call of the UIManager.getLookAndFeel() function informed me that the "Metal" L&F or "CrossPlatformLookAndFeel" is already set. Setting the GTK look and feel (com.sun.java.swing.plaf.gtk.GTKLookAndFeel) the KNIME app. indeed invokes a crash before the JXTreeTable is build.

Does SwingX's JXTreeTable use GTK+/GLib, since it is a "pure Swing" implementation? Why are the other Swing components from the KNIME nodes not a problem?

jpfeuffer commented 8 years ago

JXTreeTable is from a thirdparty extension that we provide with our package (org.jdesktop.swingx).

Ok my last guesses:

An idea would be to use the new JavaFX UI library that is supposed to become the standard. They also provide a TreeTable. This will break some early KNIME versions since it is only available in Java 8. It seems to be possible to include them into Swing panels.

kneubert commented 8 years ago

I could not figure out which component of AWT causes the problem here. A call to the constructor of the JXTreeTable or JXTable alone results in the crash of KNIME.

@aiche: I wonder why you have chosen a TreeTable instead of just a Table for the parameter lists? Are there GKNodes with a parameter list that have more than one tree root?

JavaFX UI seems to be an alternative, and there is good documentation out there.

In Java9 they will eventually address this problem: http://www.infoworld.com/article/3035505/java/java-9-to-address-gtk-gui-pains-on-linux.html

jpfeuffer commented 7 years ago

If someone has the time: http://www.hameister.org/JavaSwingTreeTable.html We could also think about using just Tables or as @alexanderfillbrunn suggested, switch to pure JComponents in a GridBagLayout with ExpanderBars.

timosachsenberg commented 7 years ago

can we label this as a blocker or critical issue (I can't)? It prevents our KNIME plugin to be usable on linux

jpfeuffer commented 7 years ago

I agree. I will mention all GKN and deNBI associates, too. @chahuistle @rrahn

jpfeuffer commented 7 years ago

Please, please someone test the pull request on Linux. @rrahn @kneubert @chahuistle @mwalzer @timosachsenberg

jpfeuffer commented 7 years ago

If it is not tested until tomorrow, it will sleep for at least another 4 weeks and will not be in the KNIME 3.3 release packages.

kneubert commented 7 years ago

@jpfeuffer: It works on my Linux machine (Eclipse SDK 4.5.2, KNIME Version 3.1.2).

jpfeuffer commented 7 years ago

Solved in #147. Please reopen, if something is not right.