-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Always render SVG to Pixmap, to prevent main thread stucking due to File IO #12904
Conversation
…stucking due to IO operations
fyi for the QML skin in general it would make sense to have some infrastructure in place that renders our SVG sources to pixmaps of different sizes as part of the build because that is much much faster to render (https://doc.qt.io/qt-6/qml-qtquick-image.html#sourceSize-prop) |
This is an interesting finding. Maybe we can implement a caching around |
I have just skimmed through the Qt source and it look like there is already a caching in place. We do probably something wrong that invalidates the cache constantly. |
Did you test this on Linux, does it improve performance there? |
@JoergAtGithub looks like the issue you discovered is also the reason some SVGs automagically update sometimes when I switch back to the Mixxx window after having edited them. |
Does this PR fixes this issue for you? |
I can't tell, I can't reproduce it reliably in the first place. |
I should have taken more notes:
Anyway, the rendering at this place is not ideal, because we may scale the picture and already have lost the vectors. Did you consider to cache a QImage in the draw function? |
I use this since some months on Windows now, and I' pretty sure, that this is only benficial. Slightly less overall CPU usage and less stucking events. |
I am currently consider if this this is a 2.4.2 fix or not. On one hand it looks experimental, on the other hand it seems to have a good effect on windows. Is there a receipt for a test? I like to do the Linux test. |
I'm pretty sure, that it will not harm Linux. But I don't know if the addressed problem exist on Linux too. It might depend on X11 / Wayland. Testing both would make sense. I'm total unsure about macOS. Which was always handled different here - and this different handling is not touched by this PR. To trigger complete rerendering of all SVG images, I need to do some operations with the Mixxx main window (minimize/maximize) or other windows (moving Mixxx preferences dialog or other app windows, change app focus, etc.). But in the profiler I see the SVG rendering also happen in normal operation, but there only for a few images at a time. |
I have debugged a quite a bit through the Qt source, and it turns out that The QSvgRenderer does not use caching. Apart form resizing, which is heavy anyway and the performance aspect can be neglected. It happens during hover actions and GUI interactions. The disc access happens if qss states things like this: mixxx/res/skins/LateNight/style_palemoon.qss Line 2218 in 067792b
A workaround would be to compile all that into a resource file that can be kept im memory. Using here a pre rendered QPixmaps for streched SVGs will probably introduce blurry pixel. |
This PR solves the issue already, why searching for a workaround? |
I cannot confirm, the on-the-fly file reading is still there even with this PR. |
Hmm - here it helped against the on the fly file reading... |
BTW: There are big improvements in this area in Qt6.8, but mainly affecting QtQuick/QML which has the issue as well: https://www.qt.io/blog/vector-graphics-in-qt-6.8 |
This is the call stack where in the fly rendering with file access happens without
The The Shade skin does not suffer the issue, because it does not use many SVGs. |
It could be interesting where the bottle neck is. Probably disc access. |
According to the profiler picture in the description it's I/O (violett color). The Windows file I/O system is usually slower than on Unix systems. The bandwith itself should be similar, but the access time differs. |
Closing this in favor of #13679 |
I noticed some stucking of the Main Thread, due to File IO. This happens from time to time during normal operation. The reason is re-rendering of many SVG files used in the skins at once. If the Main Thread stucks, of cause the waveform rendering and the Qt event queue stuck as well:
I could prevent this stucking by the experimental code of this PR, which always create a Pixmap for these images.
I don't know if this is a Windows specific issue, or also affect other platforms.