Roku Developer Program

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

What causes an app to exit?

As I've been building my app, I've noticed that sometimes my app exits unexpectedly. Eventually, I figured out that if instead of creating and closing roPosterScreens for my various pages, if I just create a single roPosterScreen and keep updating the contents, that keeps the app from exiting. Today, I just noticed in one of the example apps, /simplevideoplayer/source/appMain.brs, the following comment:

    'has to live for the duration of the whole app to prevent flashing                               
'back to the roku home screen.
screenFacade = CreateObject("roPosterScreen")
screenFacade.show()

I assume this addresses the same issue I noticed. I can't find any documentation that talks about lifetimes of screens and when an app exits. Is this documented somewhere? Could you point me to the right place?

What happens if you show() more than one screen? Does the more recent one just overlay the first? And if you close() the one on top, does the first one now get exposed?
0 Kudos
3 Replies
Highlighted
Level 10

Re: What causes an app to exit?

You'll generate less server traffic if you use different screens to show different content - that way the previous screens are retained in roku's ram. There are specific instances where updating the current screen makes more sense - like if your current screen has hundreds of content items and you want to simply remove one from the list, or change the sort order.
When you exit the top window, the top screen closes and the underlying windows don't have to be redrawn - (from my understanding) it returns control to the previous wait queue that triggered initial creation of the top screen you just closed.
The app will exit if it is live and encounters a script error, if your script tries to call a routine that is invalid, possible divide by zero errors, if the user presses home, or if all screens are closed. So by creating the facade screen first, that helps.
If you don't close the bottommost screen, then the app should continue running unless it has nothing more to do.

That being said, there are a few cases with grid screens and audio springboards, or simply the audioplayer component, as well as the roimagecanvas component, that still do not play nice with the other screen types, forcing you to have to destroy the gridscreen, and redraw it every time the interaction fails to graphically cooperate.
0 Kudos
Highlighted
Level 7

Re: What causes an app to exit?

Thanks for the explanation. Is all of this documented somewhere?
0 Kudos
Highlighted
Level 10

Re: What causes an app to exit?

Maybe a search for "facade" will help.
viewtopic.php?f=34&t=26350&p=162550#p162550

Also, having a single line with the word "End" in your app code will exit the channel as soon as the line is executed.
0 Kudos