Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include Media and Webkit in OpenJFX #26

Open
davecurrie opened this issue Nov 26, 2018 · 30 comments
Assignees
Labels

Comments

@davecurrie
Copy link
Contributor

@davecurrie davecurrie commented Nov 26, 2018

Is your feature request related to a problem?

The OpenJFX build bundled in Corretto doesn't include codecs or Webkit

Describe a solution you would like

License and build codecs, build Webkit, and include as part of Corretto

Describe alternatives you have considered

Right now, the alternative is to custom-build my own OpenJFX

@davecurrie davecurrie self-assigned this Nov 26, 2018
@bekwam

This comment has been minimized.

Copy link

@bekwam bekwam commented Nov 26, 2018

Here's a test program that will throw a Linker exception on a missing glib-lite.dll on Windows.

public class PlayAudio extends Application {

    @Override
    public void start(Stage primaryStage) throws Exception {

        Button b = new Button("Play");
        b.setOnAction(
                evt -> {

                    AudioClip clip = new AudioClip("file:///D:/audofile.wav");
                    clip.play();
                }
        );
        Scene scene = new Scene( b, 480, 320 );

        primaryStage.setScene( scene );
        primaryStage.show();
    }
}
@davecurrie davecurrie changed the title Include Media and Webkits in OpenJFX Include Media and Webkit in OpenJFX Nov 27, 2018
@davecurrie

This comment has been minimized.

Copy link
Contributor Author

@davecurrie davecurrie commented Nov 27, 2018

@bekwam Thanks for the test case.

@davecurrie davecurrie added this to the Under Discussion milestone Dec 7, 2018
@kimomon

This comment has been minimized.

Copy link

@kimomon kimomon commented Dec 17, 2018

Mac PKG already has webkit.

/Library/Java/JavaVirtualMachines/amazon-corretto-8.jdk/Contents/Home/jre/lib/libjfxwebkit.dylib

Are there plans to add in windows?

@davecurrie

This comment has been minimized.

Copy link
Contributor Author

@davecurrie davecurrie commented Dec 21, 2018

@kimomon We don't have any concrete plans about that yet but are tracking the request in this issue.

@kimomon

This comment has been minimized.

Copy link

@kimomon kimomon commented Dec 25, 2018

Thank you.
In preview2 it had disappeared from MacPKG.
I would like you to include it.

@jinsihou19

This comment has been minimized.

Copy link

@jinsihou19 jinsihou19 commented Dec 27, 2018

I am also in need of this request.

@jinsihou19

This comment has been minimized.

Copy link

@jinsihou19 jinsihou19 commented Dec 27, 2018

Here are test case that will throw a Linker exception on a missing libjfxwebkit.dylib on mac.

import javafx.application.Platform;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.embed.swing.JFXPanel;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebEvent;
import javafx.scene.web.WebView;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.net.MalformedURLException;
import java.net.URL;

import static javafx.concurrent.Worker.State.FAILED;

public class SimpleSwingBrowser extends JFrame {

    private final JFXPanel jfxPanel = new JFXPanel();
    private WebEngine engine;

    private final JPanel panel = new JPanel(new BorderLayout());
    private final JLabel lblStatus = new JLabel();

    private final JButton btnGo = new JButton("Go");
    private final JTextField txtURL = new JTextField();
    private final JProgressBar progressBar = new JProgressBar();

    public SimpleSwingBrowser() {
        super();
        initComponents();
    }

    private void initComponents() {
        createScene();

        ActionListener al = new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                loadURL(txtURL.getText());
            }
        };

        btnGo.addActionListener(al);
        txtURL.addActionListener(al);

        progressBar.setPreferredSize(new Dimension(150, 18));
        progressBar.setStringPainted(true);

        JPanel topBar = new JPanel(new BorderLayout(5, 0));
        topBar.setBorder(BorderFactory.createEmptyBorder(3, 5, 3, 5));
        topBar.add(txtURL, BorderLayout.CENTER);
        topBar.add(btnGo, BorderLayout.EAST);

        JPanel statusBar = new JPanel(new BorderLayout(5, 0));
        statusBar.setBorder(BorderFactory.createEmptyBorder(3, 5, 3, 5));
        statusBar.add(lblStatus, BorderLayout.CENTER);
        statusBar.add(progressBar, BorderLayout.EAST);

        panel.add(topBar, BorderLayout.NORTH);
        panel.add(jfxPanel, BorderLayout.CENTER);
        panel.add(statusBar, BorderLayout.SOUTH);

        getContentPane().add(panel);

        setPreferredSize(new Dimension(1024, 600));
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        pack();
    }

    private void createScene() {

        Platform.runLater(new Runnable() {
            @Override
            public void run() {

                WebView view = new WebView();
                engine = view.getEngine();

                engine.titleProperty().addListener(new ChangeListener<String>() {
                    @Override
                    public void changed(ObservableValue<? extends String> observable, String oldValue, final String newValue) {
                        SwingUtilities.invokeLater(new Runnable() {
                            @Override
                            public void run() {
                                SimpleSwingBrowser.this.setTitle(newValue);
                            }
                        });
                    }
                });

                engine.setOnStatusChanged(new EventHandler<WebEvent<String>>() {
                    @Override
                    public void handle(final WebEvent<String> event) {
                        SwingUtilities.invokeLater(new Runnable() {
                            @Override
                            public void run() {
                                lblStatus.setText(event.getData());
                            }
                        });
                    }
                });

                engine.locationProperty().addListener(new ChangeListener<String>() {
                    @Override
                    public void changed(ObservableValue<? extends String> ov, String oldValue, final String newValue) {
                        SwingUtilities.invokeLater(new Runnable() {
                            @Override
                            public void run() {
                                txtURL.setText(newValue);
                            }
                        });
                    }
                });

                engine.getLoadWorker().workDoneProperty().addListener(new ChangeListener<Number>() {
                    @Override
                    public void changed(ObservableValue<? extends Number> observableValue, Number oldValue, final Number newValue) {
                        SwingUtilities.invokeLater(new Runnable() {
                            @Override
                            public void run() {
                                progressBar.setValue(newValue.intValue());
                            }
                        });
                    }
                });

                engine.getLoadWorker()
                        .exceptionProperty()
                        .addListener(new ChangeListener<Throwable>() {

                            @Override
                            public void changed(ObservableValue<? extends Throwable> o, Throwable old, final Throwable value) {
                                if (engine.getLoadWorker().getState() == FAILED) {
                                    SwingUtilities.invokeLater(new Runnable() {
                                        @Override
                                        public void run() {
                                            JOptionPane.showMessageDialog(
                                                    panel,
                                                    (value != null)
                                                            ? engine.getLocation() + "\n" + value.getMessage()
                                                            : engine.getLocation() + "\nUnexpected error.",
                                                    "Loading error...",
                                                    JOptionPane.ERROR_MESSAGE);
                                        }
                                    });
                                }
                            }
                        });

                jfxPanel.setScene(new Scene(view));
            }
        });
    }

    public void loadURL(final String url) {
        Platform.runLater(new Runnable() {
            @Override
            public void run() {
                String tmp = toURL(url);

                if (tmp == null) {
                    tmp = toURL("http://" + url);
                }

                engine.load(tmp);
            }
        });
    }

    private static String toURL(String str) {
        try {
            return new URL(str).toExternalForm();
        } catch (MalformedURLException exception) {
            return null;
        }
    }

    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {

            @Override
            public void run() {
                SimpleSwingBrowser browser = new SimpleSwingBrowser();
                browser.setVisible(true);
                browser.loadURL("http://openjdk.java.net/");
            }
        });
    }
}
@joha78

This comment has been minimized.

Copy link

@joha78 joha78 commented Jan 3, 2019

The website says Corretto is a "drop in replacement" for java 8. If it really is, this should be resolved. Am I wrong?

@davecurrie

This comment has been minimized.

Copy link
Contributor Author

@davecurrie davecurrie commented Jan 22, 2019

Hi @joha78. The full quote (from the announcement blog post) is: "Corretto is designed as a drop-in replacement for all Java SE distributions unless you’re using features not available in OpenJDK". These components fall into the category of features not available in OpenJDK.

However, we appreciate that the situation is not ideal and are looking seriously at the best way to close this gap for everyone.

Thanks

@bekwam

This comment has been minimized.

Copy link

@bekwam bekwam commented Jan 22, 2019

@davecurrie JavaFX is already in Corretto, but select parts of the included Java code are broken. See my AudioClip test case.

Here's what I do to add JavaFX Media into an Open JDK 8 distro. (no WebKit)

https://courses.bekwam.net/public_tutorials/bkcourse_building_openjfx_8_win.html

@berry120

This comment has been minimized.

Copy link

@berry120 berry120 commented Feb 19, 2019

I suspect the big issues here are licenses - some of the formats offered by Oracle's distribution of JavaFX are patent encumbered (MP3, H264, FLV) which means lawyers inevitably need to get involved to see this through, and that makes it a lot more expensive than just throwing some devs at it.

I for one though would be interested in seeing this support even if the format support was different from Oracle's distribution - there's free & open formats like VP6, FLAC, MKV, OGG for instance that could cover all the bases without getting into complicated legalities, and then additional format support could be bundled afterwards as and when the legal side of things was sorted.

@davecurrie

This comment has been minimized.

Copy link
Contributor Author

@davecurrie davecurrie commented Mar 12, 2019

@berry120 Licensing is definitely an issue we'd need to work through in order to provide a full JavaFX package. This is not a trivial issue to fix, which is why it's still in the "under discussion" milestone.

@compuguy

This comment has been minimized.

Copy link

@compuguy compuguy commented Mar 14, 2019

If enough of OpenJFX is included so the STIG viewer works, @davecurrie I'm fine with that.

@the-suspect2

This comment has been minimized.

Copy link

@the-suspect2 the-suspect2 commented Apr 17, 2019

Is the "java.lang.ClassNotFoundException: javafx.embed.swing.JFXPanel" error related to the lack of Webkit or Media?

@Prowler2

This comment has been minimized.

Copy link

@Prowler2 Prowler2 commented May 3, 2019

If enough of OpenJFX is included so the STIG viewer works, @davecurrie I'm fine with that.

@compuguy, Just tested this build of OpenJDK 8u212 from Belsoft and the STIG viewer (v2.8 and v2.9) work fine on Windows 10 1803.

https://bell-sw.com/pages/java-8u212

@thenefield

This comment has been minimized.

Copy link

@thenefield thenefield commented May 15, 2019

If enough of OpenJFX is included so the STIG viewer works, @davecurrie I'm fine with that.

@compuguy, Just tested this build of OpenJDK 8u212 from Belsoft and the STIG viewer (v2.8 and v2.9) work fine on Windows 10 1803.

https://bell-sw.com/pages/java-8u212

This works well for me too with STIG Viewer, but not for UniFi Controller software. No winning solution here that works all around.

I have also compiled OpenJDK 11 and separately compiled in JavaFX from here (https://gluonhq.com/products/javafx/) and works great with STIG Viewer, but not the latter.

@Prowler2

This comment has been minimized.

@thukk

This comment has been minimized.

Copy link

@thukk thukk commented Jul 18, 2019

FWIW - I copied libjfxwebkit.so from my Pycharm Community 2018.3.4 installation (~/pycharm/jre64/llib/amd64) to my Corretto libraries (/usr/lib/jvm/java-1.8...corretto/jre/lib/amd64/) and STIGViewer opened right up using 'java -jar STIGviewer.jar'.

@jschwartzenberg

This comment has been minimized.

Copy link

@jschwartzenberg jschwartzenberg commented Jul 29, 2019

Hi, it seems important to separate this into two tickets. WebKit is plain LGPL and does not have license issues. It's only the media part that is problematic. WebKit and the media support have separate switches to enable/disble them. Media support won't compile on many systems as they lack the required libraries. (On RHEL you need libraries from RPMFusion for instance.)

I created PR #150 that only enables WebKit. Some builds I did with it are here:
https://schwart6.home.xs4all.nl/corretto/

It was closed now however as there was confusion that WebKit itself also has licensing issues.

@Prowler2

This comment has been minimized.

Copy link

@Prowler2 Prowler2 commented Aug 1, 2019

If enough of OpenJFX is included so the STIG viewer works, @davecurrie I'm fine with that.

@compuguy, Just tested this build of OpenJDK 8u212 from Belsoft and the STIG viewer (v2.8 and v2.9) work fine on Windows 10 1803.
https://bell-sw.com/pages/java-8u212

This works well for me too with STIG Viewer, but not for UniFi Controller software. No winning solution here that works all around.

I have also compiled OpenJDK 11 and separately compiled in JavaFX from here (https://gluonhq.com/products/javafx/) and works great with STIG Viewer, but not the latter.

@compuguy, @thenefield - Azul (java vendor for Azure) now has jdk jre versions with the JavaFX included. You still need to modify the path settings and some registry keys to get it to execute jar files from windows explorer, but I have it working now. https://www.azul.com/downloads/zulu-community/?&package=jre-fx

@thenefield

This comment has been minimized.

Copy link

@thenefield thenefield commented Aug 1, 2019

@jschwartzenberg

This comment has been minimized.

Copy link

@jschwartzenberg jschwartzenberg commented Aug 2, 2019

Did anybody find the sources for the Bellsoft version? I mailed them some weeks ago and still did not receive a response. As far as I can see, they are violating the GPL. They do include webkit support though.

Regarding Azul, they want you to send them money after which they will ship a physical disc with their source code. I don't understand why they don't just publish their sources.

So indeed the RHEL version is by far the best option. I have been testing with both Corretto and RH's OpenJDK, but with RedHat's version everything just works. Only their Windows version includes OpenJFX with WebKit, but that is by far the most difficult version to build. I have built a GNU/Linux version myself that works fine on every system I've tested it on so far (RHEL6, Ubuntu 18.04):
https://schwart6.home.xs4all.nl/rhel6/openjdk/

I will update it to the new version soon. I hoped that Corretto would become a viable alternative, but unfortunately PRs are not handled on time and this makes Corretto unsuitable for what we need.

@matthiaszimmermann

This comment has been minimized.

Copy link

@matthiaszimmermann matthiaszimmermann commented Aug 15, 2019

@berry120 Licensing is definitely an issue we'd need to work through in order to provide a full JavaFX package. This is not a trivial issue to fix, which is why it's still in the "under discussion" milestone.

we find ourselves in the same position as @jschwartzenberg. can you share some details and a potential timeline to resolve the mentioned licencing issues and maybe confirm that these licencing issues are not related to the webkit part?

@jschwartzenberg

This comment has been minimized.

Copy link

@jschwartzenberg jschwartzenberg commented Aug 16, 2019

I had to enable to media plugin because WebKit would crash the JVM without it on most sites. I guess it's used for images as well. Fortunately I could easily disable the AVPlugin so everything still builds fine on a plain RHEL6 system. My sources for OpenJFX8: https://github.com/jschwartzenberg/openjfx8

If there's any interest from Corretto I can create another PR with the same patches.

@matthiaszimmermann most distributions ship a good OpenJDK. I'd recommend installing that then cloning my repo and doing sh ./gradlew zips. This should give you a zip file you can use as an overlay on top of the JDK. Moving forward, it would be nice to have RPMs on COPR and DEBs on Launchpad. Another option is the RHEL6 builds I did. I tested them on RHEL6, RHEL7, Fedora 30 and Ubuntu 16.04. On Windows there's ojdkbuild (from which I took most of the OpenJFX patches).

@nrmnrm

This comment has been minimized.

Copy link

@nrmnrm nrmnrm commented Sep 23, 2019

Is there any timeline for a fix? We are postponing our migration to corretto because of this for a while now

@jschwartzenberg

This comment has been minimized.

Copy link

@jschwartzenberg jschwartzenberg commented Sep 23, 2019

@nrmnrm which platforms are you looking at? Which JDK/JRE are you currently using?

@nrmnrm

This comment has been minimized.

Copy link

@nrmnrm nrmnrm commented Sep 24, 2019

Currently only Windows 32bit. At the moment we are stuck with the latest one from oracle

@jschwartzenberg

This comment has been minimized.

Copy link

@jschwartzenberg jschwartzenberg commented Sep 24, 2019

@nrmnrm then you can move to the ojdkbuild OpenJDK:
https://github.com/ojdkbuild/ojdkbuild

There are both 32-bit and 64-bit Windows builds with a fully patched OpenJFX. There's an updated WebKit included that also fixes security issues.

@nrmnrm

This comment has been minimized.

Copy link

@nrmnrm nrmnrm commented Sep 24, 2019

Thanks for the info. Unfortunately there was a company decision to go with corretto and we already did the release tests with that one. So i hope something will be done about this here as well

@jschwartzenberg

This comment has been minimized.

Copy link

@jschwartzenberg jschwartzenberg commented Sep 24, 2019

@nrmnrm do you know why that was decided? We considered Corretto as well, but when discovering the state of OpenJFX 8 in it and how PRs are handled, we had to move on.

OpenJFX 8 is not maintained anymore upstream and Corretto does not even pull in the latest fixes that were still done upstream back in January, but an older release tag. I created a PR that moves Corretto to the latest upstream OpenJFX 8 and add some patches from the ojdkbuild project on top of that, see #149. That PR has been ignored for multiple months now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
You can’t perform that action at this time.