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

Debugging Help - Screensaver Crashes

Hi,

I'm looking for some help debugging. I have written a very simple screensaver, based on examples I found on-line. Basically, it looks like this:

sub RunScreenSaver()
  screen = CreateObject("roSGScreen")
  port = CreateObject("roMessagePort")
  screen.setMessagePort(port)

  m.global = screen.getGlobalNode()

  scene = screen.CreateScene("ScreensaverFade")
  screen.show()

  while(true)
    msg = wait(30000, port)

    if (msg <> invalid)
      msgType = type(msg)
      if msgType = "roSGScreenEvent"
        if msg.isScreenClosed() then return
      end if
    end if
  end while
end sub


The corresponding screen file is:
<?xml version="1.0" encoding="UTF-8"?>
<component name="ScreensaverFade" extends="Scene" >
  <children>
    <Poster 
      id = "Cache"
      height = "720"
      width = "1280"
      uri = "pkg:/images/splash-screen_hd.jpg"
    />
 </children>
</component>


This "screensaver" runs in preview and when the Roku is on the Home screen, but it crashes when it gets started from inside the Roku Media Player. If I comment out the line screen.show(), it doesn't crash but display a blank screen as expected.
This screensaver actually used to work well, the crash started happening after a firmware update a couple of weeks ago. I finally managed to reduce the issue to the minimum example code above (the actual code does a little bit more, although not all that much), but I'm lost at how I can continue fixing this.
Any suggestions would be appreciated. I am very new at Roku development.
0 Kudos
7 REPLIES 7
squirreltown
Roku Guru

Re: Debugging Help - Screensaver Crashes

I don't see anything obvious.  Commenting out show() means it's not actually running, so that doesn't tell you anything. You need run the debugger on port 8087 (screensaver) and see why it's crashing.
Kinetics Screensavers
0 Kudos
egrivel
Visitor

Re: Debugging Help - Screensaver Crashes

This is what I see when I telnet to port 8087:
------ Running dev '' runscreensaver ------

Connection closed by foreign host.


All it does is close the telnet connection. No output, nothing
I also tried post 8085, but that does the same thing (just the telnet connection getting closed when the screensaver kicks in).
0 Kudos
squirreltown
Roku Guru

Re: Debugging Help - Screensaver Crashes

"All it does is close the telnet connection. No output, nothing
I also tried post 8085, but that does the same thing (just the telnet connection getting closed when the screensaver kicks in)."


Make sure 8085 works,  then use 8087.  8085 will not show screensaver debugging. If it's closing right away, try the examples you worked from unaltered, and see if they run. I can't say more than that without seeing it.
Kinetics Screensavers
0 Kudos
egrivel
Visitor

Re: Debugging Help - Screensaver Crashes

Maybe a little bit more information.

I can telnet to port 8087. I now inserted a "stop" command just before the screen.show(). When I let the screensaver kick in outside of the Media Player, I can see in my telnet session that it stops. It also says "STOP (runtime error &hf7) in pkg:/source/main.brs, but I assume that is normal. I can to "s" to execute the next command, and it works as expected.

When I do the same thing when the screensaver kicks in inside the Roku Media Player, and it stops on the "stop" command, I see the same information. Now, when I type "s", it says "022: screen.show()" and then the telnet session is terminated, and the Roku reboots.

This is the total snippet when the stop happens:

BrightScript Micro Debugger.
Enter any BrightScript statement, debug commands, or HELP.


Current Function:
013:  
014:    ' ' Create global variable triggerSwap. This variable will trigger the
015:    ' ' swapping of images when it changes.
016:    ' m.global.AddField("triggerSwap", "int", true)
017:    ' m.global.triggerSwap = 0
018:  
019:    ' Create the scene
020:    scene = screen.CreateScene("ScreensaverFade")
021:*   stop
022:    screen.show()
023:  
024:    while(true)
025:    '   ' Message Port that fires every 30 seconds to change value of
STOP (runtime error &hf7) in pkg:/source/main.brs(21)
021:   stop
Backtrace:
#0  Function runscreensaver() As Void
   file/line: pkg:/source/main.brs(22)
Local Variables:
global           Interface:ifGlobal
m                roAssociativeArray refcnt=2 count:1
screen           bsc:roSGScreen refcnt=1
port             bsc:roMessagePort refcnt=2
scene            bsc:roSGNode refcnt=2
msg              <uninitialized>
msgtype          <uninitialized>

Brightscript Debugger> s
022:   screen.show()
Connection closed by foreign host.

Not sure if I'm doing something wrong? I can provide a link to the ZIP file with the application if that is any help.
0 Kudos
squirreltown
Roku Guru

Re: Debugging Help - Screensaver Crashes

Ok, so there is something in the ScreensaverFade component that is crashing it right? because you got that far in both situations, and then it crashes.  The only time I ever get a connection closed like that is if I accidentally put something in the code that's really illegal, and the Roku can't even interpret it. Memory is always an issue but the screensaver runs in it's own thread. Does it run on top of other apps besides the Media player, not just the home screen ?
Kinetics Screensavers
0 Kudos
egrivel
Visitor

Re: Debugging Help - Screensaver Crashes

That's what it sounds like, but the only thing in the ScreensaverFace.xml file is a single image. The entire file content is:
<?xml version="1.0" encoding="UTF-8"?>
<component name="ScreensaverFade" extends="Scene" >
  <children>
    <Poster 
      id = "Cache"
      height = "720"
      width = "1280"
      uri = "pkg:/images/black.jpg"
    />
  </children>
</component>


I actually replaced the JPG file with a file that is just black, figuring that would be as simple as it gets. Still the same behavior.

The other files that make up the project are main.brs, which I condensed down to:
sub RunScreenSaver()
  screen = CreateObject("roSGScreen")
  port = CreateObject("roMessagePort")
  screen.setMessagePort(port)

  m.global = screen.getGlobalNode()

  ' Create the scene
  scene = screen.CreateScene("ScreensaverFade")
  stop
  screen.show()

  while(true)
    msg = wait(30000, port)

    if (msg <> invalid)
      msgType = type(msg)
      if msgType = "roSGScreenEvent"
        if msg.isScreenClosed() then return
      end if
    end if
  end while
end sub


and manifest, which contains:
#
#  Copyright (c) 2016 Roku, Inc. All rights reserved.
#  Roku Channel Manifest File
#  Full spec at bit.ly/roku-manifest-file
#

##   Channel Details
screensaver_title=Test Screen Saver
major_version=1
minor_version=0
build_version=0

ui_resolutions=hd


That and the JPG file is the entire content of my project.

I'm starting to think there is something with the Roku Media Player, but that is an official Roku app, right? I didn't install some random app from the Web. My Roku model is 4630X, software version 8.1.0 build 4145-29, last updated July 26.

I only have six channels installed. I just tried with the PBS channel, and that seems to work fine in combination with the screensaver. 
0 Kudos
squirreltown
Roku Guru

Re: Debugging Help - Screensaver Crashes

I just tried my Roku Media player on a 4640 and one of my screensavers works over it fine. The only thing I've seen here different from what i do is I set my manifest resolution to fhd. 
Kinetics Screensavers
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.