If I run the following code to display a default springboard screen and the only thing I do after entering the channel is press the Home key on my Roku remote, then my Roku reboots:
sub main ()
port = CreateObject ("roMessagePort")
screen = CreateObject ("roSpringboardScreen")
screen.SetMessagePort (port)
screen.SetContent ({ContentType: "episode"})
screen.Show ()
for each msg in port
print "Message received"
end for
end sub
However, if I run the following code replacing the for-each loop with a while loop, then when I press the Home key the channel correctly exits:
sub main ()
port = CreateObject ("roMessagePort")
screen = CreateObject ("roSpringboardScreen")
screen.SetMessagePort (port)
screen.SetContent ({ContentType: "episode"})
screen.Show ()
while true
msg = wait (0, port)
print "Message received"
end while
end sub
According to the BrightScript reference manual, section 4.7 Events, on page 20, these two statements should be equivalent.
Any idea why the first one would crash the Roku? I’m running the 3.0 build 2227 firmware on a Roku HD model 2000C.
It’s probably got something to do with the Home key spewing invalid messages to the message port. Do you see a bunch of “Message received” strings when you run your second example? (I do when I try it.)
-JT
“renojim” wrote:
It’s probably got something to do with the Home key spewing invalid messages to the message port. Do you see a bunch of “Message received” strings when you run your second example? (I do when I try it.)
-JT
Yes, I do see a bunch of “Message received” strings in the second example, and only one in the first case before it crashes.
Still, I don’t see why the Roku would crash in the first case if the for-each and while loops are supposed to be equivalent ways to read event messages. Does this seem like a firmware bug or a “feature”? Out of curiousity, renojim, did the first example also crash your Roku?
I did a test, with very interesting results. Although I did not use your code exactly, I put the piece in question into the project I’m currently working on. Both worked to my surprise. I’m running 4.1 Build 2663 on a Roku 2 3100X. I placed in a roscreen…
I was expecting it to be a problem since you weren’t calling wait(0, port) in the for loop… but it ran fine for me…