JDK-8346250 : Native methods missing in libjfxwebkit.so to create websockets
  • Type: Bug
  • Component: javafx
  • Sub-Component: web
  • Affected Version: jfx17
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2024-12-11
  • Updated: 2024-12-16
  • Resolved: 2024-12-16
Related Reports
Duplicate :  
Description
A DESCRIPTION OF THE PROBLEM :
The use of websockets in linux currently results in a “java.lang.UnsatisfiedLinkError: 'void com.sun.webkit.network.SocketStreamHandle.twkDidOpen(long)” due to missing symbols in libjfxwebkit.so.
These symbols seem to be present in windows and MacOS, but they were removed in linux during the upgrade to Webkit 617.1. 
(https://github.com/openjdk/jfx/commit/ba79e081547b7f15697bfaaac42ec2de1971935a) 
Comparing the mapfile-vers with mapfile-macosx confirms the missing “SocketStreamHandle” symbols.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : 
Try to establish a websocket communication on a linux device.
Minimal example to reproduce:

1. Java file "WebViewTest.java"

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.web.WebView;
import javafx.stage.Stage;

public class WebViewTest extends Application {

    @Override
    public void start(Stage stage) {
        WebView webView = new WebView();
        webView.getEngine().load(http://localhost:8000);

        Scene scene = new Scene(webView, 800, 600);
        stage.setScene(scene);

        stage.setTitle("TEST");
        stage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}

2. “index.html” which shows an alert when connection establishes
<html>
<h1>Text Page</h1>
<button id='errorbutton' href="">Send ws data</button>
<script type="text/javascript">
    var btn = document.getElementById('errorbutton');


    btn.onclick = function () {
        supportsWebSockets = 'WebSocket' in window || 'MozWebSocket' in window;
        if (supportsWebSockets) {
            console.log("WEBSOCKET SUPPORTED")
        }
        else {
            console.log("WEBSOCKET NOT SUPPORTED")
        }

        const ws = new WebSocket('wss://echo.websocket.org/')

        ws.onopen = () => {
            console.log('ws opened on browser')
            alert("[open] Connection established");
            console.log(ws.readyState)
        }

        ws.onmessage = (message) => {
            console.log(`message received`, message.data)
            alert(message.data);
        }

        ws.onerror = (message) => {
            console.log(`message received`, message.data)
        }
        console.log(ws.readyState)
    }
</script>
<p id="p">test</p>

</html>

Running the example:
Host index.html to localhost:8000 (for example “python3 -m http.server”)
Run the WebviewTest.java with javafx-web dependency (17.0.13+)
Click the button on the page to create a websocket.


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
A popup occurring due to a websocket connection establishing.
ACTUAL -
No alert +
Exception in thread "JavaFX Application Thread" java.lang.UnsatisfiedLinkError: 'void com.sun.webkit.network.SocketStreamHandle.twkDidOpen(long)'
        at javafx.web/com.sun.webkit.network.SocketStreamHandle.twkDidOpen(Native Method)
        at javafx.web/com.sun.webkit.network.SocketStreamHandle.notifyDidOpen(SocketStreamHandle.java:361)
        at javafx.web/com.sun.webkit.network.SocketStreamHandle.lambda$didOpen$3(SocketStreamHandle.java:330)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:457)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:456)
        at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
        at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
        at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(GtkApplication.java:290)
        at java.base/java.lang.Thread.run(Thread.java:840)
Exception in thread "JavaFX Application Thread" java.lang.UnsatisfiedLinkError: 'void com.sun.webkit.network.SocketStreamHandle.twkDidClose(long)'
        at javafx.web/com.sun.webkit.network.SocketStreamHandle.twkDidClose(Native Method)
        at javafx.web/com.sun.webkit.network.SocketStreamHandle.notifyDidClose(SocketStreamHandle.java:383)
        at javafx.web/com.sun.webkit.network.SocketStreamHandle.lambda$didClose$6(SocketStreamHandle.java:354)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:457)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:456)
        at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
        at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
        at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(GtkApplication.java:290)
        at java.base/java.lang.Thread.run(Thread.java:840)


CUSTOMER SUBMITTED WORKAROUND :
Downgrading to 17.0.10


Comments
This is a duplicate of JDK-8331765.
12-12-2024