JDK-8193493 : WebView fails to render content when opened inside of an Alert (or Dialog)
  • Type: Bug
  • Component: javafx
  • Sub-Component: web
  • Affected Version: 9.0.1
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: other
  • CPU: x86
  • Submitted: 2017-12-13
  • Updated: 2017-12-14
  • Resolved: 2017-12-14
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "9.0.1"
Java(TM) SE Runtime Environment (build 9.0.1+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 10.0.16299.64]

A DESCRIPTION OF THE PROBLEM :
When an Alert uses a WebView in its content - the html is not rendered.




REGRESSION.  Last worked in version 8u162

ADDITIONAL REGRESSION INFORMATION: 
I have validate with JDK 1.8.0_162 that the contents of the WebView are rendered correctly as expected. I used the exact same code snippet mentioned below (steps to reproduce section).

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Build the following code and run with Java 9.0.1
Click the button and the alert pops up, however the WebView content is not rendered


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
webview content should be rendered and visible in the alert
ACTUAL -
webview content is not rendered, the alert is empty

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Button;
import javafx.scene.layout.Pane;
import javafx.scene.layout.StackPane;
import javafx.scene.web.WebView;
import javafx.stage.Stage;

public class Broken extends Application {
    @Override
    public void start(Stage stage) {
        stage.setTitle("No WebView!");

        Button button = new Button("Open Alert");
        button.setOnMouseClicked(event -> {
            WebView webView = new WebView();
            webView.getEngine().load("http://example.com");

            StackPane pane = new StackPane(webView);
            pane.setPrefSize(500, 400);

            Alert alert = new Alert(Alert.AlertType.INFORMATION);
            alert.getDialogPane().setHeader(new Pane());
            alert.setTitle("dialog shows nothing");
            alert.getDialogPane().setContent(pane);
            alert.showAndWait();
        });

        StackPane pane = new StackPane(button);
        stage.setScene(new Scene(pane, 800, 600));

        stage.show();
    }

    public static void main(String[] args) {
        Application.launch(args);
    }
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
none really, but I have found that showing a WebView within a new Stage (rather than using a dialog) works fine.


Comments
This has been fixed in 10-ea+32. Closing as Duplicate of JDK-8190349
14-12-2017