-
Bug
-
Resolution: Duplicate
-
P3
-
8u111
-
x86_64
-
windows_7
FULL PRODUCT VERSION :
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
JavaFX code which has worked in previous builds of Java 8 has become unstable and unusable since update 111.
Adding a Java object to javascript does not run on every action. It may work after at least one reload of the page but it is not consistent.
REGRESSION. Last worked in version 8u101
ADDITIONAL REGRESSION INFORMATION:
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a JavaFX application using WebEngine and set the JSObject and set a Java Object member. A simple one that closes the application is sufficient. In the Javascript on a HTML page try to call the method from the Java Object. Use Java 1.8.0_111 or 112 to compile and run the code. If you change back to Java 1.8.0_101 to compile and run the same code it works.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Nothing happens
ACTUAL -
The application should close
ERROR MESSAGES/STACK TRACES THAT OCCUR :
No Errors
REPRODUCIBILITY :
This bug can be reproduced often.
---------- BEGIN SOURCE ----------
package com.groundsure.javafxtest;
import javafx.application.Application;
import static javafx.application.Application.launch;
import javafx.application.Platform;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.concurrent.Worker;
import javafx.scene.Scene;
import javafx.scene.layout.Region;
import javafx.scene.paint.Color;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
import netscape.javascript.JSObject;
public class MainApp extends Application {
private Stage stage;
@Override
public void start(Stage stage) throws Exception {
this.stage = stage;
this.stage.setTitle("Test");
this.stage.setScene(new Scene(new WebPage(this),1350,750, Color.web("#666970")));
stage.show();
}
public class WebPage extends Region {
final WebView browser = new WebView();
final WebEngine webEngine = browser.getEngine();
public WebPage(final Application main) {
getChildren().add(browser);
webEngine.loadContent("</div><br /><div onClick='app.exit();' width='100' height='50'>" +
"Exit</div>");
webEngine.getLoadWorker().stateProperty().addListener(new ChangeListener<Worker.State>() {
@Override
public void changed(ObservableValue<? extends Worker.State> observableValue, Worker.State state, Worker.State newState) {
if (newState.equals(Worker.State.SUCCEEDED)) {
JSObject win = (JSObject) webEngine.executeScript("window");
win.setMember("app", new App());
}
}
});
}
}
public class App {
public void exit() {
Platform.exit();
}
}
public static void main(String[] args) {
launch(args);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Not using the latest version of java
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
JavaFX code which has worked in previous builds of Java 8 has become unstable and unusable since update 111.
Adding a Java object to javascript does not run on every action. It may work after at least one reload of the page but it is not consistent.
REGRESSION. Last worked in version 8u101
ADDITIONAL REGRESSION INFORMATION:
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a JavaFX application using WebEngine and set the JSObject and set a Java Object member. A simple one that closes the application is sufficient. In the Javascript on a HTML page try to call the method from the Java Object. Use Java 1.8.0_111 or 112 to compile and run the code. If you change back to Java 1.8.0_101 to compile and run the same code it works.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Nothing happens
ACTUAL -
The application should close
ERROR MESSAGES/STACK TRACES THAT OCCUR :
No Errors
REPRODUCIBILITY :
This bug can be reproduced often.
---------- BEGIN SOURCE ----------
package com.groundsure.javafxtest;
import javafx.application.Application;
import static javafx.application.Application.launch;
import javafx.application.Platform;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.concurrent.Worker;
import javafx.scene.Scene;
import javafx.scene.layout.Region;
import javafx.scene.paint.Color;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
import netscape.javascript.JSObject;
public class MainApp extends Application {
private Stage stage;
@Override
public void start(Stage stage) throws Exception {
this.stage = stage;
this.stage.setTitle("Test");
this.stage.setScene(new Scene(new WebPage(this),1350,750, Color.web("#666970")));
stage.show();
}
public class WebPage extends Region {
final WebView browser = new WebView();
final WebEngine webEngine = browser.getEngine();
public WebPage(final Application main) {
getChildren().add(browser);
webEngine.loadContent("</div><br /><div onClick='app.exit();' width='100' height='50'>" +
"Exit</div>");
webEngine.getLoadWorker().stateProperty().addListener(new ChangeListener<Worker.State>() {
@Override
public void changed(ObservableValue<? extends Worker.State> observableValue, Worker.State state, Worker.State newState) {
if (newState.equals(Worker.State.SUCCEEDED)) {
JSObject win = (JSObject) webEngine.executeScript("window");
win.setMember("app", new App());
}
}
});
}
}
public class App {
public void exit() {
Platform.exit();
}
}
public static void main(String[] args) {
launch(args);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Not using the latest version of java
- duplicates
-
JDK-8089681 WebView leaks memory when containing object acts as javascript callback handler
-
- Resolved
-
- relates to
-
JDK-8171401 Release Note: Fixed memory leak when Java objects are passed into JavaScript
-
- Closed
-