Your Digital Media Has Never Looked So Good

 
juantwc
Topic Author
Posts: 15
Joined: Thu Nov 26, 2015 3:23 am

Scene Graph roScene disposal best practices

Wed Feb 08, 2017 8:40 am

Hello

I am developing an app with Scene Graph where more than one scene is shown. 

Each screen is abstracted to a controller and each controller presents its own Scene, like this example:
     
      ' Create the splash screen'
      m.screen = CreateObject("roSGScreen")
      m.port = CreateObject("roMessagePort")
      m.screen.setMessagePort(m.port)
      ' Create the component'
      m.scene = m.screen.CreateScene("splash")
      m.screen.show()


When i present another screen, i repeat the same process.

It all works fine.

What i notice though is that when i debug with
sgnodes all



It will tell me that previous Scenes are still there. I am worried this is a memory issue.

I tried removing each Scene individually with scene.Close() before presenting a new one but i get the error


BRIGHTSCRIPT: ERROR: roSGScreen: create screen interrupted.: pkg:/source/controllers/....


What is the best way to remove all nodes in a Scene before presenting a new one?

Thanks,
 
EnTerr
** Valued Community Member **
Posts: 3834
Joined: Sun Jan 02, 2011 2:41 am

Re: Scene Graph roScene disposal best practices

Wed Feb 08, 2017 10:35 am

I am not sure creating >1 scene is a good idea in RSG. I'd feel better if i see scene transitions API (i.e. how to replace one scene with another, animations etc) - but i dont find that.

What is the reason to wish for >1 scene? Why not just use multiple "subscenes" (ok, so just a Group nodes) under a "One Scene to Rule them All"? https://sdkdocs.roku.com/display/sdkdoc/Scene as such has rather un-interesting features.
Last edited by EnTerr on Wed Feb 08, 2017 2:02 pm, edited 1 time in total.
 
Veeta
Posts: 149
Joined: Tue Aug 12, 2014 4:44 am
Location: http://www.veeta.tv
Contact:

Re: Scene Graph roScene disposal best practices

Wed Feb 08, 2017 12:25 pm

I agree with EnTerr.  All of my SG channels have one "Controller" node extending Scene.  It's lifespan is the duration of the app.  It creates and destroys "Screens" which extend "Group"
 
juantwc
Topic Author
Posts: 15
Joined: Thu Nov 26, 2015 3:23 am

Re: Scene Graph roScene disposal best practices

Mon Feb 13, 2017 1:22 am

Thanks for your replies. 

I had one Scene per controller only because it seems more organised. I come from a developer background in iOS and i guess i was trying to have a paradigm similar to each view controller having a view that gets shown/dismissed.

I understand from your replies this is the wrong approach, and i had suspected as much. Thank you for confirming.

So usually you just create one scene and remove nodes manually before inserting others. Can you share some sample code? 

Thanks again. 
 
EnTerr
** Valued Community Member **
Posts: 3834
Joined: Sun Jan 02, 2011 2:41 am

Re: Scene Graph roScene disposal best practices

Mon Feb 13, 2017 12:34 pm

juantwc wrote:
I understand from your replies this is the wrong approach, and i had suspected as much. Thank you for confirming.

So usually you just create one scene and remove nodes manually before inserting others. Can you share some sample code?

I don't know for a fact that multiple scenes are the wrong approach - just suspicion. If i learn more, i'll let you know.

I imagine you can also hide/unhide whole Group trees - whether usable would depend on the real life performance though
 
EnTerr
** Valued Community Member **
Posts: 3834
Joined: Sun Jan 02, 2011 2:41 am

Re: Scene Graph roScene disposal best practices

Wed Feb 15, 2017 12:47 am

I got a chance to ask someone privy to RSG's mysteries and here is what i heard back:
Scenography Swami wrote:
Our recommended usage pattern is to create one RoSGScreen and one Scene node for a channel. You can treat the child nodes of the Scene (or one of its children) as different “views” and add transitions between them (e.g. crossfades, slides, etc.). This provides the same functionality as multiple Scene’s, just a different implementation.

I don’t think there is anything to prevent you from using multiple RoSGScreen’s but setting things up that way might fail to take advantage of future improvements to channel launching transitions, etc.
 
juantwc
Topic Author
Posts: 15
Joined: Thu Nov 26, 2015 3:23 am

Re: Scene Graph roScene disposal best practices

Wed Feb 15, 2017 5:21 am

Thanks man, you are doing God's work  :) 

Would be cool to see something like this in the SDK documentation (wink wink if anybody out there has the right connections) 
 
EnTerr
** Valued Community Member **
Posts: 3834
Joined: Sun Jan 02, 2011 2:41 am

Re: Scene Graph roScene disposal best practices

Sat Feb 18, 2017 10:46 am

RokuDanny can has   8)

Who is online

Users browsing this forum: No registered users and 6 guests