Menu

The curious thing about roGridScreen

"Software and cathedrals are much the same - first we build them, then we pray" --Samuel T. Redwine, Jr.

As every programmer knows, the discovery of a bug is inevitable when you spend enough time working with a specific application or programming language. And the brightscript programming language is unfortunately not unique in that respect. There have been a number of bugs that I've encountered while working with the Roku device and the brightscript language. Most of them were easy to work around and didn't present any permanent obstacles to the development of OpenRokn. However, there are a few bugs that have never been patched and continue to hamper development efforts.

I have decided to begin posting occasional blog entries about the various bugs that I encounter while developing OpenRokn. I'm hoping that these posts will eventually be read by the right person who will finally patch these bugs. I find it rather unusual that a company such as Roku does not currently have any type of bug reporting system in place. There have been many instances where I have not reported bugs but would have if a bug tracking software such as bugzilla had been available on the Roku website.

Many of you may have noticed that in OpenRokn v0.2 the cancel button was not working in loading dialogs that preceded a grid screen. There is currently a bug involving the roGridScreen component that makes it impossible to detect when the cancel button has been pressed. As a result of this bug the cancel button has been completely removed in v0.3 from all loading dialogs that precede a grid screen.

There are a number of problems that seem to stem from the SetupLists() method of the roGridScreen component. For whatever reason as soon as you call SetupLists() the roGridScreen component begins intercepting all remote button events. That prevents the roMessageDialog from detecting when the cancel button has been pressed. The strangest aspect of this bug is that it occurs regardless of whether grid.Show() is called and it occurs even if a message port has not been set on the object.

You can reproduce the bug by coding the Main() function in the openrokn.brs script to display a loading dialog and to create a roGridScreen component that is set to exit when the up button is pressed on the top row.

Sub Main() 
   canvas = createSplashScreen() 
   canvas.Show()

   port = CreateObject("roMessagePort") 
   dialog = createMessageDialog(port, "Loading...", "", true, false, true, [{index:1,label:"Cancel"}]) 
   dialog.Show()

   rowTitles = ["Row 1", "Row 2", "Row 3", "Row 4", "Row 5", "Row 6", "Row 7"] 
   grid = CreateObject("roGridScreen") 
   grid.SetBreadcrumbText("Breadcrumb 1", "Breadcrumb 2") 
   grid.SetBreadcrumbEnabled(true) 
   grid.SetGridStyle("flat-square") 
   grid.SetDisplayMode("scale-to-fit") 
   grid.SetDescriptionVisible(true) 
   grid.SetUpBehaviorAtTopRow("exit") 
   grid.SetupLists(rowTitles.Count()) 
   'grid.SetMessagePort(port)

   while true 
      msg = wait(0, port) 
      print type(msg) 
      print "isButtonPressed: ";msg.isButtonPressed() 
      print "isRemoteKeyPressed: ";msg.isRemoteKeyPressed() 
      print "isScreenClosed: ";msg.isScreenClosed() 
      print "isListItemFocused: ";msg.isListItemFocused() 
      print "isListItemSelected: ";msg.isListItemSelected() 
      print "GetType: ";msg.GetType() 
      print "GetMessage: ";msg.GetMessage() 
      print "GetIndex: ";msg.GetIndex() 
      print "GetData: ";msg.GetData() 
      if type(msg) = "roMessageDialogEvent" then 
         if msg.isButtonPressed() and msg.GetIndex() = 1 then 
            print "canceled" 
            dialog.Close() 
            return 
         endif 
      endif 
   end while 
End Sub

The first thing you'll notice is that the cancel button is invisible in the loading dialog. This is a completely unrelated bug and has nothing to do with the grid screen. If you commented out every line of code from "rowTitles" down to "grid.SetMessagePort" the cancel button would still be invisible. I have no idea what's causing that visual bug but the cancel button really is there, you just can't see it.

At this point if you press the up button on your remote it will exit to the main Roku menu. This is incredibly strange because the grid screen has not been shown and no message port has been set on the grid component. And yet it seems to be intercepting all remote button events.

If you were to uncomment the "grid.SetMessagePort" line and then load and exit the channel a couple of times you would eventually see an event detected by the message port. This event isn't detected every time the channel is loaded so it may take a couple of tries to reproduce it.

As soon as SetupLists() is called it triggers the isListItemFocused event. Again, this is incredibly strange because the grid screen hasn't been shown, it doesn't contain any list items and no remote buttons were pressed. If you comment out the "grid.SetupLists" line then everything works as expected. Pressing the up button does not cause the channel to exit and the isListItemFocused event is not detected by the message port.

So what does all of this mean? Well, if the SetupLists() method is never called then none of these bugs occur (excluding the invisible cancel button) and the roMessageDialog can successfully detect remote button events. Unfortunately it's impossible to create a grid screen without first calling SetupLists() so the only alternative is to remove the cancel button from grid screen loading dialogs.

I have uploaded a test channel that will confirm the presence of the bugs described above. It can be downloaded from the link below. If you would like to see the cancel button implemented in a future version of OpenRokn then I encourage you to contact Roku and request that these bugs be patched. And feel free to pass along a link to this page.

http://openrokn.sourceforge.net/bugs/rogridscreen_bug.zip

If you would like to help support this project please visit the link below to flattr it.

http://flattr.com/thing/404358/OpenRokn

Posted by kavulix 2012-11-21 Labels: bug roGridScreen

Log in to post a comment.