title: JavaFX WebView blocks GUI
body: <p>All it's ok when i open light weight's pages but when i wan't to open some bigger the GUI blocks and not responding until the site load's. I try to give it to background thread but it's not working.</p>
  
  <p>MainWindowController:</p>
  
  <pre><code>WebControl webcontroller = new WebControl();
  DatabaseControl datacontroller;
  
  @FXML
  private ToggleButton PowypadkoweBt;
  @FXML
  private ToggleButton UszkodzoneBt;
  @FXML
  private ToggleButton MailBt;
  @FXML
  private ToggleButton SMSBt;
  @FXML
  private Button SendBt;
  @FXML
  private ScrollPane WynikiScroll;
  @FXML
  private TableView DoneTable;
  @FXML
  private TableColumn CheckCol, OpisCol, LoginCol;
  @FXML
  private TextArea MessageArea;
  @FXML
  private WebView WebControl;
  @FXML
  private Button NEXT;
  @FXML
  private Button PREVIOUS;
  @FXML
  private Label PAGE;
  
  @Override
  public void initialize(URL url, ResourceBundle rb) {
      this.CheckCol.setCellValueFactory(
              new Callback&lt;CellDataFeatures&lt;UsedTableRow, Boolean&gt;, ObservableValue&lt;Boolean&gt;&gt;() {
          @Override
          public ObservableValue&lt;Boolean&gt; call(CellDataFeatures&lt;UsedTableRow, Boolean&gt; param) {
              return param.getValue().getCheckedProperty();
          }
      });
      this.CheckCol.setCellFactory(CheckBoxTableCell.forTableColumn(this.CheckCol));
      this.CheckCol.setEditable(false);
      this.CheckCol.setMinWidth(50);
      this.CheckCol.setMaxWidth(50);
  
      this.OpisCol.setCellValueFactory(new PropertyValueFactory&lt;UsedTableRow, String&gt;("Description"));
      this.LoginCol.setCellValueFactory(new PropertyValueFactory&lt;UsedTableRow, String&gt;("Login"));
  
      ObservableList&lt;UsedTableRow&gt; data = FXCollections.observableArrayList();
      try {
          datacontroller = new DatabaseControl();
          data.addAll(datacontroller.getRowsFromEntity());
      } catch (ClassNotFoundException ex) {
          Alert alert = new Alert(AlertType.WARNING);
          alert.setContentText("Nie udało się nawiązać połączenia z bazą danych. Błąd klasy.");
          alert.setHeaderText("Błąd klasy.");
          alert.setTitle("Błąd");
          alert.show();
      } catch (SQLException ex) {
          Alert alert = new Alert(AlertType.WARNING);
          alert.setHeaderText("Błąd SQL.");
          alert.setContentText("Nie udało się nawiązać połączenia z bazą danych. Błąd SQL.");
          alert.setTitle("Błąd");
          alert.show();
      }
  
      this.DoneTable.setItems(data);
  
      this.WebControl.getEngine().load("http://otomoto.pl");
      this.PAGE.setText((this.webcontroller.getIteratorAuctions() + this.webcontroller.getIteratorItems() - 10) + " z " + this.webcontroller.getItemsIds().size());
     // loadNewSite();
      this.WebControl.autosize();
  
      this.WebControl.widthProperty().addListener(new ChangeListener&lt;Object&gt;() {
          public void changed(ObservableValue&lt;?&gt; observable, Object oldValue, Object newValue) {
              Double width = (Double) newValue;
              WebControl.setPrefWidth(width);
              WebControl.autosize();
          }
      });
  
      this.WebControl.requestLayout();
      this.WebControl.setContextMenuEnabled(false);
      this.WebControl.getEngine().setJavaScriptEnabled(true);
      this.WebControl.getEngine().setUserAgent("Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.117 Safari/537.36");
  
      this.PowypadkoweBt.setSelected(true);
      this.UszkodzoneBt.setSelected(true);
  
  }
  
  @FXML
  private void PowypadkoweAction(ActionEvent event) {
      if (this.PowypadkoweBt.isSelected()) {
          this.webcontroller.refresh(true);
      } else {
          this.webcontroller.refresh(false);
      }
  
      loadNewSite();
  }
  
  @FXML
  private void UszkodzoneAction(ActionEvent event) {
  
  }
  
  @FXML
  private void SMSAction(ActionEvent event) {
  
  }
  
  @FXML
  private void MailAction(ActionEvent event) {
  
  }
  
  @FXML
  private void SendAction(ActionEvent event) {
  }
  
  @FXML
  private void PREVIOUSAction(ActionEvent event) {
      webcontroller.previousAuction();
      loadNewSite();
  }
  
  @FXML
  private void NEXTAction(ActionEvent event) {
      webcontroller.nextAuction();
      loadNewSite();
      this.WebControl.autosize();
  }
  
  private void updateDoneTable() {
      ObservableList&lt;UsedTableRow&gt; data = FXCollections.observableArrayList();
  
      data.addAll(datacontroller.getRowsFromEntity());
  
      this.DoneTable.getItems().clear();
      this.DoneTable.setItems(data);
  }
  
  private void loadNewSite() {
  
      Service&lt;Void&gt; service = new Service&lt;Void&gt;() {
          @Override
          protected Task&lt;Void&gt; createTask() {
              return new Task&lt;Void&gt;() {
                  @Override
                  protected Void call() throws Exception {
                      //Background work                       
                      final CountDownLatch latch = new CountDownLatch(1);
                      Platform.runLater(new Runnable() {
                          @Override
                          public void run() {
                              try {
                                  WebControl.getEngine().load(webcontroller.getSelectedURL());
                                  PAGE.setText((webcontroller.getIteratorAuctions() + webcontroller.getIteratorItems() - 10) + " z " + webcontroller.getItemsIds().size());
                              } finally {
                                  latch.countDown();
                              }
                          }
                      });
                      latch.await();
                      //Keep with the background work
                      return null;
                  }
              };
          }
      };
  
      service.start();
  
  
  
      /*  Task task = new Task(new Runnable() {
          @Override
          public void run() {
              WebControl.getEngine().load(webcontroler.getSelectedURL());
          }
  
      });
      tr.run();
      this.PAGE.setText((this.webcontroler.getIteratorAuctions() + this.webcontroler.getIteratorItems() - 10) + " z " + this.webcontroler.getItemsIds().size());
       */
  }}
  </code></pre>
  
  <p>CInsurance Application class :</p>
  
  <pre><code>@Override
  public void start(Stage primaryStage) {
  
      try {
          Parent root = FXMLLoader.load(getClass().getResource("/cinsurance/MainWindow.fxml"));
  
          Scene scene = new Scene(root);
          scene.getStylesheets().add(getClass().getResource("/cinsurance/mainwindow.css").toExternalForm());
  
          primaryStage.setTitle("Aplikacja Ubezpieczeniowa CInsurance");
          primaryStage.setScene(scene);
          primaryStage.show();
  
      } catch (IOException ex) {
          Logger.getLogger(CInsurance.class.getName()).log(Level.SEVERE, null, ex);
      }
  
  }
  
  /**
   * @param args the command line arguments
   */
  public static void main(String[] args) {
      launch(args);
  }}
  </code></pre>
  
  <p>Thanks for any help.</p>