Bug 457408 - Discover is slow to load when a lot of backends fail at the same time
Summary: Discover is slow to load when a lot of backends fail at the same time
Status: RESOLVED FIXED
Alias: None
Product: Discover
Classification: Applications
Component: KNewStuff Backend (show other bugs)
Version: 5.25.3
Platform: Fedora RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: Plasma Bugs List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-08-02 11:53 UTC by Jonathan Wakely
Modified: 2022-10-13 16:48 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.26.1


Attachments
Output of plasma-discover --backends kns-backend --mode Update (18.98 KB, text/plain)
2022-08-02 13:54 UTC, Jonathan Wakely
Details
Output of plasma-discover --backends flatpak-backend,kns-backend --mode Update (19.07 KB, text/plain)
2022-08-02 14:04 UTC, Jonathan Wakely
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Wakely 2022-08-02 11:53:23 UTC
There's still something wrong with the Discover UX, despite Bug 443555 fixing the worst source of slowness.

If I get a systray notification that there are updates, and I click on it, it takes 30 seconds to stop showing the "fetching updates" progress bar. Why? Is it refreshing  something? It doesn't seem to be, because it still tells me I have system RPMs to update, even though I've already updated them on the command line with dnf. So it's not refreshing the packagekit backend, otherwise it would know that the updates have been installed.

The available backends are:

$ plasma-discover --listbackends 
Available backends:
 * kns-backend
 * packagekit-backend
 * fwupd-backend
 * flatpak-backend


If I run 'plasma-discover --backends flatpak-backend,packagekit-backend,fwupd-backend' then the window loads instantly, and takes less than a second to finish "Fetching updates" and show "Up to date" at the bottom left corner.

If I add kns-backend to that list, the window opens but shows "Fetching updates" and is completely unresponsive for 30 seconds. Is that the same problem as when I click on the "Updates available" notification?

What even is KNewStuff, and what do I miss out on if I disable it?
Comment 1 Jonathan Wakely 2022-08-02 12:11:06 UTC
Is it even possible to disable that backend? I don't see anything under Settings in the discover app, or any discoverrc config setting that would disable the kns-backend (or any other backend).
Comment 2 Nate Graham 2022-08-02 13:39:20 UTC
> If I run 'plasma-discover --backends flatpak-backend,packagekit-backend,fwupd-backend' then
> the window loads instantly, and takes less than a second to finish "Fetching updates" and show
> "Up to date" at the bottom left corner.
That's excellent news.

> Is that the same problem as when I click on the "Updates available" notification?

Yes, when you open Discover from the notifier, it loads all backends, so that'll be the cause there too.

So we need to figure out why the KNS backend is so slow for you. Can you paste the output from your terminal window when you run `plasma-discover --backends kns-backend --mode Update`? Thanks!
Comment 3 Jonathan Wakely 2022-08-02 13:54:36 UTC
Created attachment 151072 [details]
Output of plasma-discover --backends kns-backend --mode Update

This is the output of that command. However, when I run this, the UI finishes loading and is responsive almost immediately.

So although this output shows lots of errors (which I'm told are already fixed after 5.25.3) they don't seem to be the cause of the slowness.
Comment 4 Jonathan Wakely 2022-08-02 14:04:31 UTC
Created attachment 151074 [details]
Output of plasma-discover --backends flatpak-backend,kns-backend --mode Update

This is the output of the same command but using flatpak-backend,kns-backend

Now, the UI takes 16 seconds to go from "Fetching updates" to "Up to date", and then takes even longer to actually be responsive (maybe the flatpak backend is still updating in a background thread?). It takes another 20+ seconds to actually be responsive and let me click on anything (it won't even close the window during that time, clicking the close button brings up the 'Application "discover" is not responding' dialog to kill it).

If I use --backends fwupd-backend,kns-backend then it loads immediately. Similarly, if I use just flatpak-backend or just packagekit-backend, it loads immediately.

But it's very slow when kns-backend is combined with either flatpak-backend or packagekit-backend. And of course all of them are enabled by default when you click the update notifier.
Comment 5 Nate Graham 2022-08-02 14:21:16 UTC
Very interesting observation, thanks for that.
Comment 6 Nate Graham 2022-08-02 14:21:59 UTC
I can reproduce this, too.
Comment 7 Jonathan Wakely 2022-08-02 14:28:52 UTC
(In reply to Jonathan Wakely from comment #4)
> If I use --backends fwupd-backend,kns-backend then it loads immediately.
> Similarly, if I use just flatpak-backend or just packagekit-backend, it
> loads immediately.

This suggests that there is caching happening, and that for some combinations of backends, the already-cached set of updates is reused and quickly loaded.

But for some "bad" combinations, the cache isn't used, and so some of the updates get re-fetched every time, making it slow. And the default (all backends enabled) happens to be one of those bad combinations.

Just a guess though.
Comment 8 Aleix Pol 2022-10-13 15:38:53 UTC
This should be addressed by https://invent.kde.org/plasma/discover/-/merge_requests/383
Comment 9 Aleix Pol 2022-10-13 15:45:10 UTC
Git commit b704933b2d8cf92c8b6bf552f1ee4c1f817850d9 by Aleix Pol.
Committed on 13/10/2022 at 15:40.
Pushed by apol into branch 'master'.

Delay subCategoriesChanged signals when disabling

They can trigger a lot of JS code that induce lockups
Related: bug 401666

M  +17   -2    libdiscover/Category/Category.cpp
M  +2    -0    libdiscover/Category/Category.h

https://invent.kde.org/plasma/discover/commit/b704933b2d8cf92c8b6bf552f1ee4c1f817850d9
Comment 10 Aleix Pol 2022-10-13 15:47:55 UTC
Git commit a3dd72f42c92c9a7077164697e5e9b0badf518b4 by Aleix Pol Gonzalez, on behalf of Aleix Pol.
Committed on 13/10/2022 at 15:47.
Pushed by apol into branch 'Plasma/5.26'.

Delay subCategoriesChanged signals when disabling

They can trigger a lot of JS code that induce lockups
Related: bug 401666


(cherry picked from commit b704933b2d8cf92c8b6bf552f1ee4c1f817850d9)

M  +17   -2    libdiscover/Category/Category.cpp
M  +2    -0    libdiscover/Category/Category.h

https://invent.kde.org/plasma/discover/commit/a3dd72f42c92c9a7077164697e5e9b0badf518b4