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: 
Level 7

Home key hangs device

I've written a simple program that renders a screen, with a message wait loop for input and exit from the program.  I listen for roUniversalControlEvent and pick up on all the button presses... except the home key.

The problem is that when the home key is pressed, the Brightscript console prints that the program has exited, but instead of returning to the home page it just creates a black screen.  Almost any button press will produce a sound, but you are still stuck at the black screen.  Through much experimentation, I discovered that if I press the netflix button, wait for a moment, then press the home button, I can recover the home screen.

Since I'm not allowed to handle the home key, I don't know what to do to fix this.  The main program code is below.

Any ideas on why the firmware isn't taking me fully back to the home screen?

David

 

sub showChannelSGScreen()

    screen = CreateObject("roScreen")

    port = CreateObject("roMessagePort")

    screen.SetMessagePort(port)

 

    width = screen.GetWidth()

    height = screen.GetHeight()

    white = &hDDDDDDFF

    dark_gray = &h919498FF

    green = &h00FF00FF

    black = &h000000FF

    blue = &h007C9C7F

        

    fontRegistry = CreateObject("roFontRegistry")

    font = fontRegistry.GetDefaultFont()

    instructionFont = fontRegistry.GetDefaultFont(90,true,false)

    

    number_width = width / 4 

    number_height = height / 2

     screen.finish()

    state = 2

    notFinished = true

    offset = 40

    print "Entering CHOOSE A DIE rendering loop"

    while notFinished

        screen.DrawRect(0, 0, width,height,white) 

        screen.DrawText("CHOOSE A DIE",width / 4 + 100, height / 4,blue, instructionFont)

        upper_x = 0

        upper_y = number_height - 25

        if state = 0

            upper_x = 0 + (number_width / 2) - offset

        else if state = 1

            upper_x = number_width + (number_width / 2) - offset

        else if state = 2

            upper_x = (number_width * 2) + (number_width / 2) - offset

        else if state = 3

            upper_x = (number_width * 3) + (number_width / 2) - offset

        else

            print "unexpected state: " + StrI(state)

        end if

        screen.DrawRect(upper_x, upper_y,100,100,dark_gray)

        screen.DrawText("2", 0 + (number_width / 2), number_height, black, font)

        screen.DrawText("6", number_width + (number_width / 2), number_height, black, font)

        screen.DrawText("8", (number_width * 2) + (number_width / 2), number_height, black, font)

        screen.DrawText("20", (number_width * 3) + (number_width / 2), number_height, black, font)   

        screen.finish()

        

        print "Entering CHOOSE A DIE input loop"

        msg = wait(0, port) ' wait for a message

        if type(msg) = "roUniversalControlEvent" then

            if(msg.isPress()) then

                print "key:" + StrI(msg.GetKey())

                if msg.getKey() = 4

                    if state > 0

                        state = state - 1

                    endif

                else if msg.getKey() = 3

                    if state > 0

                        state = state - 1

                    endif

                else if msg.getKey() = 5

                    if state < 3

                        state = state + 1

                    endif

                else if msg.getKey() = 2

                    if state < 3

                        state = state + 1

                    endif

                else if msg.getKey() = 6

                    notFinished = false

                else if msg.getKey() = 0

                    return

                endif

            endif         

        endif

    end while

    ...

end sub

 

0 Kudos
7 Replies
Level 7

Re: Home key hangs device

Here is a shorter program that exhibits the same hang on hitting the home key (while in the input loop):

 

sub Main()

    showChannelSGScreen()

end sub

 

sub showChannelSGScreen()

    screen = CreateObject("roScreen")

    port = CreateObject("roMessagePort")

    screen.SetMessagePort(port)

 

    print "DBM 1"

 

    red = &hFF0000FF

    width = screen.GetWidth()

    height = screen.GetHeight()

    screen.DrawRect(0,0,width,height,red)

    screen.finish()

    

    notFinished = true

    while notFinished

        msg = wait(0, port) ' wait for a message

        if type(msg) = "roUniversalControlEvent" then

            if(msg.isPress()) then

                print "key:" + StrI(msg.GetKey())

            endif         

        endif

    end while

end sub

0 Kudos
Level 7

Re: Home key hangs device

This one shows the hang too..

 

sub Main()

    showChannelSGScreen()

end sub

 

sub showChannelSGScreen()

    screen = CreateObject("roScreen")

    port = CreateObject("roMessagePort")

    screen.SetMessagePort(port)

 

    print "DBM 1"

 

    red = &hFF0000FF

    width = screen.GetWidth()

    height = screen.GetHeight()

    screen.DrawRect(0,0,width,height,red)

    screen.finish()

    

    wait(0, port)

end sub

0 Kudos
Level 7

Re: Home key hangs device

This will also give you the home key hang.

 

sub Main()

    showChannelSGScreen()

end sub

 

sub showChannelSGScreen()

    screen = CreateObject("roScreen")

    port = CreateObject("roMessagePort")

    screen.SetMessagePort(port)

    wait(0, port)

end sub

 

0 Kudos
Level 21

Re: Home key hangs device

I tried your last example and whether I press Home or any other button it exits to the home screen.  What version of firmware do you have?  I'm on v9.2.

0 Kudos
Level 7

Re: Home key hangs device

3810X - Roku Streaming Stick+

9.2.0 build 4807-50

 

0 Kudos
Level 21

Re: Home key hangs device

I don't have one of those sticks.  You've probably done this, but make sure you reboot your device before you try it again.

0 Kudos
Level 7

Re: Home key hangs device

This happened on both my Roku Streaming Stick and my Roku Ultra.

 

The solution was to remove this line from my manifest:

splash_rsg_optimization=1

When this line is present in the manifest, the Home Key is broken for exiting the app.  By removing it, the Home Key works as expected.

I followed the examples!  Kind of unhappy about Roku development today.  There isn't a big body of coding samples out there and I really felt cut adrift on something that seemed simple like this.

 

0 Kudos