tar
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2016
08:57 AM
Scene Graph, m.global and function references
Hello everyone,
Is there any way to store roAssociativeArray with function references using Scene Graph API and m.global node?
In my tests all function references become "invalid" when added to m.global (or any other node) by using addFields function (I guess it is by design,because function is not a field and it is silently ignored).
But a good part of my codebase is relies on that.
When I was using previous Roku API, I was able to do things like this:
aa debugger output:
m.global.testaa debugger output:
Previously it was stored in Main.brs, and accessed using GetGlobalAA() with no issues with function references.
Is there any other global storage available? Or can I still use GetGlobalAA() from a Task node somehow?
Is there any way to store roAssociativeArray with function references using Scene Graph API and m.global node?
In my tests all function references become "invalid" when added to m.global (or any other node) by using addFields function (I guess it is by design,because function is not a field and it is silently ignored).
But a good part of my codebase is relies on that.
When I was using previous Roku API, I was able to do things like this:
Function GetAAWithFunctionReferences() as object
aa = {
test1: test1, ' function reference
string1: "test string 1"
}
return aa
End Function
Function test1()
print m.string1
End Function
aa debugger output:
aa = GetAAWithFunctionReferences()
print aa
<Component: roAssociativeArray> =
{
string1: test string 1
test1: <Function: test1>
}
m.global.testaa debugger output:
m.global.addFields({testaa: aa})
print m.global.testaa
<Component: roAssociativeArray> =
{
string1: test string 1
test1: invalid
}
Previously it was stored in Main.brs, and accessed using GetGlobalAA() with no issues with function references.
Is there any other global storage available? Or can I still use GetGlobalAA() from a Task node somehow?
7 REPLIES 7
tar
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2016
05:10 AM
Re: Scene Graph, m.global and function references
I think I've figured it out.
I am storing my objects with functions (managers) in GetGlobalAA() like this:
But I still need to remember that every thread has it's own globalAA: Main.brs thread, Scene Graph thread, and each Task node threads should have their own "managers", and synchronizing a data between threads is tricky sometimes.
I am storing my objects with functions (managers) in GetGlobalAA() like this:
' In a task node script
globalAA = GetGlobalAA()
myManager = GetAAWithFunctionReferences()
globalAA.testAA = myManager 'it was not obvious that I could just set objects this way
But I still need to remember that every thread has it's own globalAA: Main.brs thread, Scene Graph thread, and each Task node threads should have their own "managers", and synchronizing a data between threads is tricky sometimes.
tar
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2016
09:24 AM
Re: Scene Graph, m.global and function references
I am still need a way to store functions in node objects.
Example: I have my shows objects (roAssociativeArrays), and each object contains 6 functions.
But when I set those fields to the ContentNode - all functions are become invalid.
Is there any reason for this? I want to avoid major refactoring in my app.
How can I share function references between objects in Scene Graph?
Example: I have my shows objects (roAssociativeArrays), and each object contains 6 functions.
But when I set those fields to the ContentNode - all functions are become invalid.
Is there any reason for this? I want to avoid major refactoring in my app.
How can I share function references between objects in Scene Graph?
tar
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2016
09:32 AM
Re: Scene Graph, m.global and function references
Or how can I just pass a plain roAssociativeArray object from a TaskNode to my screen (roSGNode)?
"accosarray" interface field does not work, as it cuts out all unsupported types.
"accosarray" interface field does not work, as it cuts out all unsupported types.
EnTerr
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2016
10:18 AM
Re: Scene Graph, m.global and function references
You can't. Anything that SG does not recognize is stripped, that's mentioned in somewhere in TFM. SG does not recognize "function" types.
Because umm... it rejects BrightScript? I don't know. What should have been implemented, isn't.
Because umm... it rejects BrightScript? I don't know. What should have been implemented, isn't.
tar
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2016
05:01 PM
Re: Scene Graph, m.global and function references
EnTerr, thanks for the reply, I appreciate your attention and help.
I've re-read docs for a TaskNode https://sdkdocs.roku.com/display/sdkdoc/Task and SG treads https://sdkdocs.roku.com/display/sdkdoc ... ph+Threads
and it brought up some light to the topic again.
And all I need now is to save a TaskNode "m" state between runs.
For some reason all data added in a task node function does not appear in "m" for the next run.
Docs mention that I can have a state from init() between runs
And that's true, it works.
But I want my loaded data, and it is not being saved for unknown reason.
Am I missing something here or any data which is obtained in a task node is lost forever with no chance to capture it after converting to ContentNodes?
I've re-read docs for a TaskNode https://sdkdocs.roku.com/display/sdkdoc/Task and SG treads https://sdkdocs.roku.com/display/sdkdoc ... ph+Threads
and it brought up some light to the topic again.
And all I need now is to save a TaskNode "m" state between runs.
For some reason all data added in a task node function does not appear in "m" for the next run.
Docs mention that I can have a state from init() between runs
This means that previously, in firmware version 7.1, only the render thread m had state from init(). In firmware version 7.2, both the render thread m and the Task node thread m have state from init().
And that's true, it works.
But I want my loaded data, and it is not being saved for unknown reason.
Am I missing something here or any data which is obtained in a task node is lost forever with no chance to capture it after converting to ContentNodes?
tar
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2016
04:50 PM
Re: Scene Graph, m.global and function references
I've realized there is no way to do what I want. So I had to make a big refactoring.
Upgrading apps to the Roku Scene Graph SDK is a pain and needs really advanced skills.
However, code becomes a bit cleaner in the end.
Upgrading apps to the Roku Scene Graph SDK is a pain and needs really advanced skills.
However, code becomes a bit cleaner in the end.
asrikanth1990
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2018
10:20 PM
Re: Scene Graph, m.global and function references
Hi Tar
I am facing similar situation here, Can you please shed some light on how you solved this.
I am facing similar situation here, Can you please shed some light on how you solved this.