reapplyCss() Is called too many times when adding a node hierarchy to the Scene
Scott Palmer
swpalmer at gmail.com
Fri Mar 11 23:44:39 UTC 2016
I guess it's time to file a bug report! I'll do that as soon as I get home.
In our application this is leading to significant pause times (>>1s). In some cases significant CPU is being used for GC that causes some very noticeable stop-the-world pauses. The application is processing live video, so this is more than an irritation.
Thanks,
Scott
> On Mar 11, 2016, at 5:33 PM, David Grieve <david.grieve at oracle.com> wrote:
>
> There is (was?) some code in Node or Parent that was supposed to prevent this.
> Namely, I thought I had it so CSS was applied from the parent before applying to the children.
>
> It may also depend on how you add the nodes to the scene.
>
>> On 3/11/16 5:18 PM, Scott Palmer wrote:
>> I think I've discovered a significant performance issue with CSS
>> processing...
>>
>> Adding a Node hierarchy to a Scene leads to
>> javafx.scene.node.setScenes(Scene, SubScene) being called. This leads a
>> walk down the Node hierarchy like so:
>>
>> setScenes
>> -> invalidatedScenes
>> -> scenesChanged
>> -> setScenes // on child Nodes -- recursion
>> -> impl_reapplyCSS()
>> ->reapplyCss()
>> loops over children calling reapplyCss() on each - recursive
>>
>> The thing to note there is:
>> * invalidatedScenes decides if it is going to call impl_reapplyCSS()
>> * invalidatedScenes calls scenesChanged which calls setScenes on all
>> children which leads to invalidateScenes being called recursively on the
>> node hierarchy
>> * invalidatedScenes calls impl_reapplyCSS()
>>
>> As the setScene call walks down the node hierarchy it gets to a leaf node
>> and then calls impl_reapplyCSS() which will call reapplyCss() recursively.
>> Since when reapplyCss() returns the cssFlag for the node will be set back
>> to UPDATE, so when the parent calls impl_reapplyCSS() the CSS is
>> recursively applied to the Nodes that just had CSS applied!
>>
>> Am I missing something?
>>
>> I made a quick test case where I add a VBox containing another VBox
>> containing a Rectangle to the Scene when I press a button. I can confirm
>> that reapplyCss() is called THREE times for the Rectangle, twice for the
>> "middle" VBox, and once on the "top" VBox.
>>
>> Obviously the deeper the hierarchy the worse this gets.
>>
>> Scott
>
More information about the openjfx-dev
mailing list