title: ProgressBar framerate drops when Label draws on top
body: <p>I'd not normally ask for help here, but I'm stumped - this bug is the strangest thing I've seen in a long time.</p>
  
  <p><a href="https://gfycat.com/FluidFrigidEastsiberianlaika" rel="nofollow noreferrer">https://gfycat.com/FluidFrigidEastsiberianlaika</a></p>
  
  <p>I've got a simple UI object called <code>GhostProgressBar</code> that extends <code>ScalaFX.StackPane</code> and gives it two children - a <code>ProgressBar</code> and a <code>Label</code>. I noticed after adding it to some other UI screens that my framerate had plummeted, to a point where the UI was painfully unusuable.</p>
  
  <p>The code for this is super simple:</p>
  
  <pre><code>import scalafx.geometry.Pos
  import scalafx.scene.control.{Label, ProgressBar}
  import scalafx.scene.layout.StackPane
  
  class GhostProgressBar extends StackPane {
  
    alignment = Pos.Center
  
    val bar = new ProgressBar() {
      prefWidth = Integer.MAX_VALUE
    }
    val text = new Label() {
      id = "ProgressBarText"
      text = "PERFORMANCE TESTING"
    }
  
    children = List(bar, text)
  }
  </code></pre>
  
  <p>In the GIF I'm using it inside a <code>VBox</code> that's the <code>center</code> element of a regular <code>BorderPane</code> - nothing strange or atypical.</p>
  
  <p>From the behaviour I've observed, I think it's an issue with text being drawn over the bar of the <code>ProgressBar</code>. Just now I've done some more debugging, and my suspicions that it was related to the styling of the text were confirmed.</p>
  
  <p>This is the styling that's on the text in the GIF.</p>
  
  <pre><code>#ProgressBarText {
      -fx-text-fill: #dddddd;
      -fx-font-weight: bold;
  }
  #ProgressBarText .text {
      -fx-stroke: #333333;
      -fx-stroke-width: 1px;
      -fx-stroke-type: outside;
  }
  </code></pre>
  
  <p>When I remove that styling, the framerate doesn't drop when the bar hits the text.</p>
  
  <p>What I can't figure out is <em>why</em> this is happening? Anyone got any ideas? I have no idea if it's a Scala thing, or a ScalaFX thing, whether or not it's reproducible with the same stuff in a JavaFX context.</p>
  
  <p>Help would be appreciated.</p>
  
  <p>EDIT: I was asked for versions, here we go:</p>
  
  <ul>
  <li>Scala version: 2.12.7</li>
  <li>ScalaFX version: 8.0.102-R11</li>
  <li>JDK version: 1.8.0_181</li>
  <li>JavaFX version: unknown, I'm not familiar with ScalaFX's internals and I'm not using JavaFX directly.</li>
  </ul>
  
  <p>EDIT 2: I was asked to try the same screen elements, but using JavaFX elements instead of ScalaFX ones. Here's the code I used, the outcome was the same - whenever the outlined text was over the progress bar's bar, the framerate dropped.</p>
  
  <pre><code>import javafx.geometry.Pos
  import javafx.scene.control.{Label, ProgressBar}
  import javafx.scene.layout.StackPane
  
  class JavaFXGhostProgressBar extends StackPane {
  
      this.setAlignment(Pos.CENTER)
  
      val bar = new ProgressBar()
      bar.setMaxWidth(Double.MaxValue)
      val text = new Label()
      text.textProperty().setValue("PERFORMANCE TESTING")
      text.idProperty().setValue("OutlineProgressBarText")
  
      this.getChildren.addAll(bar, text)
  }
  </code></pre>
  
  <p>I couldn't find out what version of JavaFX I used here; IntelliJ was weirdly inconsiderate in not telling me. I couldn't find it in my external libraries list, either.</p>