JDK-8088153 : If a Region refers to a transformed Shape, updates to the transforms are not correctly passed to the rendering layer
  • Type: Bug
  • Component: javafx
  • Sub-Component: graphics
  • Affected Version: 8
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2012-09-06
  • Updated: 2018-09-05
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Blocks :  
Relates :  
Description
This has a similar cause as RT-24607. The change to enable running the rendering and application thread in parallel split the updating of the transform and bounds (now done in updateBounds) from the syncing of the data down to the PG node (impl_updatePG) so the former can be done while the rendering is still going on.

The problem with Region is that it doesn't call updateBounds on its Shape node leading to a case where the transform is out of date when impl_updatePG is called. I verified this by instrumenting the code when fixing RT-24607. This probably is not as serious, since it is unlikely for a Region's shape to have a transform that is changing (or a transform at all, for that matter), but now that Region is becoming public API, it needs to be fixed.
Comments
I agree.
23-10-2013

The attached patch is fine (and IMO better, or less worse, than making updateBounds protected). That said, I don't think there is a point fixing this bug without fixing RT-33755. As I don't see us fixing RT-33755 for Lombard we should defer this fix to Van Ness as well. Comments ?
23-10-2013

I also tried: region.setScaleShape(false); Still I don't see the transform in the shape being considered.
22-10-2013

Here is another options (a bit of hack but not too bad). We can add this at the of updateBounds() for Node (or Parent) + + if (this instanceof javafx.scene.layout.Region) { + javafx.scene.layout.Region region = (javafx.scene.layout.Region)this; + Node shape = region.getShape(); + if (shape != null) { + shape.updateBounds(); + } + } This works (as in it gets called when it should). But as far as testing goes it seems that Regions ignore any transforms to the Shape. See: @Override public void start(Stage stage) throws Exception { Region region = new Region(); region.setBackground(new Background(new BackgroundFill(Color.RED, null, null))); final Shape shape = new Circle(40); shape.setScaleX(2); // IS THIS GETTING IGNORED ? region.setShape(shape); Group group = new Group(region); region.setLayoutX(100); region.setLayoutY(100); region.setPrefSize(100, 100); Scene scene = new Scene(group, 300, 300); stage.setTitle("RT24785"); scene.addEventFilter(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent event) { switch (event.getCode()) { case PLUS: case ADD: shape.setScaleX(shape.getScaleX()+0.5); System.out.println("Scale x increased"); break; case MINUS: case SUBTRACT: shape.setScaleX(shape.getScaleX()-0.5); System.out.println("Scale x decreased"); break; } region.setShape(null); region.setShape(shape); } }); stage.setScene(scene); stage.show(); } That initial 'shape.setScaleX(2);' seem to be ignored, am I testing this correctly or am I doing a billy ?
22-10-2013

Isn't this the same as clip (Node#setClip) ? The difference is that clip is defined for Node, and its bounds is updated as part of Node#updateBounds(). Isn't there any other cases where we have this relation that a node contains another node but it isn't a 'child' relationship ?
21-10-2013

One possible fix would be to change updateBounds to be impl_updateBounds and make it a "treatAsPrivate" public method so it can be overridden in Region. That has the disadvantage of proliferating impl_ methods, which eventually will need to be eliminated.
06-09-2012