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

Pagination: exception initializing in a background thread

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • jfx25
    • jfx23
    • javafx
    • b05

      Pagination fails to initialize in a background thread when setting a current page index, due to
      java.lang.IllegalArgumentException: Children: duplicate children added exception
      (in animation)

      To reproduce, use the newly developed NodeInitializationStressTest:

      ```
          @Test
          public void pagination() {
              test(() -> {
                  Pagination c = new Pagination();
                  c.setSkin(new PaginationSkin(c));
                  return c;
              }, (c) -> {
                  c.setPageFactory((pageIndex) -> {
                      return new Label(pageIndex + " " + nextString());
                  });
                  c.setPageCount(100);
                  c.setCurrentPageIndex(nextInt(100));
                  accessControl(c);
              });
          }
      ```

      Exception:

      java.lang.IllegalArgumentException: Children: duplicate children added: parent = StackPane@2211e7f9[styleClass=page]
      at javafx.graphics/javafx.scene.Parent$3.onProposedChange(Parent.java:625)
      at javafx.base/com.sun.javafx.collections.VetoableListDecorator.setAll(VetoableListDecorator.java:116)
      at javafx.base/com.sun.javafx.collections.VetoableListDecorator.setAll(VetoableListDecorator.java:110)
      at javafx.controls/javafx.scene.control.skin.PaginationSkin.createPage(PaginationSkin.java:666)
      at javafx.controls/javafx.scene.control.skin.PaginationSkin.animateSwitchPage(PaginationSkin.java:718)
      at javafx.controls/javafx.scene.control.skin.PaginationSkin$1.handle(PaginationSkin.java:151)
      at javafx.controls/javafx.scene.control.skin.PaginationSkin$1.handle(PaginationSkin.java:1)
      at javafx.graphics/com.sun.scenario.animation.shared.TimelineClipCore.visitKeyFrame(TimelineClipCore.java:239)
      at javafx.graphics/com.sun.scenario.animation.shared.TimelineClipCore.playTo(TimelineClipCore.java:180)
      at javafx.graphics/javafx.animation.Timeline.doPlayTo(Timeline.java:172)
      at javafx.graphics/javafx.animation.AnimationAccessorImpl.playTo(AnimationAccessorImpl.java:39)
      at javafx.graphics/com.sun.scenario.animation.shared.SingleLoopClipEnvelope.timePulse(SingleLoopClipEnvelope.java:103)
      at javafx.graphics/javafx.animation.Animation.doTimePulse(Animation.java:1234)
      at javafx.graphics/javafx.animation.Animation$1.timePulse(Animation.java:190)
      at javafx.graphics/com.sun.scenario.animation.AbstractPrimaryTimer.timePulseImpl(AbstractPrimaryTimer.java:316)
      at javafx.graphics/com.sun.scenario.animation.AbstractPrimaryTimer$MainLoop.run(AbstractPrimaryTimer.java:239)
      at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:588)
      at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:572)
      at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.pulseFromQueue(QuantumToolkit.java:565)
      at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.lambda$6(QuantumToolkit.java:346)
      at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)

      Root Cause:
      Animation gets started in a background thread, which causes the animation handler to run in the FX application thread, thus creating simultaneous access to the control's fields (list of children in this case).
      Solution:
      postpone the animation.

            angorya Andy Goryachev
            angorya Andy Goryachev
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: