1

Recently adding a WebView pane to my JavaFX Application. When resizing my program I get this error and the program freezes.

java.lang.NullPointerException
    at com.sun.javafx.webkit.prism.WCPageBackBufferImpl.validate(WCPageBackBufferImpl.java:97)
    at com.sun.webkit.WebPage.paint(WebPage.java:644)
    at com.sun.javafx.sg.prism.NGWebView.renderContent(NGWebView.java:95)
    at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2067)
    at com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1959)
    at com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:235)
    at com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:576)
    at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2067)
    at com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1959)
    at com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:235)
    at com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:576)
    at com.sun.javafx.sg.prism.NGNode.renderForClip(NGNode.java:2308)
    at com.sun.javafx.sg.prism.NGNode.renderRectClip(NGNode.java:2202)
    at com.sun.javafx.sg.prism.NGNode.renderClip(NGNode.java:2228)
    at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2061)
    at com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1959)
    at com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:235)
    at com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:576)
    at com.sun.javafx.sg.prism.NGNode.renderForClip(NGNode.java:2308)
    at com.sun.javafx.sg.prism.NGNode.renderRectClip(NGNode.java:2202)
    at com.sun.javafx.sg.prism.NGNode.renderClip(NGNode.java:2228)
    at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2061)
    at com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1959)
    at com.sun.javafx.tk.quantum.ViewPainter.doPaint(ViewPainter.java:474)
    at com.sun.javafx.tk.quantum.ViewPainter.paintImpl(ViewPainter.java:327)
    at com.sun.javafx.tk.quantum.PresentingPainter.run(PresentingPainter.java:91)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
    at com.sun.javafx.tk.RenderJob.run(RenderJob.java:58)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:125)
    at java.lang.Thread.run(Thread.java:745)

The website that the webview goes to is

http://www.abendigo.org/gui/

Can someone tell me what causes this issue?

Edit: Not sure why this is needed, but here is the code as requested:

public class Controller implements Initializable {

    @FXML
    public WebView webView;

    @Override
    public void initialize(URL location, ResourceBundle resources) {
        webView.getEngine().load("http://abendigo.org/gui/");
    }

}

Video of bug reproduction: https://youtu.be/6CLPt45AbW0

4
  • Can you post the code? The error message can only be so helpful without code. Commented Aug 10, 2015 at 1:47
  • I cannot reproduce this. What JDK version and platform are you using? Can you post your code in the form of an MCVE Commented Aug 10, 2015 at 2:07
  • I've uploaded a video of me reproducing the bug myself. Also happens on my partners computer. Commented Aug 10, 2015 at 2:14
  • This exception reproduces on OS X 10.9.5, Java 8u60, only after continually manually resizing the window for a minute or two. Related bug report link. Commented Oct 7, 2015 at 19:24

1 Answer 1

4

I was faced with the same bug. It was quite difficult to find the reason. At last, I found : webView layout throw a nullPointerExpection when width or height is too large, ie over 8500 pixel.

And the good bypass was too limit the maxWidth/maxHeight of the webView to scene size :

 webView.sceneProperty().addListener(new ChangeListener<Scene>() {

        @Override
        public void changed(ObservableValue<? extends Scene> observable, Scene oldValue, Scene scene) {
            if (scene != null) {
                webView.setMaxSize(getScene().getWidth(), getScene().getHeight());
                webView.maxWidthProperty().bind(getScene().widthProperty());
                webView.maxHeightProperty().bind(getScene().heightProperty());
            } else {
                webView.maxWidthProperty().unbind();
                webView.maxHeightProperty().unbind();
            }
        }
    });
Sign up to request clarification or add additional context in comments.

2 Comments

Where should I apply the code?! Also for canvas, my webview actually limited to the scale, and it still have the issue.
On the webview itself (I updated my answer so that it is more readable). For canvas, I let you try.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.