Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
jove_shi
Employee
Employee
SAP Analytics Cloud new optimized story offers new cache mechanisms to improve the overall initial loading performance, plus new settings to allow story developers to adjust the widgets loading sequence to achieve best performance for different scenarios. This article gives a deep dive of the mechanisms, and performances related notes and recommends based on SAC 2023.16 release.



Optimized Story Query Definition and Model Metadata Cache


When the story created by new optimized design experience is saved, its 1st page’s query definition with required model metadata will be cached publicly for all the users to improve the initial loading performance to avoid extra round-trip requests.

When the story’s related model is changed (incl. planning model’s version change), the cache will be invalid. When a user first time views the story, a private cache will be re-generated and associated with the story and user account.

  • When the story is re-saved, all the private cache will be removed.


The cache will be useless for widgets which queries are modified by story page – onInitialization event script, e.g. Chart.getDataSource().setDimensionFilter(dimension, members).

When using bookmark:


Bookmark will only generate public cache by storyId & bookmarkId as key.

If bookmark is configured to “State-Changed Components Only” (default option) or “All Components in the Story”: Saving bookmark will generate a public cache for all the users.

  • When the story is re-saved, the cache will be invalid. Then a user first time views the story, a public cache will be re-generated and associated with the story and bookmark.


If bookmark is configured to “Selected Components Only”: Saving bookmark will not generate the cache.

  • When a user first time views the story, a public cache will be re-generated and associated with the story and bookmark.


Using bookmark apply() script API to load bookmark will not consume or generate the cache.
When the story is re-saved, all the cache associated with bookmark will be removed.

Performance Related Settings


Terms


Viewable widget means:

  • The widget is inside the screen viewport.

  • And the widget itself and all its parent containers are visible.

    • Widget inside un-opened popup is not viewable.




Widget is created means:

  • The widget instance is created.

  • The widget instance is accessible by scripting.

  • The widget is pending for rendering.


Widget is loaded means:

  • The widget is created.

  • The widget has loaded its query data.

  • And the widget has completed its rendering.


Decision Order of Widget Data Refresh



  1. Whether the widget is loaded by Loading Optimization Setting?

  2. After the widget is loaded, whether its Data Fresh option is paused?


Loading Optimization Setting



  1. None


    1. All the widgets are loaded during the story initialization phase.

    2. After all the widgets are loaded, Story onInitialization event Script will be triggered.





  1. Background Loading


    1. Note: Some widgets do not support Background Loading, for example:

      1. Responsive Lane

      2. Chart with cross widget feature enabled (e.g. scale alignment, referenced by dynamic text…).

      3. Text widget with dynamic text bound to model dimension.

      4. Story level input control on mobile device.

      5. Container widget which contains a widget does not support Background Loading.



    2. Only viewable widgets and “background loading unsupported” widgets are loaded during the story initialization phase.

      1. Note: Widgets inside popup are treated as unviewable widgets, so they will not be loaded during the story initialization phase.



    3. When the viewable widgets start loading, Story page - onInitialization event’s script is triggered.

    4. When Story page - onInitialization event’s script is being executed:

      1. Unviewable widgets will be loaded one after another one.

        1. Table does not support batch query, so the total loading time of multiple tables in background loading could be longer than the default loading.

          1. Recommendation: If you want to access tables via script, recommend forcing them and their parents “Always initialize on startup”. If you worry about their parents’ “Always initialize on startup” will force other widgets to be loaded before the page - onInitialization event, you can put tables in a special panel container and then use Panel.moveWidget() script API to move them back to the corresponding container when end user wants to see them.



        2. Chart, GeoMap, InputControl, Text Widget with Dynamic Text support batch query, so their loading time is similar as the default loading.



      2. Note: Because of JavaScript’s single thread execution mechanism, these widgets will be loaded and rendered during the asynchronized execution of Story page - onInitialization event script (for example: during a script function which is waiting for remote call returning data), so the entire execution time of Story page - onInitialization event script will be increased.

      3. Note: During the execution of Story page - onInitialization event’s script, if a script call references to a widget which is still not loaded, the script call will be held and wait for the widget to be loaded, then the script call will be executed.

      4. Recommendation: Referencing as less as possible unviewable widgets in Story page - onInitialization event’s script to accelerate its execution.



    5. After Story page - onInitialization event’s script has been executed:

      1. End user can see the story content and interact with widgets.

      2. It’s possible some “Background Loading” widgets are still loading.

      3. Note: Chart and Table - onResultChange event is only triggered after it finishes first time data query.



    6. Exception case to force widget always initialize on startup (excluded by viewport loading or background loading):

      1. When a widget has “Always initialize on startup” enabled on its style panel, it will be treated as virtually visible by “Viewport Loading” or “Background Loading” check logic.

      2. If a widget is not viewable, forcing to initialize it during the story initialization phase requires all its parent widgets are viewable or “Always initialize on startup” enabled.

      3. Widgets inside popup are treated as unviewable widgets no matter their “Always initialize on startup” is enabled or not.






When Widget on Canvas:











































































widget inside viewport widget visibility always initialize on startup Widget Creation Phase
Yes TRUE FALSE Initialization
Yes TRUE TRUE Initialization
Yes FALSE FALSE Background
Yes FALSE TRUE Initialization
No TRUE FALSE Background
No TRUE TRUE Initialization
No FALSE FALSE Background
No FALSE TRUE Initialization

When Widget in Container Widget:








































Container Creation Phase is Initialization Widget in Hidden TabStrip's tab or PageBook's page widget inside viewport widget visibility always initialize on startup Widget Creation Phase
Yes No Same as "Widget on Canvas"
Yes Yes N/A any FALSE Background
Yes Yes N/A any TRUE Initialization
No any any any any Background


  1. Viewport Loading (Default)


    1. Widgets which support Viewport Loading: Chart, Table, GeoMap, InputControl, Text Widget with Dynamic Text.

      1. Other widgets will behave as the same as “Background Loading” option.



    2. Only viewable widgets are loaded during the story initialization phase.

      1. Refer to Note 2.2.1.



    3. When the viewable widgets start loading, Story page - onInitialization event’s script is triggered.

    4. When Story page - onInitialization event’s script is being executed:

      1. Unviewable widgets which support Viewport Loading (Chart, Table, GeoMap, InputControl, Text Widget with Dynamic Text):

        1. Such widgets referenced by script will be loaded one after another one:

          1. Refer to behavior 2.4.1.1. and 2.4.1.2.

          2. Note: Widgets retrieved by Application.getWidgets() script API are not recognized as referenced by script.

          3. Note: Using Application.getWidgets() API to search widget by Table type will force load all the Table widgets in 2023.16 (QRC3), the fix is planned for 2023.QRC4 release.



        2. Unviewable widgets which do not support Viewport Loading:

          1. Such widgets will be loaded one after another one as the same as “Background Loading” option.



        3. Refer to Notes 2.4.2. and 2.4.3.



      2. After Story page - onInitialization event’s script has been executed:

        1. Refer to behavior 2.5.1 and 2.5.2.

        2. When a unviewable widget which supports Viewport Loading and is not referenced by script becomes viewable by user interactions (e.g. scroll page or change visibility), the widget will be loaded.



      3. Exception case to force widget always initialize on startup (excluded by viewport loading or background loading):

        1. Refer to exceptional cases 2.6.1, 2.6.2 and 2.6.3.

        2. Saving bookmark will load and render all the widgets, then restore their original Viewport Loading status.








When Widget on Canvas:







































































































Script Referenced widget inside viewport view visibility always initialize on startup whether widget will be loaded?
No Yes TRUE FALSE TRUE
No Yes TRUE TRUE TRUE
No Yes FALSE FALSE FALSE
No Yes FALSE TRUE TRUE
No No TRUE FALSE FALSE
No No TRUE TRUE TRUE
No No FALSE FALSE FALSE
No No FALSE TRUE TRUE
Yes any any any TRUE

When Widget in Container Widget:






















































































Container Widget Widget itself
Script Referenced Viewable always initialize on startup Widget in Hidden TabStrip's tab or PageBook's page widget inside viewport view visibility always initialize on startup whether widget will be loaded?
No Yes any No Same as "Widget on Canvas"
No Yes any Yes N/A any any FALSE
No No No any any any any FALSE
No No Yes No any any FALSE FALSE
No No Yes No any any TRUE TRUE
No No Yes Yes any any any FALSE
Yes any any any any any any TRUE

When Widget in Closed Popup:

































Script Referenced Viewable always initialize on startup Widget in Hidden TabStrip's tab or PageBook's page widget inside viewport view visibility always initialize on startup whether widget will be loaded?
No any any any any any any FALSE
Yes any any any any any any TRUE

When Widget in Opened Popup:























Script Referenced Viewable always initialize on startup Widget in Hidden TabStrip's tab or PageBook's page widget inside viewport view visibility always initialize on startup whether widget will be initial loaded?
any any any any any any any TRUE

Widget on Canvas When Popup Opened

































Script Referenced Viewable always initialize on startup Widget in Hidden TabStrip's tab or PageBook's page widget inside viewport view visibility always initialize on startup whether widget will be initial loaded?
No any any any any any any FALSE
Yes any any any any any any TRUE

Summary


If you are a story designer without requiring advanced scripting capability, recommend to use default "Loading Optimization Setting" = "Viewport Loading".

If you are a story developer using advanced scripting capability, recommend:

  • Balance the initial loading time and end user's first interaction response time according to your story design and scenario.

  • Balance which widgets should be loaded at the beginning for page - onInitialization script access via setting them and their parent "Always Initialize on Startup" = true.

  • Reference as less as possible un-viewable widgets in Story page - onInitialization event’s script.


 
8 Comments