Caching and anticipatory loading of scenes #183
Replies: 1 comment
-
Caching of documentsWith PR Unified Thumbnails also caching of documents with their thumbnails is possible. This PR introduces a Loading of documentsA document is loaded when it is first accessed. There is no need for anticipatory loading, as the thumbnails are loaded in background and anticipatory loading will give no visual advantage. Keep documentsWhere and when does caching of document instances improve the user experience?
Unloading documentsFor unloading of documents we should also consider a strategy. My current ideas:
The second point seems to be an easy-to-implement strategy which does not negatively affect user experience. This is also what is implemented in the merged PR. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Loading a scene until it is visible on the screen can take a non-negligible amount of time. Limiting factors are
To reduce the time necessary to switch between scenes it is useful
This article analyzes the loading process, describes the current status, and investigates the options to create a smooth user experience.
Loading of scenes
An OpenBoard scene (or page) is stored on disk as follows:
When loading a scene, the SVG elements are processed one by one, and the corresponding graphical items on the scene are created. If necessary, referenced files are also accessed, even if they are often not completely loaded in this stage:
Background loading
To load a scene in the background without affecting user experience the tasks may be executed in another thread. There is however one limitation: Creation of the graphical items of the scene cannot be performed in another thread due to internal Qt restrictions (see this comment). We can however
Caching
Creation of graphical items for a scene and rendering of PDF pages are the most time consuming tasks. Therefore OpenBoard has caching features for both of them.
UBSceneCache. This cache covers scenes from several documents. It is managed by a LRU policy with a limited number of scenes.XPDFRenderer. There is one renderer per PDF document. Here all rendered pages from that PDF document are cached, probably in several resolutions. The cache is only cleared if no more scene references this PDF document and the renderer is destroyed.None of the caches check for a memory limit.
Current status
After merging the "lazy loading" PR, the situation is as follows:
Room for improvement
I see the following places which could be improved:
Caching strategies (ideas)
Loading
The following non-exhaustive list of ideas might also be combined.
Unloading
The only reason for unloading is memory. We should definitely avoid swapping.
available / totalas limit.QImage::sizeInBytes()to calculate memory usage.Beta Was this translation helpful? Give feedback.
All reactions