Conversation
Changes in the user experience and implementationThis PR introduces some small changes in the user experience:
And more technically:
|
303f7ae to
7e096d4
Compare
- always render scene to a 400px pixmap - transform to width of left palette - show all scene items in thumbnail - re-adjust thumbnail area when mouse is released - detach scene from thumbnail when switching to another page - constant size for delete and duplicate buttons
- split loading of document in small steps - execute steps on idle in the main thread - limit number of scenes in UBSceneCache - re-use the currently unused setting App/PageCacheSize - use intermediate signal on UBGraphicsScene for zoomChanged to allow deletion of all delegates at once when scene is deleted
- Loading of scene data in worker thread no longer used - remove obsolete code from UBPersistenceManager and UBPersistenceWorker
7e096d4 to
e0e9965
Compare
|
I had some feedback today about users experiencing freezes on Debian. It's not sure it is related to OpenBoard, but even if I think we should improve cache system to take memory usage into account instead of an arbitrary number of pages, having it reintroduced with all the improvements you made on this PR could probably help a lot mitigating this possibility. So I'm going to merge it, and I'll come back to you after our internal meetings so we can go further on the different aspects raised by this PR, as discussed by mail. Edit:
Do you think that reaching memory exhaustion could lead to a freeze of the OS instead of a crash of OpenBoard ? |
Yes, if you have a swap on a lame disk. This can really feel like freezing. |
|
Testing a bit the patch, I see the active thumbnail is not always updating. Do you experience this too ? Example of reproduction scenario :
|
Yes, I can reproduce that. It is ok again after switching to page 1 and then page 2. Will have a look. |
- ensure that the scene is set on a newly created thumbnail
fixed |
This on python.ubz goes crazy ^^, and it can really gives the impression the OS is completely frozen (1 CPU goes 100% for minutes) |
| auto scene = mSceneCache.value(proxy, sceneIndex); | ||
| qDebug() << "loadDocumentScene: got result from cache"; | ||
|
|
||
| if (cacheNeighboringScenes) |
There was a problem hiding this comment.
Hi @letsfindaway,
I'm going to change the cacheNeighboringScenes logic so it caches as much pages as authorized by the pageCacheSize setting, like following :
int lowerLimitNeighbor = std::max(0, sceneIndex - (UBSettings::settings()->pageCacheSize->get().toInt()/2));
for (int i = lowerLimitNeighbor; i< std::max(UBSettings::settings()->pageCacheSize->get().toInt() - lowerLimitNeighbor, proxy->pageCount()-1); i++)
{
mSceneCache.prepareLoading(proxy,i);
}Did you have some reasons not to do so ? Do you have any suggestions about this change ?
Also, I found, holding arrow keys to go to others pages where a video item can be found in some of them, that the application crashes (systematically) when the cache is full and that a page containing a media has to be removed:
cache full, size 20
removing page 27 of "OpenBoard Document 2024-09-27 10-51-26.623"
ASSERT failure in UBGraphicsVideoItem: "Called object is not of the correct type (class destructor may have already run)",
Could you look at this ?
There was a problem hiding this comment.
Did you have some reasons not to do so ? Do you have any suggestions about this change ?
No specific reason. One argument could however be that currently the prepareLoading does not maintain a queue, but starts loading all scenes in parallel. This causes that it takes longer until the first page was loaded. So it might be counterproductive to load all pages immediately.
Also, I found, holding arrow keys to go to others pages where a video item can be found in some of them, that the application crashes (systematically) when the cache is full and that a page containing a media has to be removed:
Cannot reproduce this with a document where I have put an audio and a video on some of the pages. In the log I can see that these pages are also deleted from the cache. Can you provide me with a document where this happens?
But during testing I found that dragging the object to the thumbnail instead to the board causes an immediate crash.
There was a problem hiding this comment.
For the crash when dragging an object to the thumbnail view:
OpenBoard/src/gui/UBBoardThumbnailsView.cpp
Lines 327 to 340 in fe2bbd3
Change the else in line 336 to else if (mDropSource) to avoid that DnD is executed without a valid drop source.
However I wonder why this else exists: can you drag any object from outside the thumbnails view to that view? I thought that the event source must always be the same widget as the drop target.
There was a problem hiding this comment.
Can you provide me with a document where this happens?
Thanks for the documents. I tried it with all three of them. Still cannot reproduce the problem with the current dev branch. That's strange.
What I'm doing:
- Load the document from the Documents mode.
- Press and hold "arrow right" to flip through all pages.
- Same in the other direction, even multiple times.
- I also started the video on one of the pages and then moved away from that page. Also no crash.
There was a problem hiding this comment.
Can you provide me with a document where this happens?
Done.
No specific reason. One argument could however be that currently the
prepareLoadingdoes not maintain a queue, but starts loading all scenes in parallel. This causes that it takes longer until the first page was loaded. So it might be counterproductive to load all pages immediately.
Oh I indeed thought loading requests were queued and performed during idle time one at a time. So I thought it would not directly impact the user, just potentially indirectly because of the memory and cpu usage.
Do you think anything is possible with slight changes or will it take more important changes than what I'm doing ?
There was a problem hiding this comment.
Can you provide me with a document where this happens?
Thanks for the documents. I tried it with all three of them. Still cannot reproduce the problem with the current
devbranch. That's strange.What I'm doing:
- Load the document from the Documents mode.
- Press and hold "arrow right" to flip through all pages.
- Same in the other direction, even multiple times.
- I also started the video on one of the pages and then moved away from that page. Also no crash.
Ok so it's probably Qt related. Happening with the Qt 6.7.2 version
There was a problem hiding this comment.
Also happening with Qt 6.4.2 on a Debian virtual machine. Did you try with a Qt 5 based openboard ?
There was a problem hiding this comment.
Ok, confirmed and it is an issue with Qt 6. The reason is here:
OpenBoard/src/domain/UBGraphicsMediaItem.cpp
Lines 170 to 201 in fe2bbd3
The connections are different between Qt5 and Qt6. When deleting a media object, the destructor calls mMediaObject->stop(). This triggers the playbackStateChanged signal which is - when using Qt 6 - connected to UBGraphicsVideoItem::mediaStateChanged. But at this stage the destructor of UBGraphicsVideoItem has already run, so the object is no longer an instance of that class.
The connection is still alive, even if it was created in a subclass. This is because connections are released in the QObject destructor, which runs later. In fact this might also be a problem for Qt5, but it seems not to be fatal as in Qt6.
I will work on a solution later this weekend, most probably by disconnecting these signals in the destructor.
|
See letsfindaway#183 for some thoughts on how to improve scene caching and background loading in the next iteration. I would be happy to get your feedback and to collect more ideas there. |
This PR aims to improve performance of scene handling especially with documents with many pages, where each page has many items. This occurs when pages contain a lot of handwriting. Such scenes could be several megabytes as SVG and also occupy a lot of memory when loaded as scene.
Also loading of such pages takes considerable time. Since all pages of a document are currently loaded when the document is opened in order to assign the scenes to the board thumbnails, opening such heavy documents can currently take many seconds.
Currently the scene cache only grows. Scenes are never deleted from the cache. This can lead to memory exhaustion and crashing of OpenBoard.
The PR implements the following in three commits:
QGraphicsItemdata it is impossible to construct these objects on another thread, so this approach is the only possible solution. We now load the previous, next and next but one scene using this approach, which leads to a smooth page change behavior even on heavy documents. At the same time, we re-enable a cache size limit (default: 20 scenes) to limit memory usage. The already implemented LRU policy in the scene cache is re-enabled.For me this PR fixes #918 and #921, but I would like to have more testers.