Debugging BrightScript

The Roku client is written in BrightScript. Consider the following items when debugging client issues:

  • To see specific BrightScript compile or XML parse errors in remote component libraries (that is, those generated by a server), use the Roku device’s web service Upload and Replace buttons to load the library. Any errors in loading the component library are sent to the client’s port 8085. This method allows you to see the errors instead of just a “load failed” message.

  • Never give a scene node a reference to another scene node because this is a circular reference and creates memory leaks. The Roku Garbage Collector may fail to detect circular references in some cases.

  • If you write BrightScript code that observes a field, ensure that you un-observe the field before observing it again. Otherwise, the Roku field change handler may execute multiple times which may cause app instabilities.

  • Connect to the Roku BrightScript Console to debug your application:

     telnet <roku device ip> 8085
      > sgnodes all
      > sgnodes roots
      > sgnodes "myNodeName"
      > rd2d_bitmaps  (texture usage)
  • You can output all fields of a node from BrightScript by printing it; for example:

     newNode ="myNode")
     ? newNode
  • Normally, the server process waits for the client before it starts staging screens. To bypass this behavior on a local server for testing, launch the app logic using the -i command line argument.

  • You can clear the Roku’s registry (which implements the app’s persistent store) by adding the following to the CreatePersistentStoreEvent() function in registry.brs:

     function CreatePersistentStoreEvent() as Object
     ' clear the registry
     section = GetPersistentStoreSection()

See also Troubleshooting .