Avoid google map always init/render

Hi All,

is there a way to avoid google map always initialize when activate screen? (use cache maybe?) , because when we use application and move between screens frequently, the screen with google map triggering web browser crash,

Thanks in advance

Hello @arifian.prahata

I suggest you to enable MANAGED main TabSheet mode. In this mode screens are not unloaded and don’t re-render on opening. Pay attention that this feature decreases a time of screen opening, but increases memory cost.

To enable this option add the following config into the web-app.properties file:

cuba.web.mainTabSheetMode = MANAGED

Read more about this property in docs: link;

Regards,
Daniil.

2 Likes

Hi, @tsarev thanks for your explanation,

Does this method can be applied on certain screen or all of the screens get impact ?

Thanks

You can configure mode of managed TabSheet with the managedMainTabSheetMode property (docs) and then setup switch mode for the specific screen with the setContentSwitchMode(ContentSwitchMode mode) method: docs.

Regards,
Daniil.

1 Like

Hi @tsarev thanks for information, very helpful :+1:

but I realize there is no clue how to give value for cuba.web.managedMainTabSheetMode, in document only mention default value HIDE_TABS, but how about other possible values?

https://doc.cuba-platform.com/manual-6.10/app_properties_reference.html#cuba.web.managedMainTabSheetMode

and what does those values suppose to mean ?

This property can be found in WebConfig and you can realize that the ManagedMainTabSheetMode enum options are used as value for it.

This enum has two values:

  • HIDE_TABS - this option makes TabSheet hide screens with CSS rules and don’t unload them
  • UNLOAD_TABS - this option corresponds to default TabSheet behavior, which means that screens are unloaded while switching.

Hi Daniil,
By “increases memory cost”, how much memory increase? Depends on which aspects?

Hello.

It is hard to say, because it fully depends on complexity of screens. It means that memory costs are directly proportional to components count.

Regards,
Daniil

Hi,
It’s possible to set all tabs of a sheet as UNLOAD and only one as HIDE?

Hello @g.delogu

Yes, you can set UNLOAD_TABS for app property cuba.web.managedMainTabSheetMode to unload tabs by default. Then get Window reference by screen.getWindow(), and then use AbstractWindow#setContentSwitchMode method to setup required behavior.

Regards

Hi,
I tried but it doesn’t work (cuba v6.10.15)

  • In web-app.properties i have:
cuba.web.mainTabSheetMode = MANAGED
cuba.web.managedMainTabSheetMode = UNLOAD_TABS
  • On the ready function of the Window i have:
this.setContentSwitchMode(ContentSwitchMode.HIDE);

But the window continue to reload on tab switch. If i set cuba.web.managedMainTabSheetMode = HIDE_TABS the window doesn’t reload at every switch, but obviously the other windows do the same.

Searching on the code i found in Window.java:

enum ContentSwitchMode {
    /**
     * Tab switching is determined by the managed main TabSheet mode (hide or unload content of a tab).
     */
    DEFAULT,
    /**
     * Tab content should be hidden not considering the TabSheet mode.
     */
    HIDE,
    /**
     * Tab content should be unloaded not considering the TabSheet mode.
     */
    UNLOAD
}

The values are correct or they should be HIDE_TABS, UNLOAD_TABS?

Regards

Can you help?

Hi @g.delogu

I’ll check the case and give you an answer as soon as possible

I’ve checked the case and everything works nice.

In web-app.properties:

# managed main tabsheet mode
cuba.web.mainTabSheetMode = MANAGED
# unload tabs by default
cuba.web.managedMainTabSheetMode = UNLOAD_TABS

In screen controller:

public class TestScreen extends AbstractWindow {

    @Override
    public void init(Map<String, Object> params) {
        setContentSwitchMode(ContentSwitchMode.HIDE);
    }
}

Result:

unload-hide-tabs

Demo project:

managed-tabsheet.zip (70.4 KB)

Regards

Thanks!
The problem was the call of “setContentSwitchMode(ContentSwitchMode.HIDE)” in the ready function. Moving in the init solved the problem