Bug 450394

Summary: BambooTracker slows down on Breeze, due to leaking QProxyStyle and Breeze installing global event handlers
Product: [Plasma] Breeze Reporter: nyanpasu64 <nyanpasu64>
Component: QStyleAssignee: Plasma Bugs List <plasma-bugs-null>
Status: CONFIRMED ---    
Severity: normal CC: nate, noahadvs, uhhadd
Priority: NOR    
Version First Reported In: 5.24.1   
Target Milestone: ---   
Platform: Other   
OS: Linux   
See Also: https://bugs.kde.org/show_bug.cgi?id=442465
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description nyanpasu64 2022-02-16 16:57:53 UTC
SUMMARY
When I run BambooTracker and open and close many different instrument dialogs, the application slows down when rendering with Breeze theme.

STEPS TO REPRODUCE
1. Install/build and run https://github.com/BambooTracker/BambooTracker (self-built or from a distro package).
2. Download and extract https://github.com/BambooTracker/BambooTracker/files/7169359/32.64.128.instruments.zip, and open "128 instruments.btm" in BambooTracker.
3. In the instruments pane in the top of the window, double-click each instrument and then close the dialog (eg. pressing Esc).

The application leaks QProxyStyle (yes, it should be fixed, I reported at https://github.com/BambooTracker/BambooTracker/issues/418). Each FM instrument dialog creates dozens of `LabeledVerticalSlider`, each with their own `SliderStyle : QProxyStyle` instance intended to set `styleHint(QStyle::SH_Slider_AbsoluteSetButtons) = Qt::LeftButton`. When you open dozens of instrument dialogs, the app becomes increasingly unresponsive as `QCoreApplication` loops through around a thousand event filters per event. (Due to another bug, opening and closing an instrument dialog doesn't delete the dialog object, so you only need to open and close one dialog at a time to get the slowdown.)

I haven't fixed the bugs in BambooTracker itself, and neither have the app's maintainers. I suspect a lazy-init `static SliderStyle * = nullptr` might work better than the ideas I listed in the original bug report.

OBSERVED RESULT
The application should start slowing down after around 10 instruments. By the time you've opened 30-40 instrument dialogs, there will be a noticeable delay (0.5-1 second) opening/closing instrument or other dialogs. The slowdown increases as you open more instruments.

EXPECTED RESULT
Each QProxyStyle created doesn't cause a global slowdown. I don't notice any slowdown when setting KDE to use the Fusion application style instead of Breeze.

SOFTWARE/OS VERSIONS
Operating System: Arch Linux
KDE Plasma Version: 5.24.1
KDE Frameworks Version: 5.91.0
Qt Version: 5.15.2
Kernel Version: 5.16.9-zen1-1-zen (64-bit)
Graphics Platform: X11
Processors: 12 × AMD Ryzen 5 5600X 6-Core Processor
Memory: 15.6 GiB of RAM
Graphics Processor: NVIDIA GeForce GT 730/PCIe/SSE2

ADDITIONAL INFORMATION
Initially reported as 442465, which was closed with the message "If you have an example of actual apps in the wild using proxy styles and having lag due to Breeze, please open a new bug about this."