Bug 474944 - High CPU usage when closing Discover after installing Firefox
Summary: High CPU usage when closing Discover after installing Firefox
Status: RESOLVED FIXED
Alias: None
Product: Discover
Classification: Applications
Component: Flatpak Backend (show other bugs)
Version: 5.27.8
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Plasma Bugs List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-09-27 17:36 UTC by Alberto Garcia
Modified: 2023-09-28 22:06 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.27.9
Sentry Crash Report:


Attachments
Stack trace (2.89 KB, text/plain)
2023-09-27 17:36 UTC, Alberto Garcia
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alberto Garcia 2023-09-27 17:36:14 UTC
Created attachment 161914 [details]
Stack trace

SUMMARY
I noticed that when you close Discover after installing Firefox the "plasma-discover" process keeps running using a lot of CPU for a minute or two.

This does not happen with all apps, but it can be reproduced with Firefox (and also with other popular apps like VLC and Gimp).

STEPS TO REPRODUCE
1. Open Discover
2. Search for Firefox (Flatpak) and open the package page (the one that shows the screenshots, version, size, license, ...)
3. Press "Install" on the top right corner
4. Wait for the installation to finish.
5. Close Discover
6. Open a terminal and look for running processes (with 'top' or similar)

OBSERVED RESULT
The "plasma-discover" process keeps running for a minute or two using a lot of CPU

EXPECTED RESULT
The "plasma-discover" process dies shortly after closing the Discover window.

SOFTWARE/OS VERSIONS
OS: Arch Linux
KDE Plasma version: 5.27.8
KDE Frameworks version: 5.110.0
Qt version: 5.5.10
Discover: 5.27.8

ADDITIONAL INFORMATION
I'm attaching a stack trace of the running plasma-discover process after the main window is closed.

From the high number of QQuickItemPrivate::derefWindow() calls it seems that a large number of widgets are being destroyed.

I haven't debugged it but Firefox in particular has almost 2000 reviews on Flathub, and I have a have a hunch that this might be the cause of the problem (is Discover preloading them or something?).

On a second test, installing Firefox directly from the Discover search results (i.e. without opening the page) does not seem to cause this problem.
Comment 1 Bug Janitor Service 2023-09-28 14:15:33 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/discover/-/merge_requests/644
Comment 2 Marco Martin 2023-09-28 14:23:09 UTC
Git commit d4fc7536c77058c60e5320a4cd33e57bdb184d8d by Marco Martin.
Committed on 28/09/2023 at 16:10.
Pushed by mart into branch 'master'.

Only preload a couple of screens worth of comments

Discover used to preload every comment in order to have the scrollbar
behaving as good as possible with variable height items.
However some applications like Firefox have thousands of comments
which will freeze firefox for minutes when scrolling quickly,
eat a lot of memory and will make discover even slow to quit
in order to delete the thousands of items it created.

Cache only a couple of screens worth of comments, so that applications with few comments
behave well and applications with thousands remain efficient

M  +2    -1    discover/qml/ReviewsPage.qml

https://invent.kde.org/plasma/discover/-/commit/d4fc7536c77058c60e5320a4cd33e57bdb184d8d
Comment 3 Marco Martin 2023-09-28 14:24:27 UTC
Git commit acb816be7577f4a039a7dffd2b29a3dc627fa70c by Marco Martin.
Committed on 28/09/2023 at 16:24.
Pushed by mart into branch 'Plasma/5.27'.

Only preload a couple of screens worth of comments

Discover used to preload every comment in order to have the scrollbar
behaving as good as possible with variable height items.
However some applications like Firefox have thousands of comments
which will freeze firefox for minutes when scrolling quickly,
eat a lot of memory and will make discover even slow to quit
in order to delete the thousands of items it created.

Cache only a couple of screens worth of comments, so that applications with few comments
behave well and applications with thousands remain efficient

M  +2    -1    discover/qml/ReviewsPage.qml

https://invent.kde.org/plasma/discover/-/commit/acb816be7577f4a039a7dffd2b29a3dc627fa70c