Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
btpoole
Level 7

Execution TimeOut in a task

Execution TimeOut in a task. I thought a task was not suppose to timeout? I am running a task doing a JSON parse of approx 1300 items. The task throws an Execution timeout error. 

Debugger; 
Current Function:
026:  function upDateGrid()
027:  i=0
028:  ?"in UpDateGrid"
029:  m.showcontent=createobject("roSGNode", "ContentNode")
030:  for each items in m.roProgramlist.items
031:    for each show in items.show
032:  if show.start >= m.currentTime and m.currentTime <= show.end
033:  i=i+1
034:* ?i
035:  dataitem=m.showcontent.Createchild("ContentNode")
036:  dataitem.addfields({"title" : show.title})
037:  dataitem.addfields({"desc" : show.dec})
038:  else
Execution timeout (runtime error &h23) in pkg:/components/Task/task_gridcontent.xml(34)
034: ?i

The exact same function runs correctly in the main.brs on start up but when called to do an update of content for the grid, I get the error. Roku 2 2720X 7.6.0 build 4120-06.
0 Kudos
13 Replies
Roku Employee
Roku Employee

Re: Execution TimeOut in a task

(cleave to a new thread)
I too don't think it should be happening in Task. Can you give a "minimal code example" so i can reproduce and present to the timeout power-that-be?
0 Kudos
btpoole
Level 7

Re: Execution TimeOut in a task

task_gridcontent.xml

<?xml version="1.0" encoding="utf-8" ?>
<!--********** Copyright 2016 Roku Corp.  All Rights Reserved. **********-->
<component name = "resetgrid" extends = "Task" >
  <interface>
    <field id = "ProgramContent" type = "node" />
      </interface>

 <script type="text/brightscript" uri="pkg:/source/main.brs" />
 <script type="text/brightscript" uri="pkg:/components/home/setupcontent.brs" />
 <script type="text/brightscript" uri="pkg:/components/home/content.brs" />
<script type="text/brightscript" uri="pkg:/components/timeutility/timeutility.brs" />
<script type="text/brightscript" uri="pkg:/components/setup_variable.brs" />
  <script type = "text/brightscript" >
    <![CDATA[

    sub init()
PRINT "IN resetgrid  TASK"
m.currentTime=getCurrentTime()  'CURRENT TIME IN SECONDS
upDateGrid()
end sub


function upDateGrid()
i=0
?"in UpDateGrid"
m.showcontent=createobject("roSGNode", "ContentNode")
for each items in m.roProgramlist.items
  for each show in items.show
if show.start >= m.currentTime and m.currentTime <= show.end
i=i+1
?i
dataitem=m.showcontent.Createchild("ContentNode")
dataitem.addfields({"title" : show.title})
dataitem.addfields({"desc" : show.dec})
else
end if
end for
end for
m.top.ProgramContent=m.showcontent
end function
]]>
  </script>
</component>



Function that calls task
sub resetgrid()
m.spinner.control="start"
m.spinner.visible=true[/font][/size]
m.updateGrid = createObject("RoSGNode","resetgrid")
m.updateGrid.ObserveField("state", "resetcontent")
m.updateGrid.control = "RUN"
end sub

function resetcontent()
if m.updateGrid.state = "stop"
setcolumnWidth()
m.programmarkupgrid.content= m.updateGrid.ProgramContent
m.spinner.control= "stop"
m.spinner.visible=false
m.spinnerlabel.visible=false
m.ProgramMarkupGrid.visible=true
m.programmarkupgrid.SetFocus(true)
else
end if
end function

Here is the task, the calling function and the callback. The debugger shows the execution error occurs in the task, but not always on the same line of the task.
0 Kudos
btpoole
Level 7

Re: Execution TimeOut in a task

"btpoole" wrote:
task_gridcontent.xml

<?xml version="1.0" encoding="utf-8" ?>
<!--********** Copyright 2016 Roku Corp.  All Rights Reserved. **********-->
<component name = "resetgrid" extends = "Task" >
  <interface>
    <field id = "ProgramContent" type = "node" />
      </interface>

 <script type="text/brightscript" uri="pkg:/source/main.brs" />
 <script type="text/brightscript" uri="pkg:/components/home/setupcontent.brs" />
 <script type="text/brightscript" uri="pkg:/components/home/content.brs" />
<script type="text/brightscript" uri="pkg:/components/timeutility/timeutility.brs" />
<script type="text/brightscript" uri="pkg:/components/setup_variable.brs" />
  <script type = "text/brightscript" >
    <![CDATA[

    sub init()
PRINT "IN resetgrid  TASK"
m.currentTime=getCurrentTime()  'CURRENT TIME IN SECONDS
upDateGrid()
end sub


function upDateGrid()
i=0
?"in UpDateGrid"
m.showcontent=createobject("roSGNode", "ContentNode")
for each items in m.roProgramlist.items
  for each show in items.show
if show.start >= m.currentTime and m.currentTime <= show.end
i=i+1
?i
dataitem=m.showcontent.Createchild("ContentNode")
dataitem.addfields({"title" : show.title})
dataitem.addfields({"desc" : show.dec})
else
end if
end for
end for
m.top.ProgramContent=m.showcontent
end function
]]>
  </script>
</component>



Function that calls task
sub resetgrid()
m.spinner.control="start"
m.spinner.visible=true[/font][/size]
m.updateGrid = createObject("RoSGNode","resetgrid")
m.updateGrid.ObserveField("state", "resetcontent")
m.updateGrid.control = "RUN"
end sub

function resetcontent()
if m.updateGrid.state = "stop"
setcolumnWidth()
m.programmarkupgrid.content= m.updateGrid.ProgramContent
m.spinner.control= "stop"
m.spinner.visible=false
m.spinnerlabel.visible=false
m.ProgramMarkupGrid.visible=true
m.programmarkupgrid.SetFocus(true)
else
end if
end function

Here is the task, the calling function and the callback. The debugger shows the execution error occurs in the task, but not always on the same line of the task.

SOLVED: In place of addfields just using for example dataitem.title =  show.title seems to eliminate the error.
0 Kudos
destruk
Level 10

Re: Execution TimeOut in a task

So you're saying when you try to "addfields" a field name that already exists, like Title, times out the task, but when you simply assign a value to an existing field it doesn't?
0 Kudos
btpoole
Level 7

Re: Execution TimeOut in a task

"destruk" wrote:
So you're saying when you try to "addfields" a field name that already exists, like Title, times out the task, but when you simply assign a value to an existing field it doesn't?

Yes, that's seems to be the case. I had been using addfields previously but the error started. After many hours of changing things around I hit upon just setting the field and the error stopped and code produced expected response. I ran into this in other areas as well.
0 Kudos
btpoole
Level 7

Re: Execution TimeOut in a task

"btpoole" wrote:
"destruk" wrote:
So you're saying when you try to "addfields" a field name that already exists, like Title, times out the task, but when you simply assign a value to an existing field it doesn't?

Yes, that's seems to be the case. I had been using addfields previously but the error started. After many hours of changing things around I hit upon just setting the field and the error stopped and code produced expected response. I ran into this in other areas as well.

Update: I can run the urltransfer and assign to array from the main.brs no problem. I put the function in a task and run from the main.brs or any other brs file and it gives execution timeout.
0 Kudos
btpoole
Level 7

Re: Execution TimeOut in a task

I am pretty much at a loss when it comes to execution timeout. After reading everything I can find on the subject, nothing works. I have a roUrlTransfer that takes place in the main.brs. All good works perfect. Later in the process I have a timer setup that fires approx 1 hour interval. Once fired, the code is suppose to execute a rourlTransfer to update some info. Well I have tried it several ways. First I tried to put the urlTransfer in a task and run it but I get the execution timeout. I then called the original function from the main in the task. The function is entered and starts doing its thing but then execution timeout. The really odd thing is I can download a contentfile, store it to a global then execute the timer and task on the full file performing a parse and it works. Because of the execution timeouts, I restructured the code taking all the parsing and heavy lifting out of the Roku and placed it on my server, so the Roku only has to make a call to the server, download the file (350 kb), then run thru a simple for loop to create a content node. It still craps out. I haven't tried it on other models, but the Roku 2 refuses. Below is how I currently have it set. Any ideas on fixing it.

setcontent.brs


sub resetgrid()
[size=100]m.updateGrid = createObject("RoSGNode","updatecontent")[/size]
m.updateGrid.ObserveField("state", "resetcontent")
m.updateGrid.control = "RUN"
[size=100]end sub[/size]



updatecontent.xml

<?xml version="1.0" encoding="utf-8" ?>
<!--********** Copyright 2016 Roku Corp.  All Rights Reserved. **********-->
<component name = "updatecontent" extends = "Task" >
  <interface>
[size=100]<field id = "FileContent" type = "node" />[/size]
[size=100]   </interface>[/size]
 [size=100] <script type="text/brightscript">[/size]

    <![CDATA[

    sub init()
PRINT "IN updatecontent  TASK"
contentTransfer()
end sub

function contentTransfer()
url="http:/xxxxx.xx.xxx:xxxx/contentfile.php"
rocurl = createObject("roUrlTransfer")
roport=CreateObject("roMessagePort")
rocurl.setUrl(url)
m.top.FileContent=[size=85][font=monospace]rocurl.GetToString()[/font][/size]
[size=100]]]>[/size]

  </script>

</component>
0 Kudos
destruk
Level 10

Re: Execution TimeOut in a task

You might need to drop the Roku2 - Roku3s and Roku4s don't behave this way.
0 Kudos
btpoole
Level 7

Re: Execution TimeOut in a task

"destruk" wrote:
You might need to drop the Roku2 - Roku3s and Roku4s don't behave this way.

I believe you may be correct. I think I will test on Roku3.  I was actually trying to get it to work on the 2 hoping that if it ran on it, it would run on anything newer.
0 Kudos