Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
destruk
Streaming Star

Anyone seen a save registry value fail?

I have received a few bug reports of this happening, but I'm unable to reproduce it on any of my roku's.


Sub Main()
'... create facade, sets theme, etc etc

TheValue=RegRead("KeyName","MyChannel") 'read saved registry value

If Type(TheValue)="Invalid" Then
port=CreateObject("roMessagePort")
dialog=CreateObject("roMessageDialog")
dialog.SetMessagePort(port)
dialog.SetTitle("Invalid Registry Data")
dialog.SetText("No registry data exists - select OK to save new value")
dialog.AddButton(0,"OK")
dialog.Show()
While TRUE
dlgMsg=Wait(0,port)
If Type(dlgMsg)="roMessageDialogEvent"
If dlgMsg.isButtonPressed()
Print"Button pressed: ";dlgMsg.GetIndex();" ";dlgMsg.GetData()
Exit While
End If
End If
End While

TheValue=CreateObject("roDeviceInfo").GetDisplayType()
RegWrite("KeyName",TheValue,"MyChannel")
End If

'... displays regular screen, loads xml, etc etc etc
End Sub

Function RegRead(key,section=invalid)
If section=invalid section="Default"
sec=CreateObject("roRegistrySection",section)
If sec.Exists(key) Return sec.Read(key)
Return invalid
End Function

Function RegWrite(key,val,section=invalid)
If section=invalid section="Default"
sec=CreateObject("roRegistrySection",section)
sec.Write(key,val)
sec.Flush() 'commit it
End Function



It saves and loads the value just fine on all my roku's (Roku1 and Roku2 types), however, our clients are saying occasionally it pops the error message 'sometimes' when the code section is executed, meaning either it fails when writing the registry value 'sometimes' or the value is getting deleted sometimes. The channel isn't being removed from their roku, it's simply losing the value of the section/key? Have you seen this issue before?
There is no RegDelete command in the script files, just the RegDelete function itself (in case we need it for testing), and with the code above it should never be possible for .GetDisplayType() to return an invalid value to write.
0 Kudos
4 REPLIES 4
TheEndless
Channel Surfer

Re: Anyone seen a save registry value fail?

There is a 16k limit to what you can store in the registry. Is it possible that you're exceeding that? If you're signing all of your channels with the same key, that 16k is shared across every channel that uses that key.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
destruk
Streaming Star

Re: Anyone seen a save registry value fail?

Thanks again TheEndless. Can I suggest that the Flush() command for the registry writing return some kind of optional message on failure? For now I have to write, then flush, then give it some time, and then try to read back the value that was supposed to be written to check if it exists or not.
0 Kudos
RokuMarkn
Visitor

Re: Anyone seen a save registry value fail?

Flush() returns a boolean indicating success.

--Mark
0 Kudos
destruk
Streaming Star

Re: Anyone seen a save registry value fail?

Thanks RokuMark! doh...yeah the component reference says that... sorry.
0 Kudos