API REVIEW for TabPane tab content loading and fixed content size

Paru Somashekar parvathi.somashekar at oracle.com
Fri Jul 5 14:59:49 PDT 2013


Hi Daniel,

I took all your suggestions and have made the changes, and below is the 
updated API for the policy as well as the updated notes for performance 
considerations. In particular I have made the change to talk about 
"adding" the content of a tab to the scene graph vs loading the content 
of the tab and also highlighted the performance gains and caveats.

thanks,
Paru.

  TabContentSceneGraphPolicy is a static enum within TabPane
------------------------------------------------------------
public static enum TabContentSceneGraphPolicy {

     // The content all the tabs are added to the scenegraph up front 
with no optimization. If there are a lot of tabs and content is large - 
this could potentially cause slow start up time. This is the default 
behavior.
         ALL_TABS,

          //Only the content of the selected tab will be added to 
the scenegraph on startup and other tabs get added on selection. When a 
new tab is selected, its content is added into the scenegraph and the 
content of the previously selected tab is removed from the scenegraph.
         SELECTED_TAB_AND_REMOVE,

         //Only the content of the selected tab will be added to 
the scenegraph on startup and other tabs get added on selection. Once 
added, a Tab is kept in the scenegraph. When a new tab is selected for 
the first time, its content is added into the scenegraph. Subsequent 
selection will result in faster tab switch time as the content is 
already part of the scenegraph.
         SELECTED_TAB_AND_KEEP

          //Only the content of the selected tab will be added to 
the scenegraph at startup and content of other tabs 
get added asynchronously in the background. Hence there is 
no adding and removing of tab content when different tabs are selected 
as in the case of the SELECTED_TAB options.
         ALL_TABS_ASYNCH,

}

Notes on performance considerations

The TabPane offers some performance optimizations in the area of adding 
the tab content to the scene graph. Basically the default policy is to 
add the contents of all specified tabs to the scenegraph upfront. If the 
TabPane consists of a large number of big content tabs, then this could 
lead to a potential slow start up time, as it will have to spend some 
time in adding all the content up front before starting up.

In such situations, the TabPane allows specification of the 
TabContentSceneGraphPolicy which determines how the tab contents are 
added : all tabs, selected tab and remove,  selected tab and keep and 
selected tab and asynchronous addition of other tabs.
"All tabs" is the default policy, where all the content is added to the 
scenegraph upfront as stated above and it suffers from slow start up time.
The "selected tab and remove " policy adds the content of the selected 
tab to the scenegraph and adds the contents of other tabs "lazily" on 
selection, resulting in quicker startup time than the default polcy. It 
also ensures that content of the previously selected tab is removed from 
the scenegraph. This gives the added benefit of ensuring that no 
scenegraph related activities are performed on any of the tab contents 
that is not currently selected. However this could potentially cause the 
tab switch operation to be a bit slow.
The "selected tab and keep" policy offers a slight variation compared to 
the above policy in that, instead of removing the content of the 
previously selected tab, it is kept around once added. This results in 
faster tab switch operation for subsequent tab selections after the 
first time a tab is selected.
The fourth policy, "all tabs asynch",  handles adding the content of the 
rest of the tabs asynchronously in the background after initially adding 
the content of the selected tab on startup. However this option could 
result in a slower runtime performance.

Another area of optimization is provided for specifying a fixed width / 
height / size of the tab content area. If a fixed value is specified, 
measurement of the tab content sizes for the purpose of setting the 
available space is eliminated, thus providing faster resize operations 
on windows that contain a TabPane in them.

-----------------------------------------------------------------

On 7/3/13 3:23 PM, Daniel Zwolenski wrote:
> I'd probably be a little cautious about the term 'loading' then. In 
> particular, I'd probably read 'LAZY_LOADING' to hint that the actual 
> tabs themselves would be loaded/created lazily (a common use case). 
> Might be just me though.
>
> It looks like the 'lazy' option actually does them eagerly (i.e. all 
> on startup - not so lazy :) ), just asynchronously. I wonder if there 
> is a need for one that does them truly 'lazily' (i.e. on selection) 
> much like the SELECTED_TAB but once first loaded it then keeps it 
> there instead of adding and removing each selection.
>
> Maybe not the best names below but some ideas:
>
> enum TabContentSceneGraphPolicy {
>
>          // The content all the tabs are *added* to the scenegraph up 
> front with no optimization. If there are a lot of tabs and content is 
> large - this could potentially cause slow start up time. This is the 
> default behavior.
>         ALL_TABS,
>
>          //Only the content of the selected tab will be *added* to the 
> scenegraph at startup and content of other tabs get *added* 
> *asynchronously* in the background. Hence there is no *adding* and 
> *removing* of tab content when different tabs are selected as in the 
> case of the SELECTED_TAB options.
>         ALL_TABS_ASYNCH,
>
>          //Only the content of the selected tab will be *added to the 
> **scenegraph* on startup and other tabs get *added* on selection. When 
> a new tab is selected, its content is *added* into the scenegraph and 
> the content of the previously selected tab is *removed* from the 
> scenegraph.
>         SELECTED_TAB_AND_REMOVE,
>
> //Only the content of the selected tab will be *added to the 
> **scenegraph* on startup and other tabs get *added* on selection. Once 
> added, a Tab is kept in the scenegraph. When a new tab is selected for 
> the first time, its content is *added* into the scenegraph, after that 
> the tab is re-shown when selected again.
>         SELECTED_TAB_AND_KEEP
> }
>
>
>
> On Thu, Jul 4, 2013 at 8:06 AM, Paru Somashekar 
> <parvathi.somashekar at oracle.com 
> <mailto:parvathi.somashekar at oracle.com>> wrote:
>
>     Hi Daniel,
>
>     Yes, loading is referring to when the tab content gets added to
>     the scene. The API to add tabs to TabPane remain the same - the
>     new API is only proposing a policy that controls how they get
>     added & removed from the scenegraph.
>
>     thanks,
>     Paru.
>
>
>     On 7/3/13 2:35 PM, Daniel Zwolenski wrote:
>>     Hi Paru,
>>
>>     What do you mean by 'loaded'?
>>
>>     Currently we create the tabs and then manually add them doing
>>     something like:
>>
>>         TabPane tabPane = new TabPane();
>>         tabPane.getTabs().add(new Tab("Tab1"));
>>
>>     Wouldn't all the 'loading' have already happened before TabPane
>>     gets a look in? Or are you talking about when the tabs get added
>>     to the scene?
>>
>>     Cheers,
>>     Dan
>>
>>
>>
>>
>>     On Thu, Jul 4, 2013 at 7:03 AM, Paru Somashekar
>>     <parvathi.somashekar at oracle.com
>>     <mailto:parvathi.somashekar at oracle.com>> wrote:
>>
>>
>>         JIRA : https://javafx-jira.kenai.com/ browse/RT-24105
>>         <https://javafx-jira.kenai.com/browse/RT-24105> &
>>         https://javafx-jira.kenai.com/ browse/RT-30648
>>         <https://javafx-jira.kenai.com/browse/RT-30648>
>>
>>         The following is API to control how tab content gets loaded
>>         for a TabPane in order to improve startup time and runtime
>>         performance for a TabPane.
>>
>>         Jonathan has already reviewed the following API and I have
>>         incorporated his feedback. Thanks Jonathan.
>>
>>          TabContentSceneGraphPolicy is a static enum within TabPane
>>         ------------------------------ ------------------------------
>>         public static enum TabContentSceneGraphPolicy {
>>                  //The content all the tabs get loaded up front with
>>         no optimization. If there are a lot of tabs and content is
>>         large - this could potentially cause slow start up time. This
>>         is the default behavior.
>>                 ALL_TABS,
>>                  //Only the content of the selected tab will be
>>         loaded on startup and other tabs get loaded on selection.
>>         When a new tab is selected, its content is loaded into the
>>         scenegraph and the content of the previously selected tab is
>>         unloaded from the scenegraph.
>>                 SELECTED_TAB,
>>                  //Only the content of the selected tab will be
>>         loaded at startup and content of other tabs get loaded lazily
>>         in the background. Hence there is no loading and unloading of
>>         tab content when different tabs are selected as in the case
>>         of SELECTED_TAB option.
>>                 SELECTED_TAB_WITH_LAZY_LOADING
>>             }
>>         ------------------------------ ------------------------------ --
>>          API to specify fixed Width/Height/Size for tab content.
>>
>>         private DoubleProperty fixedWidth
>>         public final void setFixedWidth(double value)
>>         public final double getFixedWidth()
>>         public final DoubleProperty fixedWidthProperty()
>>
>>         private DoubleProperty fixedHeight
>>         public final void setFixedHeight(double value)
>>         public final double getFixedHeight()
>>         public final DoubleProperty fixedHeightProperty()
>>
>>         public final void setFixedSize(double width, double height)
>>         ------------------------------ ------------------------------
>>         ----
>>         Notes on performance considerations
>>
>>         The TabPane offers some performance optimizations in the area
>>         of tab content loading. Basically the default policy is to
>>         load the contents of all specified tabs. If the TabPane
>>         consists of a large number of big content tabs, then this
>>         could lead to a potential slow start up time, as it will have
>>         to spend some time in loading all the content up front before
>>         starting up.
>>
>>         In such situations, the TabPane allows specification of the
>>         TabContentSceneGraphPolicy which determines how the tab
>>         contents are loaded : all tabs, selected tab only, or
>>         selected tab and lazy loading of the rest of the tabs. The
>>         selected tab only option also ensures the content of the
>>         previously selected tab is removed from the scenegraph. This
>>         gives the added benefit of ensuring that no scenegraph
>>         related activities are performed on any of the tab contents
>>         that is not currently selected. However this could
>>         potentially cause the tab switch operation to be a bit slow.
>>         In order to achieve faster tab switch operation, the third
>>         option is provided where the content of the rest of the tabs
>>         are loaded lazily in the background. However the lazy loading
>>         option could result in a slower runtime performance.
>>
>>         Another area of optimization is provided for specifying a
>>         fixed width / height / size of the tab content area. If a
>>         fixed value is specified, measurement of the tab content
>>         sizes for the purpose of setting the available space is
>>         eliminated, thus providing faster resize operations on
>>         windows that contain a TabPane in them.
>>         ------------------------------ ------------------------------ ---
>>
>>         There might be a situation where the
>>         TabContentSceneGraphPolicy is set to SELECTED_TAB in which
>>         case only the content of the selected tab is loaded and user
>>         does not set fixed size. In such a case, we can either do one
>>         of the following,
>>         1) hardcode a fixed size if it is not already set
>>         2) measure the selected tab only and grow in size only if the
>>         size of the next selected tab is bigger than the previous one.
>>         3) throw an exception if SELECTED_TAB is chosen and fixed
>>         size is not set.
>>         I prefer option either 1 or 2, that way we do not force the
>>         developer to set a fixed size for the tab content.
>>         Thoughts suggestions welcome, I shall go with option 1 if I
>>         don't hear any.
>>
>>
>
>



More information about the openjfx-dev mailing list