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

StrokeType.OUTSIDE on Text Nodes Causes Severe Performance Issues

XMLWordPrintable

    • generic
    • generic

      A DESCRIPTION OF THE PROBLEM :
      Rendering stroked text with StrokeType.OUTSIDE remains extremely slow, leading to high CPU usage, UI lag, and complete unresponsiveness, especially with multiple text instances. This longstanding issue (related to JDK-8089081) persists in recent JDK versions, crippling applications that rely on outlined text for accessibility or visual design.

      In my commercial application (basically a text-slide-presenter) app I desperately need StrokeType.OUTSIDE on the Text because my client strongly dislikes the default StrokeType.CENTERED behaviour. However the app becomes completely unusable and unresponsive when this stroke-type is applied. This isn't just "slow"—it's a showstopper for production apps.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Render multiple javafx.scene.text.Text nodes (e.g in a scrollpane). Set the stroke type of the texts to "outside": text.setStrokeType(StrokeType.OUTSIDE).

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Smooth scrolling and rendering, comparable to StrokeType.CENTERED.
      ACTUAL -
      Immediate lag on scroll init; freezes after 2–3 pans with >10 labels. CPU-bound on render thread.

      ---------- BEGIN SOURCE ----------
      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.control.ScrollPane;
      import javafx.scene.layout.VBox;
      import javafx.scene.paint.Color;
      import javafx.scene.shape.StrokeType;
      import javafx.scene.text.Font;
      import javafx.scene.text.Text;
      import javafx.stage.Stage;

      public class StrokeLagDemo extends Application {
          @Override
          public void start(Stage stage) {
              VBox vbox = new VBox(5);
              for (int i = 0; i < 50; i++) { // Simulate list; lag worsens with count
                  Text text = new Text("Dynamic Text Item " + i + " - Scroll to reproduce lag");
                  text.setFill(Color.WHITE);
                  text.setStroke(Color.GRAY);
                  text.setStrokeWidth(1.0);
                  text.setFont(Font.font(16));
                  text.setStrokeType(StrokeType.OUTSIDE); // triggers bug
                  vbox.getChildren().add(text);
              }

              ScrollPane scroll = new ScrollPane(vbox);
              scroll.setPrefSize(400, 300);

              Scene scene = new Scene(scroll);
              stage.setScene(scene);
              stage.setTitle("StrokeType.OUTSIDE Lag Demo");
              stage.show();
          }

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

            pnarayanaswa Praveen Narayanaswamy
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: