Bug found in the JavaFX 1.2 Release version
(note: there is no "Affected Version" item for "JavaFX 1.2", please add...)
(note2: there is no "Component" item for "Layout", please add...)
There was a new warning added to JavaFX 1.2 about first removing a node from its old group before adding it to a new group. The problem with this is that there are certain situations where the order nodes get added and removed from a Group are out of the programmer's control, such as on bound variables. The result is that this warning gets spammed to the console repeatedly, significantly impacting performance.
Here is a simple example that will spam warnings to the console when the window is resized:
Stage {
var scene:Scene;
scene: scene = Scene {
width: 600
height: 120
content: bind Group {
translateX: scene.width / 2
translateY: scene.height / 2
content: Rectangle {
width: scene.width / 2
height: scene.height / 2
}
}
}
}
Note: This is a trivial example to demonstrate the defect, but not a best practice for how you would use bind to update the layout.
The expected behavior is that this code will show a black rectangle that covers the bottom-right quarter of the window.
The actual result is that the layout works correctly, but the console fills up with warnings and the application performance is significantly reduced.
The full warning that is emitted is printed below:
WARNING * WARNING * WARNING * WARNING * WARNING
An attempt has been made to add node to a new group without
first removing it from its current group. See the class
documentation for javafx.scene.Node for further information.
This request will be granted temporarily but it will
be refused in the future. Please change your code now.
node=Rectangle oldgroup=Group newgroup=Group
Stack trace follows.
java.lang.IllegalArgumentException
at javafx.scene.Group$_SBECL.onChange(Group.fx:162)
at com.sun.javafx.runtime.location.SequenceVariable.notifyListeners(SequenceVariable.java:157)
at com.sun.javafx.runtime.location.SequenceVariable.setAsSequence(SequenceVariable.java:259)
at projavafx.reversi.examples.PlayerScoreExample$_SBECL.compute(PlayerScoreExample.fx:32)
at projavafx.reversi.examples.PlayerScoreExample$_SBECL.compute(PlayerScoreExample.fx:32)
at com.sun.javafx.runtime.location.SequenceVariable.update(SequenceVariable.java:204)
at com.sun.javafx.runtime.location.AbstractVariable.ensureValid(AbstractVariable.java:163)
at com.sun.javafx.runtime.location.SequenceVariable.getAsSequence(SequenceVariable.java:105)
at com.sun.javafx.runtime.location.SequenceVariable.get(SequenceVariable.java:97)
at com.sun.javafx.runtime.location.SequenceVariable.get(SequenceVariable.java:39)
at com.sun.javafx.runtime.location.Bindings$BijectiveBinding$2.onChange(Bindings.java:150)
at com.sun.javafx.runtime.location.AbstractLocation$1.onAction(AbstractLocation.java:220)
at com.sun.javafx.runtime.location.AbstractLocation$1.onAction(AbstractLocation.java:217)
at com.sun.javafx.runtime.location.AbstractLocation.iterateChildren(AbstractLocation.java:182)
at com.sun.javafx.runtime.location.AbstractLocation.invalidateDependencies(AbstractLocation.java:254)
at com.sun.javafx.runtime.location.AbstractLocation.invalidate(AbstractLocation.java:109)
at com.sun.javafx.runtime.location.AbstractVariable.invalidate(AbstractVariable.java:140)
at com.sun.javafx.runtime.location.AbstractLocation$2.onAction(AbstractLocation.java:235)
at com.sun.javafx.runtime.location.AbstractLocation$2.onAction(AbstractLocation.java:229)
at com.sun.javafx.runtime.location.AbstractLocation.iterateChildren(AbstractLocation.java:182)
at com.sun.javafx.runtime.location.AbstractLocation.invalidateDependencies(AbstractLocation.java:255)
at com.sun.javafx.runtime.location.AbstractLocation.invalidate(AbstractLocation.java:109)
at com.sun.javafx.runtime.location.AbstractVariable.invalidate(AbstractVariable.java:140)
at com.sun.javafx.runtime.location.AbstractLocation$2.onAction(AbstractLocation.java:235)
at com.sun.javafx.runtime.location.AbstractLocation$2.onAction(AbstractLocation.java:229)
at com.sun.javafx.runtime.location.AbstractLocation.iterateChildren(AbstractLocation.java:182)
at com.sun.javafx.runtime.location.AbstractLocation.invalidateDependencies(AbstractLocation.java:255)
at com.sun.javafx.runtime.location.AbstractLocation.invalidate(AbstractLocation.java:109)
at com.sun.javafx.runtime.location.AbstractVariable.invalidate(AbstractVariable.java:140)
at com.sun.javafx.runtime.location.AbstractLocation$2.onAction(AbstractLocation.java:235)
at com.sun.javafx.runtime.location.AbstractLocation$2.onAction(AbstractLocation.java:229)
at com.sun.javafx.runtime.location.AbstractLocation.iterateChildren(AbstractLocation.java:182)
at com.sun.javafx.runtime.location.AbstractLocation.invalidateDependencies(AbstractLocation.java:255)
at com.sun.javafx.runtime.location.ObjectVariable.notifyListeners(ObjectVariable.java:136)
at com.sun.javafx.runtime.location.ObjectVariable.replaceValue(ObjectVariable.java:104)
at com.sun.javafx.runtime.location.ObjectVariable.set(ObjectVariable.java:115)
at projavafx.reversi.examples.PlayerScoreExample.javafx$run$(PlayerScoreExample.fx:26)
at projavafx.reversi.examples.PlayerScoreExample.javafx$run$(PlayerScoreExample.fx:26)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.javafx.runtime.provider.GUIRuntimeProvider$1.run(GUIRuntimeProvider.java:65)
at com.sun.javafx.tk.swing.SwingToolkit$StartupRoutine.run(SwingToolkit.fx:593)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
(note: there is no "Affected Version" item for "JavaFX 1.2", please add...)
(note2: there is no "Component" item for "Layout", please add...)
There was a new warning added to JavaFX 1.2 about first removing a node from its old group before adding it to a new group. The problem with this is that there are certain situations where the order nodes get added and removed from a Group are out of the programmer's control, such as on bound variables. The result is that this warning gets spammed to the console repeatedly, significantly impacting performance.
Here is a simple example that will spam warnings to the console when the window is resized:
Stage {
var scene:Scene;
scene: scene = Scene {
width: 600
height: 120
content: bind Group {
translateX: scene.width / 2
translateY: scene.height / 2
content: Rectangle {
width: scene.width / 2
height: scene.height / 2
}
}
}
}
Note: This is a trivial example to demonstrate the defect, but not a best practice for how you would use bind to update the layout.
The expected behavior is that this code will show a black rectangle that covers the bottom-right quarter of the window.
The actual result is that the layout works correctly, but the console fills up with warnings and the application performance is significantly reduced.
The full warning that is emitted is printed below:
WARNING * WARNING * WARNING * WARNING * WARNING
An attempt has been made to add node to a new group without
first removing it from its current group. See the class
documentation for javafx.scene.Node for further information.
This request will be granted temporarily but it will
be refused in the future. Please change your code now.
node=Rectangle oldgroup=Group newgroup=Group
Stack trace follows.
java.lang.IllegalArgumentException
at javafx.scene.Group$_SBECL.onChange(Group.fx:162)
at com.sun.javafx.runtime.location.SequenceVariable.notifyListeners(SequenceVariable.java:157)
at com.sun.javafx.runtime.location.SequenceVariable.setAsSequence(SequenceVariable.java:259)
at projavafx.reversi.examples.PlayerScoreExample$_SBECL.compute(PlayerScoreExample.fx:32)
at projavafx.reversi.examples.PlayerScoreExample$_SBECL.compute(PlayerScoreExample.fx:32)
at com.sun.javafx.runtime.location.SequenceVariable.update(SequenceVariable.java:204)
at com.sun.javafx.runtime.location.AbstractVariable.ensureValid(AbstractVariable.java:163)
at com.sun.javafx.runtime.location.SequenceVariable.getAsSequence(SequenceVariable.java:105)
at com.sun.javafx.runtime.location.SequenceVariable.get(SequenceVariable.java:97)
at com.sun.javafx.runtime.location.SequenceVariable.get(SequenceVariable.java:39)
at com.sun.javafx.runtime.location.Bindings$BijectiveBinding$2.onChange(Bindings.java:150)
at com.sun.javafx.runtime.location.AbstractLocation$1.onAction(AbstractLocation.java:220)
at com.sun.javafx.runtime.location.AbstractLocation$1.onAction(AbstractLocation.java:217)
at com.sun.javafx.runtime.location.AbstractLocation.iterateChildren(AbstractLocation.java:182)
at com.sun.javafx.runtime.location.AbstractLocation.invalidateDependencies(AbstractLocation.java:254)
at com.sun.javafx.runtime.location.AbstractLocation.invalidate(AbstractLocation.java:109)
at com.sun.javafx.runtime.location.AbstractVariable.invalidate(AbstractVariable.java:140)
at com.sun.javafx.runtime.location.AbstractLocation$2.onAction(AbstractLocation.java:235)
at com.sun.javafx.runtime.location.AbstractLocation$2.onAction(AbstractLocation.java:229)
at com.sun.javafx.runtime.location.AbstractLocation.iterateChildren(AbstractLocation.java:182)
at com.sun.javafx.runtime.location.AbstractLocation.invalidateDependencies(AbstractLocation.java:255)
at com.sun.javafx.runtime.location.AbstractLocation.invalidate(AbstractLocation.java:109)
at com.sun.javafx.runtime.location.AbstractVariable.invalidate(AbstractVariable.java:140)
at com.sun.javafx.runtime.location.AbstractLocation$2.onAction(AbstractLocation.java:235)
at com.sun.javafx.runtime.location.AbstractLocation$2.onAction(AbstractLocation.java:229)
at com.sun.javafx.runtime.location.AbstractLocation.iterateChildren(AbstractLocation.java:182)
at com.sun.javafx.runtime.location.AbstractLocation.invalidateDependencies(AbstractLocation.java:255)
at com.sun.javafx.runtime.location.AbstractLocation.invalidate(AbstractLocation.java:109)
at com.sun.javafx.runtime.location.AbstractVariable.invalidate(AbstractVariable.java:140)
at com.sun.javafx.runtime.location.AbstractLocation$2.onAction(AbstractLocation.java:235)
at com.sun.javafx.runtime.location.AbstractLocation$2.onAction(AbstractLocation.java:229)
at com.sun.javafx.runtime.location.AbstractLocation.iterateChildren(AbstractLocation.java:182)
at com.sun.javafx.runtime.location.AbstractLocation.invalidateDependencies(AbstractLocation.java:255)
at com.sun.javafx.runtime.location.ObjectVariable.notifyListeners(ObjectVariable.java:136)
at com.sun.javafx.runtime.location.ObjectVariable.replaceValue(ObjectVariable.java:104)
at com.sun.javafx.runtime.location.ObjectVariable.set(ObjectVariable.java:115)
at projavafx.reversi.examples.PlayerScoreExample.javafx$run$(PlayerScoreExample.fx:26)
at projavafx.reversi.examples.PlayerScoreExample.javafx$run$(PlayerScoreExample.fx:26)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.javafx.runtime.provider.GUIRuntimeProvider$1.run(GUIRuntimeProvider.java:65)
at com.sun.javafx.tk.swing.SwingToolkit$StartupRoutine.run(SwingToolkit.fx:593)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
- blocks
-
JDK-8106965 Remove warning when adding a node to a group when the node already has a parent
- Closed