Kodi Community Forum

Full Version: Skin optimization Question
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Just wondering, If i want the lightest and fastest version of skin,
What are the factors that affects the loading speed?
Will it make any difference if i remove all unnecessary includes, textures, variables?
Because that's what i'm planning to do..
(2015-08-24, 16:16)denywinarto Wrote: [ -> ]Just wondering, If i want the lightest and fastest version of skin,
What are the factors that affects the loading speed?
Will it make any difference if i remove all unnecessary includes, textures, variables?
Because that's what i'm planning to do..
denywinarto,

Go look at this thread for some ideas on speeding up a skin

http://forum.kodi.tv/showthread.php?tid=...timisation

Two things to take away from the discussions in this thread are. One, I/O is evil (read very slow), so anything you can do to reduce will speed things up. And two, any unnecessary code you can remove can only speed things up.

But also remember, if the user thinks it's fast, it's fast. Something as simple as reducing the time to show an animation can give the user the impression that things are happening quicker.

Hope this helps.
Wyrm (AppTV)
http://kodi.wiki/view/Texture_Attributes#Size

Variables should be quicker than loads of visible conditions.
@wyrm : thanks at least I know where to look now, I'll try to trim my skin down
@Hitcher : I'm using dynamic content to call home panel items from variables, but I'm still getting 1-2 sec delay..

There's something I don't see in those threads,
which one is faster,
includes in 1 single file or calling includes from another file?
(2015-08-25, 03:17)denywinarto Wrote: [ -> ]@wyrm : thanks at least I know where to look now, I'll try to trim my skin down
@Hitcher : I'm using dynamic content to call home panel items from variables, but I'm still getting 1-2 sec delay..

There's something I don't see in those threads,
which one is faster,
includes in 1 single file or calling includes from another file?
denywinarto,

To the best of my knowledge there is no real difference in speed between one big include or calling multiple include files from outside the main Iinclude file, but there is potentially a saving in memory usage.

If you are using a include in one place only you can save memory by using this form of include statement

PHP Code:
<include file="file name.xml">includename</include> 

You would then NOT include that include file in the main include file, thus saving one memory copy of the required include.

As to the delay of 1-2 seconds, that is probably more likely to do with what you are trying to display as to how you are displaying it. What exactly are you trying to show and how you have called it? Post your <content> section and we might be able to suggest a better way to show what you want displayed.

Wyrm (AppTV)
(2015-08-25, 10:31)wyrm Wrote: [ -> ]
(2015-08-25, 03:17)denywinarto Wrote: [ -> ]@wyrm : thanks at least I know where to look now, I'll try to trim my skin down
@Hitcher : I'm using dynamic content to call home panel items from variables, but I'm still getting 1-2 sec delay..

There's something I don't see in those threads,
which one is faster,
includes in 1 single file or calling includes from another file?
denywinarto,

To the best of my knowledge there is no real difference in speed between one big include or calling multiple include files from outside the main Iinclude file, but there is potentially a saving in memory usage.

If you are using a include in one place only you can save memory by using this form of include statement

PHP Code:
<include file="file name.xml">includename</include> 

You would then NOT include that include file in the main include file, thus saving one memory copy of the required include.

As to the delay of 1-2 seconds, that is probably more likely to do with what you are trying to display as to how you are displaying it. What exactly are you trying to show and how you have called it? Post your <content> section and we might be able to suggest a better way to show what you want displayed.

Wyrm (AppTV)

PHP Code:
<include file="file name.xml">includename</include> 

I see, but what if the include is called multiple times such as animations includes?
Can we use it too?

I think my delay is related to dynamic content mechanism,
I'm calling 12 items x ~30 different playlists in home menu (Ace) using dynamic content..
it's quite alot because i also include genres selection..

Image

there's 1-3 second delay when loading the items
I'm concerned because i'm only using a smaller sample library that i made in my local PC to test my custom skin..
My real library is like 40TB with hundreds of tvshows and thousands of movies..
I have removed all unnecessary windows and xml..

I think there are the related codes, to call the first playlist

IncludeMenuplaylist.xml

Code:
<include name="mf_contentvpl1">
        <control type="group">
            <posx>0</posx>
            <posy>60</posy>
            <control type="panel" id="510">
                <!--- Recent Video -->
                <include>panel_video_v</include>
                <include>panel_videolayout</include>        
                <visible>Container(9000).HasFocus(31) + SubString(skin.string(mfvpl1_list),latest)</visible>
                <content target="video" limit="12">$VAR[DefWidgetContent]</content>
            </control>
            <control type="panel" id="510">
                <!--- Recomemended Video -->
                <include>panel_video_v</include>
                <include>panel_videolayout</include>
                <visible>Container(9000).HasFocus(31) + SubString(skin.string(mfvpl1_list),random)</visible>
                <content target="video" limit="12">$VAR[DefWidgetContent2]</content>
            </control>
        </control>
    </include>

IncludeVIPMenu.xml

Code:
        <item id="31">
            <!-- Vpl 1 -->
            <label fallback="31072">$INFO[skin.string(vpl1.label)]</label>
            <label2>West Movie</label2>
            <icon fallback="special://skin/backgrounds/vplaylist.jpg">$VAR[value_mainmenubg_vpl1]</icon>
            <onclick>Skin.SetBool(playlists)</onclick>
            <onclick>Skin.SetString(playlist,v1)</onclick>
            <onclick condition="Container(9000).HasFocus(31) + SubString(skin.string(mfvpl1_list),latest)">ActivateWindow(videolibrary,$INFO[skin.string(vpl1.path)],return)</onclick>    
            <onclick condition="Container(9000).HasFocus(31) + SubString(skin.string(mfvpl1_list),random)">ActivateWindow(videolibrary,$INFO[skin.string(vpl1a.path)],return)</onclick>
            <property name="dropdown">not_empty</property>            
            <property name="widget">Playlist</property>
            <property name="widget2">Playlist2</property>            
            <property name="widgetPlaylist">C:/Users/Downloader/AppData/Roaming/Kodi/userdata/playlists/video/Barat.xsp</property>
            <property name="widgetPlaylist2">C:/Users/Downloader/AppData/Roaming/Kodi/userdata/playlists/video/Recommended_Barat.xsp</property>
            <visible>!IsEmpty(skin.string(vpl1))</visible>
        </item>

IncludeVariables.xml

Code:
<variable name="DefWidgetContent2">
        <!-- Individual Widget Paths -->
      <value condition="StringCompare(Container(9000).ListItem.Property(widget2),Playlist2)">$INFO[Container(9000).ListItem.Property(widgetPlaylist2)]</value>    
       </variable>
    
    <variable name="Widget_Title">
        <value condition="!IsEmpty(Container(510).ListItem.Title)">$INFO[Container(510).ListItem.Title]</value>
     </variable>
         
    <variable name="Widget_Subtitle">
        <value condition="!IsEmpty(Container(510).ListItem.TagLine)">$INFO[Container(510).ListItem.TagLine]</value>
     </variable>
    
    <variable name="Widget_Fanart">
        <value condition="!IsEmpty(Container(510).ListItem.Art(fanart))">$INFO[Container(510).ListItem.Art(fanart)]</value>
   </variable>
    
    <variable name="Widget_Plot">
        <value condition="!IsEmpty(Container(510).ListItem.Plot)">$INFO[Container(510).ListItem.Plot]</value>
    </variable>
    
    <variable name="Widget_TVShowTitle">
        <value condition="!IsEmpty(Container(510).ListItem.TVShowTitle)">$INFO[Container(510).ListItem.TVShowTitle]</value>
    </variable>
    
    <variable name="Widget_Genre">
        <value condition="!IsEmpty(Container(510).ListItem.Genre)">$INFO[Container(510).ListItem.Genre]</value>
   </variable>
    
    <variable name="Widget_Rating">
        <value condition="!IsEmpty(Container(510).ListItem.Rating)">$INFO[Container(510).ListItem.Rating]</value>
   </variable>

Is there anything else that could be optimized in terms of coding?
My sample library doesn't even have 1% content of the real library.. and it still lags 1-3 secs..
I haven't removed the unnecessary textures though..

BTW speaking of texture..
i think i remember reading somebody said using texture cache utility could also speed things up..
Let me see if i can find it again..
(2015-08-26, 15:14)denywinarto Wrote: [ -> ]
PHP Code:
<include file="file name.xml">includename</include> 

I see, but what if the include is called multiple times such as animations includes?
Can we use it too?
The real question is if you are only using the animation once why are you bothering with a include.
If you are using something as small as an animation block only once just inline the code as it would be quicker to load than using
a include. In fact, unless it would help with readability or making things easier to edit I would not bother with a include for anything
a small as a animation block (easy to edit is the main reason I have a few animations in includes).

Quote:I think my delay is related to dynamic content mechanism,
I'm calling 12 items x ~30 different playlists in home menu (Ace) using dynamic content..
it's quite alot because i also include genres selection..

there's 1-3 second delay when loading the items
I'm concerned because i'm only using a smaller sample library that i made in my local PC to test my custom skin..
My real library is like 40TB with hundreds of tvshows and thousands of movies..
I have removed all unnecessary windows and xml..
I'm surprised it only takes 1-3 seconds before you see something,
you are making things way harder than they need to be. Let's see if we can catch all of the problems with your posted code.

Quote:I think there are the related codes, to call the first playlist

IncludeMenuplaylist.xml

Code:
[php]<include name="mf_contentvpl1">
        <control type="group">
            <posx>0</posx>
            <posy>60</posy>
            <control type="panel" id="510">
                <!--- Recent Video -->
                <include>panel_video_v</include>
                <include>panel_videolayout</include>        
                <visible>Container(9000).HasFocus(31) + SubString(skin.string(mfvpl1_list),latest)</visible>
                <content target="video" limit="12">$VAR[DefWidgetContent]</content>
            </control>
            <control type="panel" id="510">
                <!--- Recomemended Video -->
                <include>panel_video_v</include>
                <include>panel_videolayout</include>
                <visible>Container(9000).HasFocus(31) + SubString(skin.string(mfvpl1_list),random)</visible>
                <content target="video" limit="12">$VAR[DefWidgetContent2]</content>
            </control>
        </control>
    </include>

IncludeVIPMenu.xml

Code:
        <item id="31">
            <!-- Vpl 1 -->
            <label fallback="31072">$INFO[skin.string(vpl1.label)]</label>
            <label2>West Movie</label2>
            <icon fallback="special://skin/backgrounds/vplaylist.jpg">$VAR[value_mainmenubg_vpl1]</icon>
            <onclick>Skin.SetBool(playlists)</onclick>
            <onclick>Skin.SetString(playlist,v1)</onclick>
            <onclick condition="Container(9000).HasFocus(31) + SubString(skin.string(mfvpl1_list),latest)">ActivateWindow(videolibrary,$INFO[skin.string(vpl1.path)],return)</onclick>    
            <onclick condition="Container(9000).HasFocus(31) + SubString(skin.string(mfvpl1_list),random)">ActivateWindow(videolibrary,$INFO[skin.string(vpl1a.path)],return)</onclick>
            <property name="dropdown">not_empty</property>            
            <property name="widget">Playlist</property>
            <property name="widget2">Playlist2</property>            
            <property name="widgetPlaylist">C:/Users/Downloader/AppData/Roaming/Kodi/userdata/playlists/video/Barat.xsp</property>
            <property name="widgetPlaylist2">C:/Users/Downloader/AppData/Roaming/Kodi/userdata/playlists/video/Recommended_Barat.xsp</property>
            <visible>!IsEmpty(skin.string(vpl1))</visible>
        </item>

IncludeVariables.xml

Code:
<variable name="DefWidgetContent2">
        <!-- Individual Widget Paths -->
      <value condition="StringCompare(Container(9000).ListItem.Property(widget2),Playlist2)">$INFO[Container(9000).ListItem.Property(widgetPlaylist2)]</value>    
       </variable>
    
    <variable name="Widget_Title">
        <value condition="!IsEmpty(Container(510).ListItem.Title)">$INFO[Container(510).ListItem.Title]</value>
     </variable>
         
    <variable name="Widget_Subtitle">
        <value condition="!IsEmpty(Container(510).ListItem.TagLine)">$INFO[Container(510).ListItem.TagLine]</value>
     </variable>
    
    <variable name="Widget_Fanart">
        <value condition="!IsEmpty(Container(510).ListItem.Art(fanart))">$INFO[Container(510).ListItem.Art(fanart)]</value>
   </variable>
    
    <variable name="Widget_Plot">
        <value condition="!IsEmpty(Container(510).ListItem.Plot)">$INFO[Container(510).ListItem.Plot]</value>
    </variable>
    
    <variable name="Widget_TVShowTitle">
        <value condition="!IsEmpty(Container(510).ListItem.TVShowTitle)">$INFO[Container(510).ListItem.TVShowTitle]</value>
    </variable>
    
    <variable name="Widget_Genre">
        <value condition="!IsEmpty(Container(510).ListItem.Genre)">$INFO[Container(510).ListItem.Genre]</value>
   </variable>
    
    <variable name="Widget_Rating">
        <value condition="!IsEmpty(Container(510).ListItem.Rating)">$INFO[Container(510).ListItem.Rating]</value>
   </variable>

Is there anything else that could be optimized in terms of coding?
My sample library doesn't even have 1% content of the real library.. and it still lags 1-3 secs..
I haven't removed the unnecessary textures though..
Biggest issue is that ALL of you variable definitions have only one item. Just replace the $INFO from your value statements above
and don't bother with the condition as if the $INFO is empty the value with be empty anyway. So instead of code like this

PHP Code:
            <control type="panel" id="510">
                <!--- 
Recent Video -->
                <include>
panel_video_v</include>
                <include>
panel_videolayout</include>        
                <
visible>Container(9000).HasFocus(31) + SubString(skin.string(mfvpl1_list),latest)</visible>
                <
content target="video" limit="12">$VAR[DefWidgetContent]</content>
            </
control

Just use this and do away with the DefWidgetContent variable as its pointless.

PHP Code:
            <control type="panel" id="510">
                <!--- 
Recent Video -->
                <include>
panel_video_v</include>
                <include>
panel_videolayout</include>        
                <
visible>Container(9000).HasFocus(31) + SubString(skin.string(mfvpl1_list),latest)</visible>
                <
content target="video" limit="12">$INFO[Container(9000).ListItem.Property(widgetPlaylist2)]</content>
            </
control

Next avoid substring compares like the plague as they are verrrrrrrryyyyyyy slow. So if you have only two options that you want to check
use a boolean instead. Instead of using.

PHP Code:
<property name="dropdown">not_empty</property

I would use something like

PHP Code:
Skin.SetBool(v1_list_dropdown

And set it to true if you want a dropdown to be available.

Now while it will not save a great deal of time as I'm pretty sure visible conditions are cached
(the result of a condition are only checked once and the result is reused each time you use it), Kodi will still have to parse each
instruction in the xml file to display your screen. So don't keep checking for the same condition if your code is nested in a block
where you have already checked something. For example.

PHP Code:
<include name="mf_contentvpl1">
        <
control type="group">
            <
posx>0</posx>
            <
posy>60</posy>
            <
control type="panel" id="510">
                <!--- 
Recent Video -->
                <include>
panel_video_v</include>
                <include>
panel_videolayout</include>        
                <
visible>Container(9000).HasFocus(31) + SubString(skin.string(mfvpl1_list),latest)</visible>
                <
content target="video" limit="12">$VAR[DefWidgetContent]</content>
            </
control>
            <
control type="panel" id="510">
                <!--- 
Recomemended Video -->
                <include>
panel_video_v</include>
                <include>
panel_videolayout</include>
                <
visible>Container(9000).HasFocus(31) + SubString(skin.string(mfvpl1_list),random)</visible>
                <
content target="video" limit="12">$VAR[DefWidgetContent2]</content>
            </
control>
        </
control>
    </include> 

Change this to.

PHP Code:
<include name="mf_contentvpl1">
        <
control type="group">
            <
posx>0</posx>
            <
posy>60</posy>
            <
visible>Container(9000).HasFocus(31)</visible>
            <
control type="panel" id="510">
                <!--- 
Recent Video -->
                <include>
panel_video_v</include>
                <include>
panel_videolayout</include>        
                <
visible>SubString(skin.string(mfvpl1_list),latest)</visible>
                <
content target="video" limit="12">$VAR[DefWidgetContent]</content>
            </
control>
            <
control type="panel" id="510">
                <!--- 
Recomemended Video -->
                <include>
panel_video_v</include>
                <include>
panel_videolayout</include>
                <
visible>SubString(skin.string(mfvpl1_list),random)</visible>
                <
content target="video" limit="12">$VAR[DefWidgetContent2]</content>
            </
control>
        </
control>
    </include> 

And remove the occurrence of "Container(9000).HasFocus(31)" in the panels and items as you have already checked that condition
and you don't really need to check again.

Now will the above suggestions reduce the time to display your panel any great amount? Don't know, as Kodi needs time to populate the
results of the playlist. If you can use an internal content listing (think of items that you would see in the root of the video library as examples)
that Kodi stores in its database that will certainly be quicker than if you use a custom playlist that needs to be pulled into the system. The things is
currently you are doing a lot of unnecessary checks and executing code that basically does nothing, so the the suggestions above can't hurt.

Quote:BTW speaking of texture..
i think i remember reading somebody said using texture cache utility could also speed things up..
Let me see if i can find it again..
Would probably help a bit and certainly can't hurt.

Make the changes I suggested above and see how you go. I have probably missed a number of things that might speed things up but until you cut back
on the worthless code its a bit hard to see what else needs fixing

Wyrm (AppTV)
Thanks wyrm, it seems to speed up a bit Big Grin
Quote:Biggest issue is that ALL of you variable definitions have only one item. Just replace the $INFO from your value statements above
and don't bother with the condition as if the $INFO is empty the value with be empty anyway.
This seems to help as it call the parameters directly, didn't think of this before

Quote:Next avoid substring compares like the plague as they are verrrrrrrryyyyyyy slow. So if you have only two options that you want to check
use a boolean instead

This is not related to the items panel isn't it?
It's for dropdown menu you see on the left side of my skin
Whenever "Alphabet" is clicked, the list you see there opens,
And when "Genre" is clicked, Alphabet and its subitems closes and Genre subitems opens.
So i guess we can't use skin.setbool for this?
If it doesn't help reducing the panel items lag i think it's fine..

Quote:Now while it will not save a great deal of time as I'm pretty sure visible conditions are cached
(the result of a condition are only checked once and the result is reused each time you use it), Kodi will still have to parse each
instruction in the xml file to display your screen. So don't keep checking for the same condition if your code is nested in a block
where you have already checked something

This screws up the bottom panel focus unfortunately,
all items show the same information of the first focused item
So i revert it..

It seems to be slightly faster, But i will have to test it again for my real library
Internal content?
Custom Playlist + dynamic content is the only way i know of..
That's the fastest way to sort content right?
I used randomandlastitem script before but the lag was way worse than this,,