Testing Roku Channels involves using a debug console and access to a variety of ports. The debug console provides a window into the runtime environment and provides features such as crash logs, stack-traces and much more.
Table of Contents
Accessing the debug console
The Roku Plugin for Eclipse contains a built-in console with access to all the available debug ports.
The debug console can also be accessed using telnet through a shell application such as PuTTY for Windows or terminal on Mac and Linux:
The console shows the output of your channel during run time. If the channel crashes, the debugger will display the line number of the error, as well as the contents of variables at the time of the crash. If there is a syntax error in the code, it will also be described here. The developer console should be open whenever a channel is side-loaded to catch any possible startup errors.
In addition to displaying console output, the shell can also be used as an interactive debugger. When your application is running, simply press
ctrl + c to break the application and enter debug mode. You will see the BrightScript Debugger prompt where you can type in commands.
stopanywhere in your code. Be sure to remove this when submitting your channel for publication.
|8080||debug server||debug server containing a host of utilities|
|8085||BrightScript console||BrightScript runtime environment|
|8087||Screensaver||The starting point for screensavers|
BrightScript console (port 8085) commands
|Print current BrightScript component instances|
|Print a summary of BrightScript component instance counts by component type|
|Toggle whether BrightScript should break into the debugger after non-fatal diagnostic messages|
|Print backtrace of call function context frames|
|Print BrightScript component classes|
|Continue script execution|
|Move down the function context chain one|
|Run garbage collector|
|Print the list of BrightScript console commands|
|Print the last line that executed|
|List current function|
|Print the next line to execute|
|Step over a function|
|Step out of a function|
|Print a variable or expression|
|Step one program statement|
|List all current executed suspended threads|
|Select a suspended thread to debug - all following debug commands will execute within that thread|
|Move up the function context chain one|
|Print local variables and their types/values|
1 This command is only available in firmware version 7.2 and greater.
2 This command is only available in firmware version 7.5 and greater.
3 Shortcuts for
threadare only available in firmware version 7.6 and greater.
BrightScript statements can also be compiled and executed in the console. This can be used to change variables during execution or call a function that prints useful information about the state of your program.
Beginning with firmware version 7.5 and above, the main BrightScript console (port 8085) now provides context for all threads. This eliminates the need to have multiple telnet sessions open for each running thread and ports 8089 - 8093 will no longer be used.
As seen below, any break or
stop in the channel will suspend all threads. All threads will be listed with the following information:
- ID: thread ID
- Location: file the thread originated from and line number
- Source Code: current line of code
The current selected thread will be marked with an
This information can be recalled anytime during debugging using the
SceneGraph debug server (port 8080) commands
|enhanced_dev_log rendezvous on 2|
Enable console logging of thread rendezvous. Set to
|loaded_textures||Displays the current set of images loaded into texture memory|
|r2d2_bitmaps||Prints a list of assets loaded into texture memory and the amount of free, used, and maximum available memory on your device, respectively.|
|sgnodes all 1||Prints every existing node created by the currently running channel|
|sgnodes roots 1||Prints every existing node without a parent created by the currently running channel. The existence of these un-parented nodes means they are being kept alive by direct BrightScript references. These could be in variables local to a function, arrays, or associative arrays, including a component global |
|sgnodes node_ID 1||Prints nodes with an id field set to node_ID, except it bypasses all the hierarchy and rules, and just runs straight down the whole list in the order of node creation. It will list multiple nodes if there are several that match.|
|This command provides basic node operation performance metrics. This command tracks all node operations by thread, whether its being created or an operation on an existing node, and whether it involves a rendezvous.|
|This command can be used to change the observer callback model and can also override the default |
1 These commands are similar to the getAll() , getRoots() , getRootsMeta(), and getAllMeta() ifSGNodeChildren methods, which can be called on any SceneGraph node.
2 Available since firmware version 7.6.