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: 
opnchaudhary
Streaming Star

Roku channel not exiting

Hello All,
I wrote a roku channel, I have a function main() as entry point, which then opens another function homescreen(), when I hit back button in homescreen I can see in the debugger console that the homescreen function has returned control to the main function and the print line in main() function below the homescreen() function call is being printed. But the channel is not exiting. Its showing blank screen.
I had no luck with End / Stop.
Is there someone who had this issue and fixed it? Thanks.
Regards
Paras Nath Chaudhary

0 Kudos
10 REPLIES 10
dcrandall
Visitor

Re: Roku channel not exiting

I know you had to have checked this, but the code isn't there so I can't be sure... Is there any reason Main() wouldn't be exiting?
0 Kudos
TheEndless
Channel Surfer

Re: Roku channel not exiting

As dcrandall noted, there's no way for us to help you without seeing your code. Can you post your main() and homescreen() functions?
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
RokuJoel
Binge Watcher

Re: Roku channel not exiting

Make sure you homescreen() function has a return statement after the msg.isScreenClosed() event-detection logic. Also make sure you havent created an roImageCanvas in-line within a function that has another screen active within it.

- Joel
0 Kudos
opnchaudhary
Streaming Star

Re: Roku channel not exiting

Below is short snippet of my code. On back button press I can see "Reached End" printed in debugger console, but the channel doesn't exit. I am not using roImageCanvas anywhere in the project.


Function Main()

'Apply the theme
initTheme()


if GetAuthData() <> invalid then
response1=APICall(GetAPIurl()+"linked_roku.php?roku_code="+GetAuthData())
else
showRegistration()
endif


if response1 <> invalid then
if response1.status="true" then
'Show HOmeScreen
print "Status true"
SetXtraData("ctv_userid",response1.user.id)
homeScreen(0,2)
else
showRegistration()

endif
endif
print "Reached End"

End Function
function homeScreen(row as Integer,col as Integer)

'Normal API call for listing items in roGridScreen

dialog=ShowPleaseWait("Please wait","")
grid.SetUpBehaviorAtTopRow("stop")
grid.Show()
dialog.close()
while true
mresponse=APICall(GetAPIurl()+"message.php")
if mresponse.message <> invalid
if mresponse.message="r"
homeScreen(0,2)
else
'open roMessageDialog using a function call
endif
endif
if type(msg) = "roGridScreenEvent" then
if msg.isScreenClosed() then
return -1
exit while
elseif msg.isListItemFocused()
'no operation here
elseif msg.isListItemSelected()
'opens roSpringboardScreen using a function call
elseif msg.isRemoteKeyPressed()
'opens roMessageDialog using a functional call
endif
end if
end while
end function

Function ShowPleaseWait(title As dynamic, text As dynamic) As Object
port = CreateObject("roMessagePort")
dialog = CreateObject("roOneLineDialog")
dialog.SetMessagePort(port)
dialog.SetTitle(title)
dialog.ShowBusyAnimation()
dialog.Show()
return dialog
End Function


Thanks
Regards
Paras Nath Chaudhary

0 Kudos
destruk
Streaming Star

Re: Roku channel not exiting

You could 'ignore' the problem by adding END on the line below the print for Reached End - to insure the app exits when you want it to.
The code you posted is incomplete (as you are missing at least one "end if" in the homescreeen function) - which would have been caught by the debugger when you sideloaded the channel app.
0 Kudos
TheEndless
Channel Surfer

Re: Roku channel not exiting

My guess would be that the channel is actually crashing, which will prevent the channel from closing, when sideloaded, so you can debug the crash. What output do you see in the debug console?
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
opnchaudhary
Streaming Star

Re: Roku channel not exiting

Sorry for the endif missing in the snippet pasted here. The channel is not crashing. There is no error in debugger console. The mistake was only when I pasted my code here. And adding End after the print for "Reached End" didn't help. The channel doesn't close, remains open with a blank white screen.
Regards
Paras Nath Chaudhary

0 Kudos
EnTerr
Roku Guru

Re: Roku channel not exiting

"TheEndless" wrote:
My guess would be that the channel is actually crashing, which will prevent the channel from closing, when sideloaded, so you can debug the crash.

Your diagnosis is spot-on.

It always confuses me though, when someone says "crashing" about an Roku app that is in "interrupted" or "stopped"* state. If i really try to hone a metaphor, dev.channel is left in a "vegetative state" since UI is "wakeful" (some UI elements function and events may get queued) while BrightScript code is "unconscious". Subsequently, a side-loaded channel may regain consciousness, while a workhorse one gets shot.

(*) after the STOP statement for willfully breaking into console.
0 Kudos
destruk
Streaming Star

Re: Roku channel not exiting

If it's printing "Reached End" -- is this print anywhere else in your code files? It might not be at the place you think it is.
"End" would exit the channel if it executes a single end statement.
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.