Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
neowinston
Visitor

How do I call XML code from Brightscript for a Roku Channel?

I'm trying to populate a Label List using the below XML Roku Channel, Scenegraph code. I'm getting these errors: 
BRIGHTSCRIPT: ERROR: roSGScreen: creating MAIN|TASK-only component failed on RENDER thread: pkg:/components/screens/DetailsScreen/DetailsScreen.brs(101)
BRIGHTSCRIPT: ERROR: roMessagePort: Trying to construct a message port on a non-plugin thread: pkg:/components/screens/DetailsScreen/DetailsScreen.brs(102)

Full error message:


BRIGHTSCRIPT: ERROR: roSGScreen: creating MAIN|TASK-only component failed on RENDER thread: pkg:/components/screens/DetailsScreen/DetailsScreen.brs(101)
BRIGHTSCRIPT: ERROR: roMessagePort: Trying to construct a message port on a non-plugin thread: pkg:/components/screens/DetailsScreen/DetailsScreen.brs(102)

BrightScript Micro Debugger.
Enter any BrightScript statement, debug commands, or HELP.

Suspending threads...
Thread selected:  1*   ...ailsScreen/DetailsScreen.brs(103)    screen.setMessagePort(m.port)

Current Function:
100:  sub showChannelSGScreen()
101:    screen = CreateObject("roSGScreen")
102:    m.port = CreateObject("roMessagePort")
103:*   screen.setMessagePort(m.port)
104:    scene = screen.CreateScene("LabelListExample")
105:    screen.show()
106:  
107:    while(true)
'Dot' Operator attempted with invalid BrightScript Component or interface reference. (runtime error &hec) in pkg:/components/screens/DetailsScreen/DetailsScreen.brs(103)
103:   screen.setMessagePort(m.port)
Backtrace:
#1  Function showchannelsgscreen() As Void
  file/line: pkg:/components/screens/DetailsScreen/DetailsScreen.brs(103)
#0  Function onitemselected() As Void
  file/line: pkg:/components/screens/DetailsScreen/DetailsScreen.brs(95)
Local Variables:
global           Interface:ifGlobal
m                roAssociativeArray refcnt=3 count:7
screen           Invalid
scene            <uninitialized>
msg              <uninitialized>
msgtype          <uninitialized>
Threads:
ID    Location                                Source Code
0    pkg:/source/main.brs(20)                msg = wait(0, port)
1*   ...ailsScreen/DetailsScreen.brs(103)    screen.setMessagePort(m.port)
 *selected

Brightscript Debugger>
Thread detached
>>> Details >> OnkeyEvent

Thread detached
0 Kudos
2 REPLIES 2
Tyler_Smith
Binge Watcher

Re: How do I call XML code from Brightscript for a Roku Channel?

http requests cannot be performed on the render thread.
Take a look at https://sdkdocs.roku.com/display/sdkdoc/Task which defines the process in RSG.
Tyler Smith
0 Kudos
neowinston
Visitor

Re: How do I call XML code from Brightscript for a Roku Channel?

Hello Tyler,

Thanks for your answer and of the link!

For me it's not very clear how I call the Task from BrightScript. Would you please give me an example? Thank you!

I'm trying to invoke the task in a BrightSprit file like so (from this link: https://sdkdocs.roku.com/display/sdkdoc ... er+Content😞

m.getHomeOptionsList = createObject("roSGNode", "getLabelListContent")
m.getHomeOptionsList.setField("uri", "http://www.sdktestinglab.com/homeoptionslistcontent.xml")
m.getHomeOptionsList.observeField("content", "showhomeoptionslist")
m.getHomeOptionsList.functionName = "showhomeoptionslist"
m.getHomeOptionsList.control = "RUN"
0 Kudos