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.
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.
- blocks
-
JDK-8348987 ☂ Thread safety in Node initialization
-
- In Progress
-
- clones
-
JDK-8349098 TabPane: exception initializing in a background thread
-
- Resolved
-
- relates to
-
JDK-8349756 Memory leak in PaginationSkin when setting page count / index
-
- Resolved
-
-
JDK-8349679 build.gradle: increase system test memory limit to 1GB
-
- Resolved
-
- links to
-
Commit(master) openjdk/jfx/d07d5cc6
-
Review(master) openjdk/jfx/1698
(1 links to)