v19 Episode content loads slowly on Kodi startup
#1
Hello all,

I am using the following as the <content> tag for a recently added episodes widget:

xml:

<content target="video" sortorder="descending" sortby="dateadded" limit="10">videodb://tvshows/titles/-1/-1/?xsp=%7B%22rules%22%3A%7B%22and%22%3A%5B%7B%22field%22%3A%22playcount%22%2C%22operator%22%3A%22is%22%2C%22value%22%3A%220%22%7D%5D%7D%2C%22type%22%3A%22episodes%22%7D</content>

As you can see, I want to show the latest 10 unwatched episodes.  My issue is that, even though that is a database path, the widget does not load immediately on Kodi startup.  It takes a few seconds, even on a powerful Core i7 PC with 32GB of RAM on a Gigabit Ethernet network.  The media is on my Synology NAS, and it is accessed via SMB.

Is there anything I would need to change to make this content show up faster? I ask since I do not see the same lag on the recently added movies widget, which has the following content tag:

xml:

<content target="video"  sortorder="descending" sortby="dateadded" limit="10">videodb://movies/titles/?xsp=%7B%22rules%22%3A%7B%22and%22%3A%5B%7B%22field%22%3A%22playcount%22%2C%22operator%22%3A%22is%22%2C%22value%22%3A%220%22%7D%5D%7D%2C%22type%22%3A%22movies%22%7D</content>

And the media is coming from the same NAS, on the same network.

Should I be using a different path or content tag in order to speed the episodes widget up? Any help will be greatly appreciated.

Regards,

Bart
Amber Maintainer
Main HTPC: Intel Core i7, 32GB, nVidia GTX1080, Windows 11 Soundbar: Samsung HW-Q950A TV: LG CX Kodi: 19.3 Skin: Amber
Reply
#2
Does your skin also load widget content from other sources like addons or plugins? If yes, this is probably your issue ...

KODI seems to load/update one content container after another which isn't a problem if you only have videodb:// sources but this causes issues as soon as you are adding some addon/plugin widgets.

e.g. let's say you have 20 home widgets:
  • 10 widgets fetch their content from videodb:// sources
  • 10 widgets fetch their content from plugin:// sources

Now, the average content load times from videodb:// (local database) sources are usually very low (~5 ms), so even if you have 10 widgets everything is loaded/updated in ~50-100ms. 

This is different for addon/plugin sources because KODI has to start the python addon, fetch the data (e.g. http request) and then populate the container. So, the average load times are much higher (200-500ms) and can be even worse if the server which provides the addon data is slow.
In this case, it would take KODI about 5sec (best case) to update/load our 10 addon/plugin widgets

I've already taken a look how KODIs JobWorker handles these directory updates but unfortunately my c++ skills are not good enough to try to fix this issue yet. 
Again, I'm not sure if that's your problem but this is something every skin developer should keep in mind when adding addon/plugin widgets.
Reply
#3
(2021-05-13, 21:57)bsoriano Wrote:
xml:

<content target="video" sortorder="descending" sortby="dateadded" limit="10">videodb://tvshows/titles/-1/-1/?xsp=%7B%22rules%22%3A%7B%22and%22%3A%5B%7B%22field%22%3A%22playcount%22%2C%22operator%22%3A%22is%22%2C%22value%22%3A%220%22%7D%5D%7D%2C%22type%22%3A%22episodes%22%7D</content>

I noticed something else:

You should add a limit field directly in your "xsp=" parameter, otherwise this request would return ALL unwatched episodes which, depending on your tv library size, could take quite some time. You could also enable debug (component specific --> database) to see what db queries are too slow ...

xml:

   ...
    <rule field="playcount" operator="lessthan">
        <value>1</value>
    </rule>
    <limit>15</limit>
    <order direction="descending">dateadded</order>
   ...
Reply
#4
(2021-05-14, 14:09)bkury Wrote:
(2021-05-13, 21:57)bsoriano Wrote:
xml:

<content target="video" sortorder="descending" sortby="dateadded" limit="10">videodb://tvshows/titles/-1/-1/?xsp=%7B%22rules%22%3A%7B%22and%22%3A%5B%7B%22field%22%3A%22playcount%22%2C%22operator%22%3A%22is%22%2C%22value%22%3A%220%22%7D%5D%7D%2C%22type%22%3A%22episodes%22%7D</content>

I noticed something else:

You should add a limit field directly in your "xsp=" parameter, otherwise this request would return ALL unwatched episodes which, depending on your tv library size, could take quite some time. You could also enable debug (component specific --> database) to see what db queries are too slow ...

xml:

   ...
    <rule field="playcount" operator="lessthan">
        <value>1</value>
    </rule>
    <limit>15</limit>
    <order direction="descending">dateadded</order>
   ...
@bkury , thanks! I just did as you suggest, and also tested with just that widget and the recently added movies widget active.  It still took around 5 seconds for the widget content to appear.  What I do not understand is why the recently added movies widget appears immediately, since I have a big library (8000+ movies scattered around 2 different Synology NAS).

Regards,

Bart
Amber Maintainer
Main HTPC: Intel Core i7, 32GB, nVidia GTX1080, Windows 11 Soundbar: Samsung HW-Q950A TV: LG CX Kodi: 19.3 Skin: Amber
Reply
#5
(2021-05-13, 21:57)bsoriano Wrote: It still took around 5 seconds for the widget content to appear.  What I do not understand is why the recently added movies widget appears immediately, since I have a big library (8000+ movies scattered around 2 different Synology NAS).

I assume your TV library isn't that small either? In that case, you could further speed up your db request by adding the following as your FIRST rule:
xml:
 
<rule field="dateadded" operator="after">
   <value>2021-01-01</value>
</rule>
This will only process episodes added this year which should be sufficient for a "Recently added" widget.
Reply
#6
(2021-05-15, 00:00)bkury Wrote:
(2021-05-13, 21:57)bsoriano Wrote: It still took around 5 seconds for the widget content to appear.  What I do not understand is why the recently added movies widget appears immediately, since I have a big library (8000+ movies scattered around 2 different Synology NAS).

I assume your TV library isn't that small either? In that case, you could further speed up your db request by adding the following as your FIRST rule:
xml:
 
<rule field="dateadded" operator="after">
   <value>2021-01-01</value>
</rule>
This will only process episodes added this year which should be sufficient for a "Recently added" widget.
@bkury , thanks! I had not thought of that.  No, my tv library is 900+ tv shows, and 21k+ episodes.  I will test with that.

Regards,

Bart
Amber Maintainer
Main HTPC: Intel Core i7, 32GB, nVidia GTX1080, Windows 11 Soundbar: Samsung HW-Q950A TV: LG CX Kodi: 19.3 Skin: Amber
Reply

Logout Mark Read Team Forum Stats Members Help
Episode content loads slowly on Kodi startup0