Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8165757

Crash when using when using JFXPanel and WebEngine

    Details

    • Subcomponent:
      web
    • CPU:
      x86_64
    • OS:
      os_x

      Description

      FULL PRODUCT VERSION :
      java version "1.8.0_101"
      Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
      Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)

      FULL OS VERSION :
      OS X 10.9.5 (13F1911)

      A DESCRIPTION OF THE PROBLEM :
      I am working on the Apache JMeter project , we want to introduce JavaFX WebEngine.
      So we based our code on this :
      http://docs.oracle.com/javafx/2/swing/SimpleSwingBrowser.java.htm

      Loading some particular content, we get a JVM crash with generation of hs_err_pid files.

      I was able to reproduce the problem with the SimpleSwingBrowser class.

      THE PROBLEM WAS REPRODUCIBLE WITH -Xint FLAG: Yes

      THE PROBLEM WAS REPRODUCIBLE WITH -server FLAG: Yes

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Just run the class with the particular content that I need to attach.
      Where can I attach it ?

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      Expected result : Load the web page
      Actual result : JVM crash
      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      1 0x135519ab9 JSC::DFG::ByteCodeParser::setLocal(JSC::VirtualRegister, JSC::DFG::Node*, JSC::DFG::ByteCodeParser::SetMode)
      2 0x13550d1d2 JSC::DFG::ByteCodeParser::parseBlock(unsigned int)
      3 0x1355070ea JSC::DFG::ByteCodeParser::parseCodeBlock()
      4 0x1355065d5 JSC::DFG::ByteCodeParser::handleInlining(JSC::DFG::Node*, int, JSC::CallLinkStatus const&, int, int, unsigned int, JSC::CodeSpecializationKind)
      5 0x135504913 JSC::DFG::ByteCodeParser::handleCall(int, JSC::DFG::NodeType, JSC::CodeSpecializationKind, unsigned int, int, int, int)
      6 0x13550bd09 JSC::DFG::ByteCodeParser::parseBlock(unsigned int)
      7 0x1355070ea JSC::DFG::ByteCodeParser::parseCodeBlock()
      8 0x1355129c3 JSC::DFG::ByteCodeParser::parse()
      9 0x135512af9 JSC::DFG::parse(JSC::DFG::Graph&)
      10 0x13556ee77 JSC::DFG::Plan::compileInThreadImpl(JSC::DFG::LongLivedState&)
      11 0x13556eba0 JSC::DFG::Plan::compileInThread(JSC::DFG::LongLivedState&, JSC::DFG::ThreadData*)
      12 0x13554008d JSC::DFG::compile(JSC::VM&, JSC::CodeBlock*, JSC::CodeBlock*, JSC::DFG::CompilationMode, unsigned int, JSC::Operands<JSC::JSValue, JSC::OperandValueTraits<JSC::JSValue> > const&, WTF::PassRefPtr<JSC::DeferredCompilationCallback>)
      13 0x13564a94d operationOptimize
      14 0x5a01e6c9fd69
      15 0x5a01e6ca95fa
      16 0x5a01e6cab2bd
      17 0x5a01e6cb4f13
      18 0x135677b6a llint_op_call
      19 0x135677bd5 llint_op_call
      20 0x135677bd5 llint_op_call
      21 0x135677bd5 llint_op_call
      22 0x5a01e6c01aa0
      23 0x135677bd5 llint_op_call
      24 0x135672a37 callToJavaScript
      25 0x13562c4e3 JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*)
      26 0x1355e9089 JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&)
      27 0x135718ece JSC::call(JSC::ExecState*, JSC::JSValue, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&)
      28 0x134aa6b8c WebCore::JSMainThreadExecState::call(JSC::ExecState*, JSC::JSValue, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&)
      29 0x134ac0b06 WebCore::JSEventListener::handleEvent(WebCore::ScriptExecutionContext*, WebCore::Event*)
      30 0x134ca458e WebCore::EventTarget::fireEventListeners(WebCore::Event*, WebCore::EventTargetData*, WTF::Vector<WebCore::RegisteredEventListener, 1ul, WTF::CrashOnOverflow>&)
      31 0x134ca411e WebCore::EventTarget::fireEventListeners(WebCore::Event*)
      #
      # A fatal error has been detected by the Java Runtime Environment:
      #
      # SIGSEGV (0xb) at pc=0x000000013543b79e, pid=17500, tid=0x0000000000000d07
      #
      # JRE version: Java(TM) SE Runtime Environment (8.0_101-b13) (build 1.8.0_101-b13)
      # Java VM: Java HotSpot(TM) 64-Bit Server VM (25.101-b13 mixed mode bsd-amd64 compressed oops)
      # Problematic frame:
      # C [libjfxwebkit.dylib+0xe2e79e] WTFCrash+0x3e
      #
      # Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
      #
      # An error report file with more information is saved as:
      # /data/decathlon/workspace/leroymerlin-lt/hs_err_pid17500.log
      #
      # If you would like to submit a bug report, please visit:
      # http://bugreport.java.com/bugreport/crash.jsp
      # The crash happened outside the Java Virtual Machine in native code.
      # See problematic frame for where to report the bug.
      #


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      /*
       * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
       *
       * Redistribution and use in source and binary forms, with or without
       * modification, are permitted provided that the following conditions
       * are met:
       *
       * - Redistributions of source code must retain the above copyright
       * notice, this list of conditions and the following disclaimer.
       *
       * - Redistributions in binary form must reproduce the above copyright
       * notice, this list of conditions and the following disclaimer in the
       * documentation and/or other materials provided with the distribution.
       *
       * - Neither the name of Oracle or the names of its
       * contributors may be used to endorse or promote products derived
       * from this software without specific prior written permission.
       *
       * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
       * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
       * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
       * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
       * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
       * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
       * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
       * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
       * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
       * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
       * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
       */

      package simpleswingbrowser;

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

      import java.awt.BorderLayout;
      import java.awt.Dimension;
      import java.awt.event.ActionEvent;
      import java.awt.event.ActionListener;
      import java.net.MalformedURLException;
      import java.net.URL;

      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.BorderFactory;
      import javax.swing.JButton;
      import javax.swing.JFrame;
      import javax.swing.JLabel;
      import javax.swing.JOptionPane;
      import javax.swing.JPanel;
      import javax.swing.JProgressBar;
      import javax.swing.JTextField;
      import javax.swing.SwingUtilities;

      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("file:///data/jmeter/crash-javafx-browser/order.html");
                  }
              });
          }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      None found

        Attachments

        1. hs_err_pid10386.log
          50 kB
        2. hs_err_pid10499.log
          50 kB
        3. order.html
          57 kB
        4. SimpleSwingBrowser.java
          9 kB

          Issue Links

            Activity

              People

              • Assignee:
                ghb Guru Hb
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: