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: 
BCVatOVG
Visitor

EPC Bug with Scene Graph ProgressDialog

I have an application that does cross promotion to other applications that I built.  In the load of my app I present a ProgressDialog box on the top root Scene Graph Scene. When the loading finishes, I close the ProgressDialog.

At another point it replaces the loading dialogue with another basic simple Dialog. At this point, I can no longer send EPC launch commands.  I get a HTTP/1.1 503 Service Unavailable.  Setting the top dialog to invalid does not seem to help.  I have pasted the code, as well as attached a sample application that you can load and test. 

sub init()
m.top.SetFocus(true)
showDialog()
End sub


sub showDialog()

' create a loading dialog while we retrieve the video info
m.ProgressDialog = CreateObject("roSGNode", "ProgressDialog")

m.Dialog = CreateObject("roSGNode", "Dialog")

m.top.dialog = m.ProgressDialog

' If I run an EPC launch command here while ProgressDialog is spinning, Roku returns 503 which MAY be acceptable.
'curl -is -d '' 'http://192.168.6.110:8060/launch/93259'
'HTTP/1.1 503 Service Unavailable
'Server: Roku UPnP/1.0 MiniUPnPd/1.4
'Content-Length: 0


m.top.dialog.close = true
' Doesn't matter if I set it to invalid or not
m.top.dialog.close = invalid


' If I comment out the rest of the program
' and run an EPC launch command here, Roku does expected, returns 200 and launches the channel
'curl -is -d '' 'http://192.168.6.110:8060/launch/93259'
'HTTP/1.1 200 OK
'Server: Roku UPnP/1.0 MiniUPnPd/1.4
'Content-Length: 0

' If I replace the ProgressDialog with a simple Dialog, any launch EPC command fails 
m.top.dialog = m.Dialog
m.top.dialog.title = "EPC doesn't work after a ProgressDialog"

m.top.dialog.close = true
m.top.dialog = invalid

'curl -is -d '' 'http://192.168.6.110:8060/launch/93259'
'HTTP/1.1 503 Service Unavailable
'Server: Roku UPnP/1.0 MiniUPnPd/1.4
'Content-Length: 0

end sub


Download the sample package here: https://drive.google.com/file/d/0B4NsUtyQ2cAoT2dnaU1TZWhCY1E/view?usp=sharing

Please let me know 1) what I am doing wrong or 2) if you have any further questions.

Thanks,
Blake
0 Kudos
6 REPLIES 6
BCVatOVG
Visitor

Re: EPC Bug with Scene Graph ProgressDialog

No one has any input on this?  Can anyone replicate and confirm the bug?

Thanks,
Blake
0 Kudos
belltown
Roku Guru

Re: EPC Bug with Scene Graph ProgressDialog

Your code as written doesn't make any sense to me. In both cases, you're closing the dialog immediately after creating it. And what's an EPC?
0 Kudos
BCVatOVG
Visitor

Re: EPC Bug with Scene Graph ProgressDialog

That is a typo.  It should be an ECP (External Control Protocol) https://sdkdocs.roku.com/display/sdkdoc/External+Control+Guide

I am trying to launch another channel from within my channel.

The fact that the dialogue is closed immediately doesn't matter. Obviously in my real application, I am waiting on a task node to complete before closing the dialog, but for this test channel, it closes it right away.

The point I am trying to make is that when you curl the ECP command after replacing the ProgressDialog with a simple Dialog, any launch EPC command fails with 503 Service Unavailable.
0 Kudos
belltown
Roku Guru

Re: EPC Bug with Scene Graph ProgressDialog

I think I see what you're trying to do now. I didn't get it the first time I looked at your sample code because it didn't do anything.

I wrote my own code that I think does what you're trying to do, and get the same result: An ECP command fails with HTTP error code 503 (Service Unavailable) when attempted after a progress dialog has been dismissed and replaced by a normal dialog. I tried a few workarounds to no avail. It looks like a bug to me.

Here's my code:

MainScene.xml
<?xml version="1.0" encoding="UTF-8"?>

<component name="MainScene" extends="Scene">
    <script type="text/brightscript" uri="pkg:/components/MainScene.brs" />
    <children>
        <Timer id="timer" duration="5" control="start" />
        <Ecp id="ecp" />
    </children>
</component>


MainScene.brs
sub init()
    m.ecp = m.top.findNode("ecp")
    m.timer = m.top.findNode("timer")
    m.timer.ObserveField("fire", "onFire")
    m.top.SetFocus(true)

    '>>>> COMMENT THE FOLLOWING LINE: ECP WORKS <<<<<'
    '>>>> UN-COMMENT THE FOLLOWING LINE: ECP FAILS WITH ERROR 503 <<<<'
    m.top.dialog = CreateObject("roSGNode", "ProgressDialog")
end sub

sub onFire()
    m.dialog = CreateObject("roSGNode", "Dialog")
    m.dialog.title = "Dialog Title"
    m.dialog.buttons = ["Run Netflix", "Cancel"]
    m.dialog.ObserveField("buttonSelected", "onButtonSelected")
    m.top.dialog = m.dialog
end sub

sub onButtonSelected()
    if m.dialog.buttonSelected = 0
        m.ecp.ecpExec = "http://localhost:8060/launch/12"
        m.ecp.control = "RUN"
    else
        m.dialog.close = true
    end if
end sub


Ecp.xml
<?xml version="1.0" encoding="UTF-8"?>

<component name="Ecp" extends="Task">
  <script type="text/brightscript" uri="pkg:/components/Ecp.brs" />
  <interface>
    <field id="ecpExec" type="uri" />
  </interface>
</component>


Ecp.brs
sub init()
    m.top.functionName = "taskRun"
end sub

function taskRun() as void
    port = CreateObject("roMessagePort")
    ut = CreateObject("roUrlTransfer")
    ut.SetPort(port)
    ut.SetUrl(m.top.ecpExec)
    ut.AsyncPostFromString("")
    msg = Wait(0, port)
    print "ResponseCode: "; msg.GetResponseCode(); " FailureReason: "; msg.GetFailureReason()
end function


The error I get, unless the m.top.dialog assignment is commented out in MainScene.brs/init() is:
ResponseCode:  503 FailureReason: The requested URL returned error: 503 Service Unavailable
0 Kudos
BCVatOVG
Visitor

Re: EPC Bug with Scene Graph ProgressDialog

Sorry, this was a bit unclear.  I was trying to make it as simple and as stripped down as possible in order to eliminate any code that may be conflicting with the ECP.

Thank you for taking the time to test, try workarounds, and identify this as a bug.  I did more testing too and packaged another test channel.

I have attached 2 versions of a new built program, so anyone can test this out.  The builds are the same except that DialogSwap will create a progress dialog that will then be replaced by a normal dialog causing the ECP command to launch another channel to fail. The second app DialogNoSwap only opens and closes a Progress Dialog (does NOT switch it with another dialog) and the ECP command to launch another channel works.

I hope this clarify's the issue.  Please let me know if you have any further questions.

DialogNoSwap
DialogSwap

Thanks,
Blake
0 Kudos
EnTerr
Roku Guru

Re: EPC Bug with Scene Graph ProgressDialog

Ha. I am mystified as to why this http 503 happens!
Could it have something to do with not draining the message from internal port?
Or is it a timing issue (e.g. sending too fast) 
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.