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

[Touch] JVM irreversible state, Too many touchpoints

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 8
    • Fix Version/s: emb-8u6, 8u20
    • Component/s: javafx
    • Labels:
    • Environment:

      Windows 7, JDK 8, JDK 7, .....

      Description

      Also affects JDK 7

      In the provided application there are 2 buttons. One with the label "Open Secondary Stage" so simply do the following:


           -> 1º press that button "Open Secondary Stage" and without release drag over the main stage and then release.
           -> 2º press the button in the secondary stage
           -> 3º press on any point in the area of the main stage and a exception "Too many touch points detected will be thrown" and the JVM will fall in an irreversible state


      Not to mention, that in a complex applications not in simple demos, it is very easy to fall in this state....

      Java Application below:


      package application;

      import javafx.application.Application;
      import javafx.event.ActionEvent;
      import javafx.event.EventHandler;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.input.TouchEvent;
      import javafx.scene.layout.BorderPane;
      import javafx.scene.layout.HBox;
      import javafx.stage.Modality;
      import javafx.stage.Stage;
      import javafx.stage.StageStyle;

      public class Main extends Application {
      Stage secondaryStage;
      Stage primaryStage;

      @Override
      public void start(Stage primaryStage) {
      try {
      this.primaryStage = primaryStage;
      BorderPane root = new BorderPane();

      Button openDialog = new Button("OPEN SECONDARY STAGE");

      openDialog.setOnTouchPressed(new EventHandler<TouchEvent>() {

      @Override
      public void handle(TouchEvent event) {
      System.out.println("TOUCH PRESS");
      openSecondarySTage();
      if(secondaryStage!=null && secondaryStage.getScene()!=null) {
      if(event.getTouchPoint().getGrabbed()!=secondaryStage.getScene()) {
      event.getTouchPoint().grab(secondaryStage.getScene());
      System.out.println("Grabbed TP: "+event.getTouchPoint().getId()+" by "+event.getTouchPoint().getGrabbed());
      }
      }
      }

      });
      Button closeDialog = new Button("CLOSE SECONDARY STAGE");

      closeDialog.onActionProperty().set(new EventHandler<ActionEvent>() {

      @Override
      public void handle(ActionEvent event) {
      System.out.println("closing secondary from prim button");
      closeSecondaryStage();
      }

      });
      Scene scene = new Scene(root, 400, 400);

      scene.addEventHandler(TouchEvent.TOUCH_MOVED,
      new EventHandler<TouchEvent>() {

      @Override
      public void handle(TouchEvent event) {
      System.out
      .println("TOUCH EVENT DETECTED BY PRIMARY STAGE: "
      + event);
      }

      });
      scene.getStylesheets().add(
      getClass().getResource("application.css").toExternalForm());
      primaryStage.setScene(scene);

      HBox centerPane = new HBox();
      centerPane.getChildren().add(openDialog);
      centerPane.getChildren().add(closeDialog);
      root.setCenter(centerPane);
      primaryStage.show();
      } catch (Exception e) {
      e.printStackTrace();
      }
      }

      private void openSecondarySTage() {
      if(secondaryStage!=null && secondaryStage.isShowing()) {
      secondaryStage.toFront();
      return;
      }
      System.out.println("OPENING SECONDARY STAGE");

      BorderPane root = new BorderPane();
      secondaryStage = new Stage(StageStyle.UTILITY) ;
      secondaryStage.initModality(Modality.APPLICATION_MODAL);

      secondaryStage.initOwner(primaryStage);
      Scene scn = new Scene(root, 200, 200);
      scn.addEventHandler(TouchEvent.TOUCH_MOVED,
      new EventHandler<TouchEvent>() {

      @Override
      public void handle(TouchEvent event) {
      System.out
      .println("SECONDARY STAGE TOUCHED: "
      + event);
      }

      });
      secondaryStage.setScene(scn);

      Button closeOnSec = new Button("CLOSE SECONDARY STAGE");


      closeOnSec.setOnAction(new EventHandler<ActionEvent>() {

      @Override
      public void handle(ActionEvent event) {
      System.out.println("Closing Sec from Sec ");
      closeSecondaryStage();
      }

      });
      root.setCenter(closeOnSec);
      secondaryStage.show();
      secondaryStage.toFront();
      secondaryStage.setX(primaryStage.getX()+primaryStage.getWidth()/2);
      secondaryStage.setY(primaryStage.getY()+primaryStage.getHeight()/3);
      }

      private void closeSecondaryStage() {
      System.out.println("CLOSING SECONDARY STAGE");
      if (secondaryStage != null) {
      secondaryStage.close();
      secondaryStage = null;
      }
      }

      public static void main(String[] args) {
      launch(args);
      }
      }




        Attachments

          Activity

            People

            Assignee:
            msladecek Martin Sládeček
            Reporter:
            pgomezjfx Pablo Gómez (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported: