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?
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.