Skip to content
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

slow startup esp with lots of skin widgets due to addon menu's caching removed on startup #24110

Open
7 tasks done
djay opened this issue Nov 17, 2023 · 7 comments
Open
7 tasks done
Labels
Triage: Needed (managed by bot!) issue that was just created and needs someone looking at it

Comments

@djay
Copy link

djay commented Nov 17, 2023

Bug report

Describe the bug

When starting kodi, any addon menus that were cached to disc (via the cacheToDisc=True param in the addon), are not used on startup. This leads to the user having to wait a long time if they have skin with many widgets which point to addon menus. This is particularly bad with a lot of widgets and on a lower end machine that can't handle so many python instances all loading at the same time (1 per widget).

It also seems like json-rpc calls used by widgets don't cache at all which is unexpected.

Expected Behavior

Kodi should startup fast with content quickly displayed in all widgets even if out of date , letting the user choose to wait for more updates or use the widgets as is.

Actual Behavior

Kodi calls all the addons menu at the same time no matter how many of them there are and doesn't matter if there is a cached menu on disk or how old it is. This can leave a page of widgets with spinning waiting indicators for many a long period, in some cases over a minute.

If there is limited memory, then this can often lead to crashing or memory managers killing the process due to too many addons loading at once

Possible Fix

Kodi should use the cached menu, regardless of how old initially so startup is fast. and then queue the actual call to the addon menu and refresh the widget once the menu has been cached again, thus limited the number of addons running simultaneously and letting the user browse some content even if its stale. Many lists don't change that often so in many cases the list would be unchanged.

To Reproduce

Steps to reproduce the behavior:

  1. Pick a skin with widgets
  2. Pick a plugin that allows caching it's menus
  3. Add widgets that point to the addon menus
  4. Open once and let the wdigets load
  5. Restart then notice the delay before the widgets are loaded.

Debuglog

  • not applicable

Screenshots

Here are some links or screenshots to help explain the problem:

  • not applicable

Additional context or screenshots (if appropriate)

Here is some additional context or explanation that might help:

None

Your Environment

Used Operating system:

  • Android

  • iOS

  • tvOS

  • Linux

  • macOS

  • Windows

  • Windows UWP

  • Operating system version/name: all

  • Kodi version: 18.0-Leia - latest

@xbmc-gh-bot xbmc-gh-bot bot added the Triage: Needed (managed by bot!) issue that was just created and needs someone looking at it label Nov 17, 2023
@ksooo
Copy link
Member

ksooo commented Nov 17, 2023

@djay please provide all information requested by the issue template, esp. debug log and exact Kodi version! As of now we do not even know which Kodi version you are talking about.

@djay djay changed the title addon menu's cached to disk are removed on startup causing slow startup esp with lots of skin widgets slow startup esp with lots of skin widgets due to addon menu's caching removed on startup Nov 20, 2023
@djay
Copy link
Author

djay commented Nov 20, 2023

@ksooo fixed

@lrusak
Copy link
Contributor

lrusak commented Nov 29, 2023

No debug log?

@djay
Copy link
Author

djay commented Dec 7, 2023

I can do better than a log. Here is a plugin that does a hack to get round this bug

https://github.com/nkestrel/kodi.service.plugin.listcachekeeper

On startup and when displaying cached lists, the log will show errors as Kodi tries and fails to delete the protected cache files

As you can see kodi is cleaning these cache files in startup, preventing kodi from a fast startup.

@djay
Copy link
Author

djay commented Dec 7, 2023

and here is the code that clears these cached lists out on startup

auto archiveCachePath = CSpecialProtocol::TranslatePath("special://temp/archive_cache/");

@djay
Copy link
Author

djay commented Dec 11, 2023

actually I've noticed that some skin widgets do not end up creating cache files on disk when set to a addons directory. Only when you go to the addon manually is the cache file created. So to fix this problem additional changes would be needed by skin widgets to generate those cache's and use them, as well as the caches not being wiped on startup. This would then result in the desired fast startup.

Not that sure on the code but I think what needs to be changed to use a cache is

JSONRPC_STATUS CFileOperations::GetDirectory(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)

I think the main part of the code does the caching for viewing the addons is

bool CGUIMediaWindow::GetDirectory(const std::string &strDirectory, CFileItemList &items)

@djay
Copy link
Author

djay commented May 4, 2024

@jmarshallnz what do you think of the idea of caching lists from plugins to disc in json-rpc if they are slow? perhaps with an extra flag if you want to ensure its fresh?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Triage: Needed (managed by bot!) issue that was just created and needs someone looking at it
Projects
None yet
Development

No branches or pull requests

3 participants