JDK-8090322 : Need new tree visible property in Node that consider Scene and Stage visibility
  • Type: Bug
  • Component: javafx
  • Sub-Component: scenegraph
  • Affected Version: 8,9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2011-07-06
  • Updated: 2020-09-08
  • Resolved: 2016-07-06
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.
JDK 9
9Fixed
Related Reports
Blocks :  
Blocks :  
Blocks :  
Blocks :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
Currently there is Node.treeVisible property which is true iff the node and all its parents up to the scene root are visible. It may be useful to have an extended version that would take scene and stage visibility into account.

Use cases:
* WebView needs to stop animations inside web page when it is not shown;
* Jasper wanted to know when some node became visible in a tab.

Considerations:
* This is too expensive to calculate for all nodes by default. So the simplest way to provide it would be a special binding implementation or a util class. Where you create a instance and pass in the node you are interested in. It can then register listeners all the way up the tree and listen to what it needs.
Comments
Changeset: 4b60077e4d1b Author: ckyang Date: 2016-07-06 13:43 -0700 URL: http://hg.openjdk.java.net/openjfx/9-dev/rt/rev/4b60077e4d1b
06-07-2016

+1
06-07-2016

Thanks for the feedback. While fixing those old comments (written for the initial attempt to change the semantic of treeVisible) I found a bug in my implementation of treeShowing regarding its initial state. This is a one line fix and I have improved the unit test to cover the case. Here is the revised webrev (01): http://cr.openjdk.java.net/~ckyang/JDK-8090322/webrev.01/ and plus that fix includes chart, control, web: http://cr.openjdk.java.net/~ckyang/JDK-8090322/webrevPlus.01/ Here is the delta between v00 and v01: http://cr.openjdk.java.net/~ckyang/JDK-8090322/webrev-00-01.diff/
06-07-2016

Comments: 1) Small typo in comment in SubScene: 'inherrited' rather than 'inherited' 2) Your comment in Node::sceneWindowChangedListener is '// Replace the windowShowingListener and call updateTreeVisible', but I don't see 'updateTreeVisible' being called - I presumed this comment is incorrect? 3) In Node::invalidatedScenes your comment is '// isTreeVisible need to take into account of Window's showing', but I wonder if that should be 'isTreeShowing'? 4) The second changeset includes the contents of the first changeset - I'm sure you'll reconcile appropriately. Because all my comments are minor, consider this a +1. Thanks!
06-07-2016

I propose to introduce a new internal "treeVisible" property that takes into account of Stage visibility and let's called it treeShowing. Here is a proposed implementation of treeShowing property: http://cr.openjdk.java.net/~ckyang/JDK-8090322/webrev.00/ I have changed chart, control and web to use this new property where its logic implied. http://cr.openjdk.java.net/~ckyang/JDK-8090322/webrevPlus.00/ Both webrevs passed full clean build/test and sanity testing on Mac.
05-07-2016

It turns up that we have code logic within scene graph that depend on the existing treeVisible semantic that purely restricted to a tree is visible if its subgraph is visible. Hence we can't simply change the semantic of treeVisible to include Stage visibility.
05-07-2016

We have decided to use this JBS issue to track the semantic change to the internal treeVisible property. We will file a new RFE to consider public API for this functionality.
22-06-2016

The implementation part of this is planned for JDK 9, which will fix the semantics to include whether or not a node is part of a visible (live) Scene, but it won't be exposed as public API. That suggests that we need two JBS issues -- one to change the implementation, and one (not planned for 9) to create new public API to expose this property.
02-05-2016

Is this issue going to be targeted to JDK 9?
01-05-2016

Am I right that you're talking about the existence of Node.impl_isTreeVisible()? The point here is also to make this API public.
07-07-2011

I'm ok with impl_ stuff. If you have a strong case for a public property, please put it here.
07-07-2011