SageTV Community  

Go Back   SageTV Community > SageTV Development and Customizations > SageTV Studio
Forum Rules FAQs Community Downloads Today's Posts Search

Notices

SageTV Studio Discussion related to the SageTV Studio application produced by SageTV. Questions, issues, problems, suggestions, etc. relating to the Studio software application should be posted here.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 06-22-2009, 06:48 PM
razrsharpe razrsharpe is offline
Sage Icon
 
Join Date: Sep 2008
Location: Boston, MA
Posts: 2,111
Studio Execution Logic

So I was helping plucky debug some code for v3 of his movie wall. We were primarily trying to make things faster. And i came across a piece of code that looks like it should only be executing once; however, it was executing multiple times (and obviously making things much slower). To help see what was happening I made a little test stv to show you guys. I want to know if this is normal? How to avoid this in structuring your code? etc. From what i have observed i think the issue lies in performing logic as children of panel widgets.

Both tests involve logic that is A = A + 1. Then i display the result of A 4 times.

Test 1 - A is displayed in a child panel that is a child of A = A + 1

Test 2 - A is displayed as a direct child of A = A + 1

I would think that A should equal 1 for both tests. However for test 1 it executes the code twice, and for test 2 it executes the code a total of 8 times (twice for each display of A).

I probably explained that terribly so take a look at the attached jpgs and/or the stv containing this code and let me know your thoughts. Also take a look at the cmd window.. i displayed A there while it was executing to see what was going on.

Thanks

PS - to fix the original issue that plucky and I were trying to diagnose in SMW we ended up moving all the logic (in this case a loop through your entire video collection) into BeforeMenuLoad. Everything worked much faster after
Attached Images
File Type: jpg Studio Test 1.jpg (172.7 KB, 272 views)
File Type: jpg Studio Test 2.jpg (157.6 KB, 258 views)
Attached Files
File Type: stv Studio_Tests.stv (3.8 KB, 230 views)
__________________
Server 2003 r2 32bit, SageTV9 (finally!)
2x Dual HDHR (OTA), 1x HD-PVR (Comcast), 1x HDHR-3CC via SageDCT (Comcast)
2x HD300, 1x SageClient (Win10 Test/Development)
Check out TVExplorer

Last edited by razrsharpe; 06-22-2009 at 06:51 PM.
Reply With Quote
  #2  
Old 06-22-2009, 07:05 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
Laying out and rendering the UI is a multi-pass process, and widgets in a blue UI chain get evaluated on every pass. Think of this blue code as like the menu's Draw or HitTest method that gets called at the drop of a hat whenever Sage needs to know something about how the menu lays out.

So if you have something that's expensive to compute, or has side effects that you don't want to happen more than once, it's best to put that sort of code into green process chains wherever possible, since those chains get evaluated just once per click or hook event.
__________________
-- Greg
Reply With Quote
  #3  
Old 06-22-2009, 07:12 PM
razrsharpe razrsharpe is offline
Sage Icon
 
Join Date: Sep 2008
Location: Boston, MA
Posts: 2,111
ahhhhhhhh... i figured it was something like that. Thanks for explaining it so clearly ... Is there a means of saying i want this code to be "green"? According to the studio docs (page 16) it says that it needs to a child of a hook, listener, or user selection of a UI element... so it would appear that i cant just say "make this code green"

anyway, thanks for clarifying that bit of confusion and responding so fast
__________________
Server 2003 r2 32bit, SageTV9 (finally!)
2x Dual HDHR (OTA), 1x HD-PVR (Comcast), 1x HDHR-3CC via SageDCT (Comcast)
2x HD300, 1x SageClient (Win10 Test/Development)
Check out TVExplorer
Reply With Quote
  #4  
Old 06-22-2009, 10:08 PM
Opus4's Avatar
Opus4 Opus4 is offline
Administrator
 
Join Date: Sep 2003
Location: NJ
Posts: 19,624
Quote:
Originally Posted by razrsharpe View Post
Is there a means of saying i want this code to be "green"? According to the studio docs (page 16) it says that it needs to a child of a hook, listener, or user selection of a UI element... so it would appear that i cant just say "make this code green"
The full description for a process action chain says:
Quote:
Originally Posted by Studio PDF Manual, p. 17 in v6.5-A
Process (green indicator) – Process action chains consist of widgets used only for
code execution purposes; they do not lead directly to widgets that display a UI
element, except for Shapes, Menus, and OptionsMenus. A Process action chain
may be executed as a result of a hook, listener or a user selection of a UI element.
You don't mark a section of code as 'green'/Process action chain; it qualifies for that category according to the rules of coding in Studio. As Greg said, you could make your code run as part of the BeforeMenuLoad hook. Then, if it needs to be updated because of user input, a timer, etc., you would use a reference to that process chain to execute the code & update your data. Refreshing all or part of the screen afterwards accomplishes updating the display with the updated data.

- Andy
__________________
SageTV Open Source v9 is available.
- Read the SageTV FAQ. Older PDF User's Guides mostly still apply: SageTV V7.0 & SageTV Studio v7.1.
- Hauppauge remote help: 1) Basics/Extending it 2) Replace it 3) Use it w/o needing focus
- HD Extenders: A) FAQs B) URC MX-700 remote setup
Note: This is a users' forum; see the Rules. For official tech support fill out a Support Request.
Reply With Quote
  #5  
Old 06-23-2009, 06:01 AM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
Razor,

Thanks for asking I figured that was the response but I am glad it is confirmed. There are lots placed you can put the code "to make it green" I think we did it best in before menuload. Greg and Andy thanks for the great explanation it is clear to me now.

Got an additional question is there a way to force beforemenuload to calculate again say after a property has changed that affects it. I currently just point to the menu widget again to reload the menu but was wondering if there was another way
Reply With Quote
  #6  
Old 06-23-2009, 06:57 AM
razrsharpe razrsharpe is offline
Sage Icon
 
Join Date: Sep 2008
Location: Boston, MA
Posts: 2,111
Andy, thanks for the additional info... that makes sense now i think i know what i want/need to do now.

Quote:
Originally Posted by PLUCKYHD View Post
Got an additional question is there a way to force beforemenuload to calculate again say after a property has changed that affects it. I currently just point to the menu widget again to reload the menu but was wondering if there was another way
Andy answered that above (if i understand him)... you put a reference to the chain of code in BeforeMenuLoad that updates the data when you want to update the data (ie after the property is updated)... then (also after the property is updated) you refresh the UI elements with RefreshArea() (or something similar).
__________________
Server 2003 r2 32bit, SageTV9 (finally!)
2x Dual HDHR (OTA), 1x HD-PVR (Comcast), 1x HDHR-3CC via SageDCT (Comcast)
2x HD300, 1x SageClient (Win10 Test/Development)
Check out TVExplorer
Reply With Quote
  #7  
Old 06-23-2009, 07:56 AM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
That he did answer to early in the morning I think I will leave mine reloading the menu as that way I don't forgot to refresh an area by mistake.
Reply With Quote
  #8  
Old 06-23-2009, 08:00 AM
razrsharpe razrsharpe is offline
Sage Icon
 
Join Date: Sep 2008
Location: Boston, MA
Posts: 2,111
Quote:
Originally Posted by PLUCKYHD View Post
I think I will leave mine reloading the menu as that way I don't forgot to refresh an area by mistake.
the only downside to that that i see that you will recalculate EVERYTHING.. .and that may needlessly slow things down if you only need to update a small subset of the data.
__________________
Server 2003 r2 32bit, SageTV9 (finally!)
2x Dual HDHR (OTA), 1x HD-PVR (Comcast), 1x HDHR-3CC via SageDCT (Comcast)
2x HD300, 1x SageClient (Win10 Test/Development)
Check out TVExplorer
Reply With Quote
  #9  
Old 06-23-2009, 08:02 AM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
Doesn't seem to slow anything down as I clear the menucache as well.
Reply With Quote
  #10  
Old 06-23-2009, 08:05 AM
razrsharpe razrsharpe is offline
Sage Icon
 
Join Date: Sep 2008
Location: Boston, MA
Posts: 2,111
sounds like youre all set then
__________________
Server 2003 r2 32bit, SageTV9 (finally!)
2x Dual HDHR (OTA), 1x HD-PVR (Comcast), 1x HDHR-3CC via SageDCT (Comcast)
2x HD300, 1x SageClient (Win10 Test/Development)
Check out TVExplorer
Reply With Quote
  #11  
Old 06-23-2009, 02:12 PM
Opus4's Avatar
Opus4 Opus4 is offline
Administrator
 
Join Date: Sep 2003
Location: NJ
Posts: 19,624
Quote:
Originally Posted by PLUCKYHD View Post
Doesn't seem to slow anything down as I clear the menucache as well.
Hold on... you are clearing the menu cache every time something on your menu changes? You aren't talking about an import to be released for use by others, are you? If so, you are going to kill all cached menus that the user has been to, causing everything to load more slowly after use of your menu. ClearMenuCache() is not intended to be used as a way to refresh your current menu, so please don't use it that way. You should be coding your menu to properly refresh only its own data so you won't be affecting other people's STV work and reducing the responsiveness of the SageTV UI as te user jumps from menu to menu.

- Andy
__________________
SageTV Open Source v9 is available.
- Read the SageTV FAQ. Older PDF User's Guides mostly still apply: SageTV V7.0 & SageTV Studio v7.1.
- Hauppauge remote help: 1) Basics/Extending it 2) Replace it 3) Use it w/o needing focus
- HD Extenders: A) FAQs B) URC MX-700 remote setup
Note: This is a users' forum; see the Rules. For official tech support fill out a Support Request.
Reply With Quote
  #12  
Old 06-23-2009, 02:17 PM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
Andy,

No I posted that wrong I am only using that in one part (the cache gets to full if I don't)

I have recoded today all to reference the necessary section in beforemenuload and refresh after to much better success.
Reply With Quote
  #13  
Old 06-23-2009, 03:06 PM
Opus4's Avatar
Opus4 Opus4 is offline
Administrator
 
Join Date: Sep 2003
Location: NJ
Posts: 19,624
Quote:
Originally Posted by PLUCKYHD View Post
No I posted that wrong I am only using that in one part (the cache gets to full if I don't)
I would be curious why it needs to clear the menu cache. Clearing all the menu cache shouldn't be something that needs to be used very often.

Quote:
I have recoded today all to reference the necessary section in beforemenuload and refresh after to much better success.
Great.

- Andy
__________________
SageTV Open Source v9 is available.
- Read the SageTV FAQ. Older PDF User's Guides mostly still apply: SageTV V7.0 & SageTV Studio v7.1.
- Hauppauge remote help: 1) Basics/Extending it 2) Replace it 3) Use it w/o needing focus
- HD Extenders: A) FAQs B) URC MX-700 remote setup
Note: This is a users' forum; see the Rules. For official tech support fill out a Support Request.
Reply With Quote
  #14  
Old 06-23-2009, 03:40 PM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
Quote:
Originally Posted by Opus4 View Post
I would be curious why it needs to clear the menu cache. Clearing all the menu cache shouldn't be something that needs to be used very often.

- Andy
I think I just overloaded the ui so much when changing a major ui setting it seems to be the only way to speed it up, but that was before I recoded and put/moved allot of it to BeforeMenuLoad. I can probably get rid of it now without much problems. I only had/have it in one spot but I will try and get rid of it there as well didn't realize it cleared so much.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
6.1.x tuner use logic sleonard SageTV Beta Test Software 2 03-26-2007 12:48 PM
Program Guide logic, FireFly remote ? davefred99 SageTV Software 3 05-02-2006 08:01 PM
Live TV while recording scheduled show logic julesjohn SageTV Software 5 01-09-2005 11:13 AM
Cancellation logic? corykim SageTV EPG Service 1 05-01-2003 08:06 AM


All times are GMT -6. The time now is 06:09 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, vBulletin Solutions Inc.
Copyright 2003-2005 SageTV, LLC. All rights reserved.