Kodi Community Forum

Full Version: Variables slow if condition "Container.HasFocus" is used
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello

Sadly Variables evaluate verry slow if "Container(foo).Hasfocus(bar)" is used.

Ideas for workarounds??

My Widgetvariables look like this:
PHP Code:
<variable name="DBWidgetLeft"
        <
value condition="Container(9000).Hasfocus(3) + [[!Skin.HasSetting(LeftMusicWidgetShow-RecentAlbums) + !Skin.HasSetting(LeftMusicWidgetShow-RecentSongs) + !Skin.HasSetting(LeftMusicWidgetShow-Nothing) + !Skin.HasSetting(LeftMusicWidgetShow-OnFocus)] | Skin.HasSetting(LeftMusicWidgetShow-OnFocus)]">special://skin/widgetplaylists/Music/Music_(OnFocus).xsp</value>
        
<value condition="Container(9000).Hasfocus(3) + Skin.HasSetting(LeftMusicWidgetShow-RecentAlbums)">plugin://service.library.data.provider?type=recommendedalbums&reload=$INFO[Window.Property(recommendedalbums)]</value>   <!-- musicdb://recentlyplayedalbums/ -->
        
<value condition="Container(9000).Hasfocus(3) + Skin.HasSetting(LeftMusicWidgetShow-RecentSongs)">special://skin/widgetplaylists/Music/Music_(RecentlyPlayed-Songs).xsp</value> 
        
<value condition="Container(9000).Hasfocus(8) + [[!Skin.HasSetting(LeftMusicVideosWidgetShow-Recent) + !Skin.HasSetting(LeftMusicVideosWidgetShow-Nothing) + !Skin.HasSetting(LeftMusicVideosWidgetShow-OnFocus)] | Skin.HasSetting(LeftMusicVideosWidgetShow-OnFocus)]">special://skin/widgetplaylists/MusicVideos/MusicVideos_(OnFocus).xsp</value>
        
<value condition="Container(9000).Hasfocus(8) + Skin.HasSetting(LeftMusicVideosWidgetShow-Recent)">special://skin/widgetplaylists/MusicVideos/Musicvideos_(InProgress).xsp</value>
        
<value condition="Container(9000).Hasfocus(18) + [[!Skin.HasSetting(LeftMusicClipsWidgetShow-Recent) + !Skin.HasSetting(LeftMusicClipsWidgetShow-Nothing) + !Skin.HasSetting(LeftMusicClipsWidgetShow-OnFocus)] | Skin.HasSetting(LeftMusicClipsWidgetShow-OnFocus)]">special://skin/widgetplaylists/MusicVideos/MusicClips_(OnFocus).xsp</value>
        
<value condition="Container(9000).Hasfocus(18) + Skin.HasSetting(LeftMusicClipsWidgetShow-Recent)">special://skin/widgetplaylists/MusicVideos/MusicClips_(InProgress).xsp</value>
        
<value condition="Container(9000).Hasfocus(19) + [[!Skin.HasSetting(LeftConcertsWidgetShow-Recent) + !Skin.HasSetting(LeftConcertsWidgetShow-Nothing) + !Skin.HasSetting(LeftConcertsWidgetShow-OnFocus)] | Skin.HasSetting(LeftConcertsWidgetShow-OnFocus)]">special://skin/widgetplaylists/MusicVideos/Concerts_(OnFocus).xsp</value>
        
<value condition="Container(9000).Hasfocus(19) + Skin.HasSetting(LeftConcertsWidgetShow-Recent)">special://skin/widgetplaylists/MusicVideos/Concerts_(InProgress).xsp</value>
        
<value condition="Container(9000).Hasfocus(10) + [[!Skin.HasSetting(LeftMovieWidgetShow-Recent) + !Skin.HasSetting(LeftMovieWidgetShow-Nothing) + !Skin.HasSetting(LeftMovieWidgetShow-OnFocus)] | Skin.HasSetting(LeftMovieWidgetShow-OnFocus)]">special://skin/widgetplaylists/Videos/Movies_(OnFocus).xsp</value>
        
<value condition="Container(9000).Hasfocus(10) + Skin.HasSetting(LeftMovieWidgetShow-Recent)">special://skin/widgetplaylists/Videos/Movies_(InProgress).xsp</value>
        
<value condition="Container(9000).Hasfocus(16) + [[!Skin.HasSetting(LeftHDMovieWidgetShow-Recent) + !Skin.HasSetting(LeftHDMovieWidgetShow-Nothing) + !Skin.HasSetting(LeftHDMovieWidgetShow-OnFocus)] | Skin.HasSetting(LeftHDMovieWidgetShow-OnFocus)]">special://skin/widgetplaylists/Videos/HDMovies_(OnFocus).xsp</value>
        
<value condition="Container(9000).Hasfocus(16) + Skin.HasSetting(LeftHDMovieWidgetShow-Recent)">special://skin/widgetplaylists/Videos/HDMovies_(InProgress).xsp</value>
        
<value condition="Container(9000).Hasfocus(17) + [[!Skin.HasSetting(Left3DMovieWidgetShow-Recent) + !Skin.HasSetting(Left3DMovieWidgetShow-Nothing) + !Skin.HasSetting(Left3DMovieWidgetShow-OnFocus)] | Skin.HasSetting(Left3DMovieWidgetShow-OnFocus)]">special://skin/widgetplaylists/Videos/3DMovies_(OnFocus).xsp</value>
        
<value condition="Container(9000).Hasfocus(17) + Skin.HasSetting(Left3DMovieWidgetShow-Recent)">special://skin/widgetplaylists/Videos/3DMovies_(InProgress).xsp</value>
        
<value condition="Container(9000).Hasfocus(11) + [[!Skin.HasSetting(LeftTVShowWidgetShow-Recent) + !Skin.HasSetting(LeftTVShowWidgetShow-Nothing) + !Skin.HasSetting(LeftTVShowWidgetShow-OnFocus)] | Skin.HasSetting(LeftTVShowWidgetShow-OnFocus)]">special://skin/widgetplaylists/Videos/Episodes_(OnFocus).xsp</value>
        
<value condition="Container(9000).Hasfocus(11) + Skin.HasSetting(LeftTVShowWidgetShow-Recent)">special://skin/widgetplaylists/Videos/Episodes_(InProgress).xsp</value>
        
<value condition="Container(9000).Hasfocus(9) + [[!Skin.HasSetting(LeftDokuWidgetShow-Recent) + !Skin.HasSetting(LeftDokuWidgetShow-Nothing) + !Skin.HasSetting(LeftDokuWidgetShow-OnFocus)] | Skin.HasSetting(LeftDokuWidgetShow-OnFocus)]">special://skin/widgetplaylists/Videos/Dokus_(OnFocus).xsp</value>
        
<value condition="Container(9000).Hasfocus(9) + Skin.HasSetting(LeftDokuWidgetShow-Recent)">special://skin/widgetplaylists/Videos/Dokus_(InProgress).xsp</value>
        
<value></value>
    </
variable

and the content:
PHP Code:
<content target="$VAR[WidgetTarget]">$VAR[DBWidgetLeft]</content

Sadly it is to slow for my taste.
EDIT:(One List with different content according to Mainmenufocus position)/EDITEND

As soon as i code every widget separatly and use "<visible>Container(9000).Hasfocus(foo)</visible>" on top.
I dont have any speed issues.

Do i realy need to code 10 Times The same Widget with an other ID (and Content) to get the speed which im after.
Copy Paste 10 Times the same code, chanche the "List- and the "Container(foo).ListItem.XYZ" ID for every Copy to get this to work fast??

There Have to be other solutions! (Any Ideas?)

Did experimenting with includes for equal Partrs and Variable IDs ($VAR[WidgetID]) according to Container(9000).HasFocus(foo) without luck.

May one of You have a Idea or can Help.
(Goal is to show diffrent widgets (Content) according to the Focusposition of the Homemenu)

Regards
The best method for widgets is includes and/or visible conditions.

If you want to use one list then use conditional includes based on the skin settings and use the container focus conditions in their items.

Or you can have separate lists with includes for the content again but the lists use the container visible conditions. Also all the lists can have the same ID as long as only one is displayed at any one time.
Thanks for your reply

(2015-01-07, 22:10)Hitcher Wrote: [ -> ]The best method for widgets is includes and/or visible conditions.
jer, This is mainly what i think i learnd while trying to serarch for a propper solution.
(visible for "HasFocus"on top, and i've got the speed im after (but face other problems when it comes to simplify the code).)

(2015-01-07, 22:10)Hitcher Wrote: [ -> ]If you want to use one list then use conditional includes based on the skin settings and use the container focus conditions in their items.
Jer, goal was to use just one List with different Content according to Focus Position.
You talk abot conditional includes for the Content i guess:
PHP Code:
<include condition="Skinhas.Setting(ShowOnFocus)">blablup/OnFocus.xps<include>
<include 
condition="Skinhas.Setting(ShowImProgress)">blablup/InProgress.xps<include> 

(2015-01-07, 22:10)Hitcher Wrote: [ -> ]and use the container focus conditions in their items.
(I already do it this way)

(2015-01-07, 22:10)Hitcher Wrote: [ -> ]Or you can have separate lists with includes for the content again but the lists use the container visible conditions. Also all the lists can have the same ID as long as only one is displayed at any one time.
"Also all the lists can have the same ID as long as ..." -> this is where i run in to trubbles.

Did have a similar thuth, but i get problems as soon the (Widget-)List became focus (if i use the same ID on all lists).

Cant exactly tell why, but as soon as the List became Focus it shows the labels and/or Fanart of other widgetContent. (Shows Fanart from Widget1 instead of from Widget2 if Widget2 has focus.)

The only way to prevent this would be to have different ID's for every List and Widget (as long as i dont miss something. Do I?), which would end up in coding 10 Times the whole widget only diferted by the ID ($INFO[Container(9101).ListItem.Art(fanart)], $INFO[Container(9102).ListItem.Art(fanart)], $INFO[Container(9103).ListItem.Art(fanart)] and so on..)

My Attempt (same ID, includes):
PHP Code:
<!-- Widget1 -->
<
control type="group">
    <include>
WidgetListPosLeft</include>
    <include>
VisibleFadeEffect</include>
    <
visible>Container(9000).Hasfocus(3)</visible>     <!-- MainmenuFocusPosition -->
                
                <include>
WidgetTitleLableLeft</include>
                
                <
control type="list" id="9101">
                    <include>
WidgetItemSlideLeft</include>
                    <include>
WidgetListDimensionsLeft</include>
                    <
onleft>9101</onleft>
                    <
onright>9101</onright>
                    <
onup condition="!Skin.HasSetting(HideRightWidget)">8101</onup>
                    <
onup condition="Skin.HasSetting(HideRightWidget)">20</onup>
                    <
ondown condition="System.HasAddon(script.globalsearch)">9000</ondown>   <!-- 608 -->
                    <
ondown condition="!System.HasAddon(script.globalsearch)">9000</ondown>   <!-- 603 -->
                    <
viewtype label="535">list</viewtype>
                    <
pagecontrol>-</pagecontrol>
                    <
scrolltime>200</scrolltime>
                    <
orientation>Horizontal</orientation>
                    <!--
focusposition>3</focusposition-->
                    <
spinposx>0</spinposx>
                    
                    <include>
WidgetItemLayoutLeft</include>                    
                    
                    <
content target="Music">$VAR[Container(9000).Hasfocus(3)Left]</content>  <!--Here i could use conditional includes according to Skinsettings of co-->

                </
control>
                
                <include>
WidgetNavArrowsLeft</include>
                
            </
control>
            <!-- 
Widget1 End -->

            <!-- 
Widget2 -->
            <
control type="group">
                <include>
WidgetListPosLeft</include>
                <include>
VisibleFadeEffect</include>
                <
visible>Container(9000).Hasfocus(8)</visible>                    
                
                <include>
WidgetTitleLableLeft</include>
                
                <
control type="list" id="9101">
                    <include>
WidgetItemSlideLeft</include>
                    <include>
WidgetListDimLeft</include>
                    <
onleft>9101</onleft>
                    <
onright>9101</onright>
                    <
onup condition="!Skin.HasSetting(HideRightWidget)">8101</onup>
                    <
onup condition="Skin.HasSetting(HideRightWidget)">20</onup>
                    <
ondown condition="System.HasAddon(script.globalsearch)">9000</ondown>   <!-- 608 -->
                    <
ondown condition="!System.HasAddon(script.globalsearch)">9000</ondown>   <!-- 603 -->
                    <
viewtype label="535">list</viewtype>
                    <
pagecontrol>-</pagecontrol>
                    <
scrolltime>200</scrolltime>
                    <
orientation>Horizontal</orientation>
                    <!--
focusposition>3</focusposition-->
                    <
spinposx>0</spinposx>
                    
                    <include>
WidgetItemLayoutLeft</include>                    
                    
                    <
content target="$VAR[WidgetTarget]">$VAR[Container(9000).Hasfocus(8)Left]</content>

                </
control>
                
                <include>
WidgetNavArrowsLeft</include>
                
            </
control>
            <!-- 
Widget2 End -->
            <!-- 
Widget3 --> 
and so on for all 10 Widgets.
If this would Work i would be fine with it.

but it starts alredy to fail while try to show the WidgetItemfanart if the widget got Focus.
Here The Include for the Focusfanart:

PHP Code:
<include name="FocusFanartLeft">
        <
control type="image">
            <!-- 
Fanartpreview Full-->
            <
description>FullscreenFanart</description>
            <
posx>0</posx>
            <
posy>0</posy>
            <
width>1920</width>
            <
height>1080</height>
            <
texture background="true">$INFO[Container(9101).ListItem.Art(fanart)]</texture>
            <
aspectratio>scale</aspectratio
                <
animation effect="slide" start="0,0" end="0,-47" time="0" condition="Skin.HasSetting(UseTextbasedMenu)">Conditional</animation
            <
visible>Control.HasFocus(9101)</visible>
        </
control>
        <
control type="image">
            <
posx>0</posx>
            <
posy>0</posy>
            <
width>1920</width>
            <
height>1080</height>
            <
texture background="true" colordiffuse="F7FFFFFF">overlays/Main-BG.png</texture>
            <
visible>Control.HasFocus(9101) + !IsEmpty(Container(9101).ListItem.Art(fanart))</visible>
        </
control>
<include> 

Did i maby do a mistake there and it shuld work? i didnt got any "alowhiddenfocus" in any visible in the whole code.
I think/it seems the labels and Images ($INFO[Container(9101).ListItem.Label]) remember there content. (they dont care which Widget is visible)

(Hope this wasnt to much and i could descripe the problem i face well enouth.)

Regards
Try moving <visible>Container(9000).Hasfocus(ID)</visible> to the actual lists and nest them all in the group.

If that doesn't work post (pastebin) the whole XML for us to look at.

The problem with trying to stick it all in one list is the time Kodi needs to reload the content each time as you've discovered.
VARs cannot get "slowed down", they are always updated for next frame. The problem is, as already mentioned, that lists with plugin:// need some time to update when plugin path changes. So the title is a little bit misleading Smile

btw a technically nicer way would be to assign the plugin info as listitem properties, you wouldnt need such a huge var then. (Aeon Nox 5 as a repo skin does this elegantly for example if you want to have a reference.)
AWESOM!!

@Hitcher: Exactly this did the Trick! Big GrinBig Grin ImageImage

At first i thuth i Post a reply that i gonna give it a try, and then come back to you as soon i've tested it, but as it is an easy fix i thuth i give it a try right away.

And what shuld i say?? IT WORKS!

Thanks a BUNCH!! fxxxing AWSOME!

Was so close to give up and did thuth as a last chance i try it with a Post, (not to confident)
but wtf.

THANX!
(2015-01-08, 00:29)phil65 Wrote: [ -> ]VARs cannot get "slowed down", they are always updated for next frame.
Jer, but they need there Time to update after Focus Chanche, if i can work with visible condition the whole thing is much faster. (also on Startup)

(2015-01-08, 00:29)phil65 Wrote: [ -> ]The problem is, as already mentioned, that lists with plugin:// need some time to update when plugin path changes. So the title is a little bit misleading Smile
sry. wasnt my intension, as long as i use only Settings as variable conditions i've never exploring speed issues. I just recognise this slowdown if i use Focusposition as condition as mentioned. (-) if i think again about the behaviort, its kinda logic visible is (much) faster, just got problems as how to get it to work proparly

(2015-01-08, 00:29)phil65 Wrote: [ -> ]btw a technically nicer way would be to assign the plugin info as listitem properties, you wouldnt need such a huge var then. (Aeon Nox 5 as a repo skin does this elegantly for example if you want to have a reference.)
"plugin info"? could you may give a example?
if theres a easyer (and faster) way, i would probably have a look in to Nox Code.
For the Moment im Happy i could increase the widget speed to a akzeptabel level.
If you think the nox way would bring benefits i may have a look in to it...
(Did already experimenting with propreties (but in a diffrent way as you suggest i guess (<onfocus>Set.Property(Widget.Info,3)</onfocus> and substrings in the variable).)
if you have a workin solution then keep it. plugin info should mean type/path of plugin.
and again: the variable does not update slowly, you can test that by putting it into a label at the same time and make that visible.
Another Question:

Why did i have to put the visible also in to the List? did thuth the child element inherit the visible from the parent element? (if im alowd to ask)

@phil65
Did have a quick look in to the nox code.
As far as i saw, he did it not to diffrent from one of my Attempts.

Sadly i didnt get it to work with properties. Not realy shure why. Probably i did just a beginner/basic mistake.

What i did try was; i did set the properties in the Mainmenu-Items via "<onfocus>SetProperty(Widget,3)</onfocus>" (Mainmenu is included in Home)

and for the Variables i did a Stringcompare: <value condition="StringCompare(Window(Home).Property(Widget),3) + blablub>

No Luck (Nothing showd up)

Did also try to show the Property as a label in Home with "<label>$INFO[Window(Home).Property(Widget)]</label>"

Which was empty, nomather which Mainmenuiten got focus.
I didnt say that it will solve your issue, it would just be nicer code if someone decides to only use one list control for all different main menu items.
The only reason I commented though was because I wanted to have it for the record in case someone might look this thread up again: Variables are not "slower" than infolabels. your problem is a different one (list wasnt populated yet when becoming visible)
Issue is already solved.(!) Just wanna try a different way to see how it work, which sadly faild.

Regards.
my first mate, this is a site about RMXP.


We all love it, and we understand what ya mean. Try the anti lag script


Also, I used variables before switches... I know Im weird.