qt: retain pages in memory when navigating in the interface and when player opens
This is VLC 3 dialogs approach, once a page loads it is kept in memory. This makes sense because if the user opens a page/view once, there is a high chance that it is going to be opened in the future again.
At the same time, currently the player is considered a page and going back from player causes the previous page to be re-loaded.
Since going this way retains the page in the memory,
the twitching of items is limited to the scene graph
node re-generation. In other words, the images are
retained (independent of cache) as long as
QSG_TRANSIENT_IMAGES
is not set (default) but
textures may be discarded.
Image nodes own the texture for QQuickImage
, and
setting an item invisible causes its node to be
deleted. If we want to retain the textures as well,
we can set the opacity to 0.0 instead of unsetting
visibility. When opacity is 0.0, the nodes remain
in the scene graph but are not rendered.
In this case I think we don't want to retain the textures (and other stuff owned by the nodes), as video memory is not as available as system memory.
We have not followed this approach previously to reduce the memory usage. However, there have been complaints so we should probably proceed with this.
If necessary, in the future we can implement a mechanism to unload the pages. For example, we can use a timer approach, such that if a view is not opened for a long time we can unload it.
This was also requested by @ePirat if I remember correctly.
Request review @chub.