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

SDK or BrightScript Changes Between Roku 2 and Roku 3

I have a BrightScript file that's used in registration and activation of Roku boxes for a private channel subscription. It was written about 2 years ago. It continues to work fine with Roku 2 models. However, when used with any of the Roku 3 models, it aborts. There is no change indicated in the Roku SDK that explains this behavior. I have copied the debugger output, below. I know it is of limited value in troubleshooting this issue. If possible, I appreciate receiving an email address to which I could send the actual brs file (or the complete app).
Thank you.



------ Running ------
?BrightScript Micro Debugger.
Enter any BrightScript statement, debug commands, or HELP.

Current Function:
106: Function showRegDialog(infotype) As Integer
107: regDialog = createobject("roMessageDialog")
108: regDialog.setmessageport(createobject("roMessagePort"))
109: regDialog.enableoverlay(true)
110:
111: if (infotype = 0)
112: regDialog.setTitle("supermediaplex")
113: regDialog.settext("Are you a supermediaplex subscriber?")
114: regDialog.addbutton(0,"Yes")
115: regDialog.addbutton(1,"No")
116:
117: elseif (infotype = 1)
118: regDialog.setTitle("It's easy to get started.")
119: regDialog.settext("Go to your Internet browser and visit: http://WWW.SUPERMEDIAPLEX.COM")
120: regDialog.addbutton(0,"Done")
121: endif
122: regDialog.show()
123: while true
124: msg = wait(0,regDialog.GetMessagePort())
125: if msg.isscreenclosed() return -1
126: if msg.isButtonInfo() return -1 ' Info pressed again, dismiss the info overlay
127: if msg.isbuttonpressed() and infotype=0 then
128: button = msg.getindex()
129: print "Info Button ";button;" pressed"
130: if button = 1 then
131: isReady = ShowDialog2Buttons("Ready to get start ed?","","Yes","No")
132: if isReady = 0 then
133: showRegDialog(1)
134: endif
135: return 1
136: else
137: return 0
138: endif
139: elseif msg.isbuttonpressed() and infotype=1 then
140: return 1
141: endif
142: end while
143: end function
Break in 124
124: msg = wait(0,regDialog.GetMessagePort())
Backtrace:
Function showregdialog(infotype As Dynamic) As Integer
file/line: /tmp/plugin/DDAAAAOnTdvz/pkg:/source/regScreen.brs(124)
Function doregistration() As Integer
file/line: /tmp/plugin/DDAAAAOnTdvz/pkg:/source/regScreen.brs(35)
Function preshowhomescreen(breada As Dynamic, breadb As Dynamic) As Object
file/line: /tmp/plugin/DDAAAAOnTdvz/pkg:/source/appHomeScreen.brs(12)
Function main() As Void
file/line: /tmp/plugin/DDAAAAOnTdvz/pkg:/source/appMain.brs(20)

Local Variables:
infotype &h0002 Integer val:0
global &h0020 rotINTERFACE:ifGlobal
m &h0010 bsc:roAssociativeArray, refcnt=5
regdialog &h0010 bsc:roMessageDialog, refcnt=1
msg &h0000 <uninitialized> val:Uninitialized
button &h0000 <uninitialized> val:Uninitialized
isready &h0000 <uninitialized> val:Uninitialized
BrightScript Debugger> ------ Running ------

In my .brs file, line 124 and subsequent lines referenced in the debugger are scripted as follows:
		msg = wait(0,regDialog.GetMessagePort())
if msg.isscreenclosed() return -1
if msg.isButtonInfo() return -1 ' Info pressed again, dismiss the info overlay
if msg.isbuttonpressed() and infotype=0 then
button = msg.getindex()
print "Info Button ";button;" pressed"
if button = 1 then
isReady = ShowDialog2Buttons("Ready to get started?","","Yes","No")
if isReady = 0 then
showRegDialog(1)
endif
return 1
else
return 0
endif
0 Kudos
10 REPLIES 10\
EnTerr
Level 11

Re: SDK or BrightScript Changes Between Roku 2 and Roku 3

That's no abort. See where it says
Break in 124
124: msg = wait(0,regDialog.GetMessagePort())
Backtrace:
That just shows you have pressed Ctrl-C in console to interrupt the program while it was waiting for event on the dialog port.

On a side note, can you edit your message and put [code ][/code] brackets around the code/printouts you post? Makes it easier to read; there is even formatting button on toolbar for that, mark code and click |Code|.
0 Kudos
JohnBasedow
Level 7

Re: SDK or BrightScript Changes Between Roku 2 and Roku 3

I know you have an 'infinite' wait with wait (0, ...), but you still want to make sure the msg isn't invalid before you access it.

But, based on this trace, it looks like you have caused it to abort via the console.
0 Kudos
mosbat
Level 7

Re: SDK or BrightScript Changes Between Roku 2 and Roku 3

I have provided an updated debug and a more complete section of the code. The only time CTL-C is pressed is at the outset, so as to enable the micro debugger. I emphasize that the code works perfectly fine with Roku 2 series. However, in subsequent versions something has evidently changed with the "showRegDialog" function. I appreciate any guidance. Thank you.

------ Running ------
?BrightScript Micro Debugger.
Enter any BrightScript statement, debug commands, or HELP.

Current Function:
106: Function showRegDialog(infotype) As Integer
107: regDialog = createobject("roMessageDialog")
108: regDialog.setmessageport(createobject("roMessagePort"))
109: regDialog.enableoverlay(true)
110:
111: if (infotype = 0)
112: regDialog.setTitle("Supermediaplex")
113: regDialog.settext("Are you a Supermediaplex subscriber?")
114: regDialog.addbutton(0,"Yes")
115: regDialog.addbutton(1,"No")
116:
117: elseif (infotype = 1)
118: regDialog.setTitle("It's easy to get started.")
119: regDialog.settext("Go to your Internet browser and visit: WWW.SUPERMEDIAPLEX.COM")
120: regDialog.addbutton(0,"Done")
121: endif
122: regDialog.show()
123: while true
124: msg = wait(0,regDialog.getmessageport())
125: if msg.isscreenclosed() return -1
126: if msg.isButtonInfo() return -1 ' Info pressed again, dismiss the info overlay
127: if msg.isbuttonpressed() and infotype=0 then
128: button = msg.getindex()
129: print "Info Button ";button;" pressed"
130: if button = 1 then
131: isReady = ShowDialog2Buttons("Ready to get started?","","Yes","No")
132: if isReady = 0 then
133: showRegDialog(1)
134: endif
135: return 1
136: else
137: return 0
138: endif
139: elseif msg.isbuttonpressed() and infotype=1 then
140: return 1
141: endif
142: end while
143: end function
Break in 124
124: msg = wait(0,regDialog.getmessageport())
Backtrace:
Function showregdialog(infotype As Dynamic) As Integer
file/line: /tmp/plugin/OCAAAAxdFl4H/pkg:/source/regScreen.brs(124)
Function doregistration() As Integer
file/line: /tmp/plugin/OCAAAAxdFl4H/pkg:/source/regScreen.brs(35)
Function preshowhomescreen(breada As Dynamic, breadb As Dynamic) As Object
file/line: /tmp/plugin/OCAAAAxdFl4H/pkg:/source/appHomeScreen.brs(12)
Function main() As Void
file/line: /tmp/plugin/OCAAAAxdFl4H/pkg:/source/appMain.brs(20)

Local Variables:
infotype &h0002 Integer val:0
global &h0020 rotINTERFACE:ifGlobal
m &h0010 bsc:roAssociativeArray, refcnt=5
regdialog &h0010 bsc:roMessageDialog, refcnt=1
msg &h0000 <uninitialized> val:Uninitialized
button &h0000 <uninitialized> val:Uninitialized
isready &h0000 <uninitialized> val:Uninitialized
BrightScript Debugger> c

Current Function:

106: Function showRegDialog(infotype) As Integer
107: regDialog = createobject("roMessageDialog")
108: regDialog.setmessageport(createobject("roMessagePort"))
109: regDialog.enableoverlay(true)
110:
111: if (infotype = 0)
112: regDialog.setTitle("Supermediaplex")
113: regDialog.settext("Are you a Supermediaplex subscriber?")
114: regDialog.addbutton(0,"Yes")
115: regDialog.addbutton(1,"No")
116:
117: elseif (infotype = 1)
118: regDialog.setTitle("It's easy to get started.")
119: regDialog.settext("Go to your Internet browser and visit: WWW.SUPERMEDIAPLEX.COM")
120: regDialog.addbutton(0,"Done")
121: endif
122: regDialog.show()
123: while true
124: msg = wait(0,regDialog.getmessageport())
125: if msg.isscreenclosed() return -1
126: if msg.isButtonInfo() return -1 ' Info pressed again, dismiss the info overlay
127: if msg.isbuttonpressed() and infotype=0 then
128: button = msg.getindex()
129: print "Info Button ";button;" pressed"
130: if button = 1 then
131: isReady = ShowDialog2Buttons("Ready to get started?","","Yes","No")
132: if isReady = 0 then
133: showRegDialog(1)
134: endif
135: return 1
136: else
137: return 0
138: endif
139: elseif msg.isbuttonpressed() and infotype=1 then
140: return 1
141: endif
142: end while
143: end function
'Dot' Operator attempted with invalid BrightScript Component or interface refere
nce. (runtime error &hec) in ...l4H/pkg:/source/regScreen.brs(125)
125: if msg.isscreenclosed() return -1
Backtrace:
Function showregdialog(infotype As Dynamic) As Integer
file/line: /tmp/plugin/OCAAAAxdFl4H/pkg:/source/regScreen.brs(125)
Function doregistration() As Integer
file/line: /tmp/plugin/OCAAAAxdFl4H/pkg:/source/regScreen.brs(35)
Function preshowhomescreen(breada As Dynamic, breadb As Dynamic) As Object
file/line: /tmp/plugin/OCAAAAxdFl4H/pkg:/source/appHomeScreen.brs(12)
Function main() As Void
file/line: /tmp/plugin/OCAAAAxdFl4H/pkg:/source/appMain.brs(20)

Local Variables:
infotype &h0002 Integer val:0
global &h0020 rotINTERFACE:ifGlobal
m &h0010 bsc:roAssociativeArray, refcnt=5
regdialog &h0010 bsc:roMessageDialog, refcnt=1
msg &h0080 Invalid val:invalid
button &h0000 <uninitialized> val:Uninitialized
isready &h0000 <uninitialized> val:Uninitialized
BrightScript Debugger> c

Current Function:
106: Function showRegDialog(infotype) As Integer
107: regDialog = createobject("roMessageDialog")
108: regDialog.setmessageport(createobject("roMessagePort"))
109: regDialog.enableoverlay(true)
110:
111: if (infotype = 0)
112: regDialog.setTitle("Supermediaplex")
113: regDialog.settext("Are you a Supermediaplex subscriber?")
114: regDialog.addbutton(0,"Yes")
115: regDialog.addbutton(1,"No")
116:
117: elseif (infotype = 1)
118: regDialog.setTitle("It's easy to get started.")
119: regDialog.settext("Go to your Internet browser and visit: WWW.SUPERMEDIAPLEX.COM")
120: regDialog.addbutton(0,"Done")
121: endif
122: regDialog.show()
123: while true
124: msg = wait(0,regDialog.getmessageport())
125: if msg.isscreenclosed() return -1
126: if msg.isButtonInfo() return -1 ' Info pressed again, dismissthe info overlay
127: if msg.isbuttonpressed() and infotype=0 then
128: button = msg.getindex()
129: print "Info Button ";button;" pressed"
130: if button = 1 then
131: isReady = ShowDialog2Buttons("Ready to get started?","","Yes","No")
132: if isReady = 0 then
133: showRegDialog(1)
134: endif
135: return 1
136: else
137: return 0
138: endif
139: elseif msg.isbuttonpressed() and infotype=1 then
140: return 1
141: endif
142: end while
143: end function
Function Call Operator ( ) attempted on non-function. (runtime error &he0) in ..
.l4H/pkg:/source/regScreen.brs(125)
125: if msg.isscreenclosed() return -1
Backtrace:
Function showregdialog(infotype As Dynamic) As Integer
file/line: /tmp/plugin/OCAAAAxdFl4H/pkg:/source/regScreen.brs(125)
Function doregistration() As Integer
file/line: /tmp/plugin/OCAAAAxdFl4H/pkg:/source/regScreen.brs(35)
Function preshowhomescreen(breada As Dynamic, breadb As Dynamic) As Object
file/line: /tmp/plugin/OCAAAAxdFl4H/pkg:/source/appHomeScreen.brs(12)
Function main() As Void
file/line: /tmp/plugin/OCAAAAxdFl4H/pkg:/source/appMain.brs(20)

Local Variables:
infotype &h0002 Integer val:0
global &h0020 rotINTERFACE:ifGlobal
m &h0010 bsc:roAssociativeArray, refcnt=5
regdialog &h0010 bsc:roMessageDialog, refcnt=1
msg &h0080 Invalid val:invalid
button &h0000 <uninitialized> val:Uninitialized
isready &h0000 <uninitialized> val:Uninitialized
BrightScript Debugger>

The followings are lines 106 through 143 that contain the showRegDialog function:
Function showRegDialog(infotype) As Integer
regDialog = createobject("roMessageDialog")
regDialog.setmessageport(createobject("roMessagePort"))
regDialog.enableoverlay(true)

if (infotype = 0)
regDialog.setTitle("Photros")
regDialog.settext("Are you a Supermediaplex subscriber?")
regDialog.addbutton(0,"Yes")
regDialog.addbutton(1,"No")

elseif (infotype = 1)
regDialog.setTitle("It's easy to get started.")
regDialog.settext("Go to your Internet browser and visit: WWW.SUPERMEDIAPLEX.COM")
regDialog.addbutton(0,"Done")
endif
regDialog.show()
while true
msg = wait(0,regDialog.getmessageport())
if msg.isscreenclosed() return -1
if msg.isButtonInfo() return -1 ' Info pressed again, dismiss the info overlay
if msg.isbuttonpressed() and infotype=0 then
button = msg.getindex()
print "Info Button ";button;" pressed"
if button = 1 then
isReady = ShowDialog2Buttons("Ready to get started?","","Yes","No")
if isReady = 0 then
showRegDialog(1)
endif
return 1
else
return 0
endif
elseif msg.isbuttonpressed() and infotype=1 then
return 1
endif
end while
end function
0 Kudos
RokuMarkn
Level 8

Re: SDK or BrightScript Changes Between Roku 2 and Roku 3

JohnBasedow already provided the answer. Before calling methods on the msg object returned from wait, you need to verify the type of the object. You should be doing something like this:

msg = wait(0, regDialog.getmessageport())
if (type(msg) = "roSpringboardScreenEvent" then
if msg.isscreenclosed() return -1
if msg.isButtonInfo() return -1
' etc
end if

You've been lucky because on the Roku 2 you're not getting any events other than the type you expect, but you shouldn't depend on that.

--Mark
0 Kudos
EnTerr
Level 11

Re: SDK or BrightScript Changes Between Roku 2 and Roku 3

"mosbat" wrote:
I have provided an updated debug and a more complete section of the code.
...
Function Call Operator ( ) attempted on non-function. (runtime error &he0) in ..
.l4H/pkg:/source/regScreen.brs(125)
125: if msg.isscreenclosed() return -1

Local Variables:
...
msg &h0080 Invalid val:invalid
...


You provided WAY, WAY TOO MUCH text from the console, with 3 stack traces - 2 from ^C and 1 from the error at the end. Above I trimmed the output only to the relevant part - that makes it easy to spot. See, msg is invalid and you are calling isScreenClosed() on it, so it rightfully bitches there is no such function. It is possible that you got invalid there because you interrupted with ctrl-C the script before and then "c"ontinued it - i seem to remember in that case invalid spoke is being thrown in the message wheel. The solution is as pointed out, check type(msg)="..." before calling methods. Or "if msg<>invalid then ...", whatever.
0 Kudos
mosbat
Level 7

Re: SDK or BrightScript Changes Between Roku 2 and Roku 3

Upon further debugging found that the code stops executing at the following function:
Function displayRegistrationScreen() As Object
regsite = "" + m.UrlBase
regscreen = CreateObject("roCodeRegistrationScreen")
regscreen.SetMessagePort(CreateObject("roMessagePort"))

Any guidance is much appreciated. Reminder, this works in Roku2. The problem is limited to Roku3. Thank you.
0 Kudos
RokuJoel
Roku Employee
Roku Employee

Re: SDK or BrightScript Changes Between Roku 2 and Roku 3

What firmware version on your Roku3? I just tested with 5.4 b3340 on a Roku3 and I don't see any issue:


sub main()
regsite = "http://"
regscreen = CreateObject("roCodeRegistrationScreen")
regscreen.SetMessagePort(CreateObject("roMessagePort"))
regscreen.show()
while true


end while
end sub


I don't think this is the cause of your problem, although the value of m.UrlBase could cause a crash if it was not a string.

- Joel
0 Kudos
mosbat
Level 7

Re: SDK or BrightScript Changes Between Roku 2 and Roku 3

I tried replacing the line -- regsite = "" + m.UrlBase -- with the actual URL; but results were the same. I am using the HDMI Stick 3500X, running FW Version 5.4, B2525 (which I believe is the latest released update). A colleague, using Roku 3 "STB model" is also getting the same errors.

You referenced B3340. Are you saying that you tested the SuperMediaPlex private channel with B3340 and there were no activation screen issues?

Incase not had a chance to test, wonder if I could impose upon you to test SuperMediaPlex for yourself. https://owner.roku.com/Account/ChannelCode/?code=supermediaplex

Thank you.
0 Kudos
RokuJoel
Roku Employee
Roku Employee

Re: SDK or BrightScript Changes Between Roku 2 and Roku 3

Hi, no, I tested your little snippet of code and determined that your displayRegistrationScreen function is not failing due to anything in these two lines of code:

   regscreen = CreateObject("roCodeRegistrationScreen")
regscreen.SetMessagePort(CreateObject("roMessagePort"))
0 Kudos