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: 
JordanT92
Visitor

Performance of roScreen

Hello, I'm developing my first app using roScreen the ifDraw2D components, the built-in roku search screen doesn't quite suit my needs so I'm currently designing the search screen of my app. I want this to be quick and snappy to navigate and search, I've designed the keyboard using a basic layout and below it, it will display results grapped asynchronously while you're inputting. Are there any tips I can use to increase performance as right now it seems the navigation is a tad behind and I haven't added the asynchronous search features yet. Does getting the date and time every time I draw a frame have any noticeable effect on performance?



Strangely the episode page runs faster, I guess not having to draw the alphabet of squares improves performance..?


Any tips or hints would be great!

Many thanks, Jordan.
0 Kudos
12 REPLIES 12
Komag
Roku Guru

Re: Performance of roScreen

What Roku model number are you using? Text and alpha transparency are a couple things that hurt performance a lot in general. I don't know the impact of getting the date and time.

You might set up a test function to make a timer, get the date and time 100 or 1000 times, then print the timer results. I've used this approach on lots of functions to really tell me how long it's taking for various things, and it can be eye opening at times.
0 Kudos
TheEndless
Channel Surfer

Re: Performance of roScreen

I wouldn't expect grabbing the time to impact performance, but it should be an easy test. Have you commented that part out to see if performance improves?

There's nothing on that keyboard screen that I'd expect to cause any performance issues, so my guess is there's something in your code that's causing the problems. Are you caching and re-using the font? Initializing a font is pretty slow, so if you're not re-using it, that could definitely be the issue.

On a side note, that's a nice, clean layout. I like it!
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
JordanT92
Visitor

Re: Performance of roScreen

"Komag" wrote:
What Roku model number are you using? Text and alpha transparency are a couple things that hurt performance a lot in general. I don't know the impact of getting the date and time.

You might set up a test function to make a timer, get the date and time 100 or 1000 times, then print the timer results. I've used this approach on lots of functions to really tell me how long it's taking for various things, and it can be eye opening at times.

I'm using a Roku 1 (2710) and a Now TV box (2400), the Now TV box obliterates the Roku 1 for performance, the 1 tends to be very jittery and low fps whereas the Now TV box is pretty smooth. That's a really good idea, I'll start testing the speed on some of my functions to see if any can be optomised, and think about adding a FPS counter to my screens too. They aren't running slow by any measure, it all runs quite well actually, but it just feels that the default roku screen can navigate from letter to letter faster than my screen, but I guess the transparency plays a part in that... Thank you!

"TheEndless" wrote:
I wouldn't expect grabbing the time to impact performance, but it should be an easy test. Have you commented that part out to see if performance improves?

There's nothing on that keyboard screen that I'd expect to cause any performance issues, so my guess is there's something in your code that's causing the problems. Are you caching and re-using the font? Initializing a font is pretty slow, so if you're not re-using it, that could definitely be the issue.

On a side note, that's a nice, clean layout. I like it!

Yes I've tried that, but the results are negligible really, I was only concerned about the date and time as the rest of the code is pretty straight-forward and couldn't be done in any other way, so even if some draw function does affect performance, there's nothing I can do about that. With the date and time, I have it set up so the date & time are grabbed at startup, the offset in seconds is then used as a reference point for roTimespan which marks every frame. So at 10:04:33, it waits 27 seconds then grabs the date & time again, then again every 60 seconds from that point for accuracy. Do you think this would be faster than getting the roDateTime every frame?

Font's are initalised on startup and sizes are allocated to an array, so I have obj.Font.Calibri.p16, which is Calibri 16pt (~22px). I'll go through my code and move out anything that could be initalised at startup to maximize performance.

Thank you very much! It's a redesign of my current app, I'm having an issue with roGridScreen where the focused item flickers back and forth between two items randomly and I can't find any way to stop it, so I'm redesigning it from scratch using roScreen. A lot of work it seems! But I'm getting there....
0 Kudos
TheEndless
Channel Surfer

Re: Performance of roScreen

"JordanT92" wrote:
They aren't running slow by any measure, it all runs quite well actually, but it just feels that the default roku screen can navigate from letter to letter faster than my screen

FWIW, with the built-in SDK screens, the UI runs in a separate thread from the BrightScript code, so it'll be smoother, by default, especially on slower boxes. I wouldn't get too hung up on matching performance on the Roku 1 box. You'll be hard pressed to get there on any of the 27XX boxes with a lot of elements on the screen. Assuming each key on the keyboard is a separate bitmap, if you cached the whole keyboard to a single bitmap first instead of drawing each key individually each frame, and only updated the highlighted key, that would likely help a lot.

"JordanT92" wrote:
Thank you very much! It's a redesign of my current app, I'm having an issue with roGridScreen where the focused item flickers back and forth between two items randomly and I can't find any way to stop it, so I'm redesigning it from scratch using roScreen. A lot of work it seems! But I'm getting there....

There was a bug in the 6.0 and 6.1 firmware that caused the grid screen focused index to jump around when returning to the screen. I don't know if that's what you were experiencing or not, but I believe it was fixed in 6.2.
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
JordanT92
Visitor

Re: Performance of roScreen

"TheEndless" wrote:
"JordanT92" wrote:
They aren't running slow by any measure, it all runs quite well actually, but it just feels that the default roku screen can navigate from letter to letter faster than my screen

FWIW, with the built-in SDK screens, the UI runs in a separate thread from the BrightScript code, so it'll be smoother, by default, especially on slower boxes. I wouldn't get too hung up on matching performance on the Roku 1 box. You'll be hard pressed to get there on any of the 27XX boxes with a lot of elements on the screen. Assuming each key on the keyboard is a separate bitmap, if you cached the whole keyboard to a single bitmap first instead of drawing each key individually each frame, and only updated the highlighted key, that would likely help a lot.

"JordanT92" wrote:
Thank you very much! It's a redesign of my current app, I'm having an issue with roGridScreen where the focused item flickers back and forth between two items randomly and I can't find any way to stop it, so I'm redesigning it from scratch using roScreen. A lot of work it seems! But I'm getting there....

There was a bug in the 6.0 and 6.1 firmware that caused the grid screen focused index to jump around when returning to the screen. I don't know if that's what you were experiencing or not, but I believe it was fixed in 6.2.


That's good to know! I'm surprised at how well the Now TV Box runs it to be honest, my screens will never get too crowded as I'm going for a more simplistic approach. Currently some items are drawn off screen and scroll into view later, I'll ensure they're only drawn when in the bounding box of the screen and I think the performance on most screens will be pretty decent then, even on the lower end boxes. For the Roku 1, i think disabling animation altogether may be the only way to go... I'm running the latest version (no choice of course) and it still happens, although this is a grid with 11,000+ item (any items out of view are set to invalid).

My next questions is... To speed things up from a data standpoint, I want my app to download a ZIP / JSON file on startup, and use that as the central database for everything, so the only time any network activity would occur is when grabbing images. The only problem is, this file is likely to be around the 20MB mark... Do you think the boxes would be alright with this if I limit playback to 720p? Or would I run out of memory? I can't seem to find a way of getting my current memory usage...

Thank you very much TheEndless!
0 Kudos
TheEndless
Channel Surfer

Re: Performance of roScreen

"JordanT92" wrote:
That's good to know! I'm surprised at how well the Now TV Box runs it to be honest, my screens will never get too crowded as I'm going for a more simplistic approach. Currently some items are drawn off screen and scroll into view later, I'll ensure they're only drawn when in the bounding box of the screen and I think the performance on most screens will be pretty decent then, even on the lower end boxes. For the Roku 1, i think disabling animation altogether may be the only way to go... I'm running the latest version (no choice of course) and it still happens, although this is a grid with 11,000+ item (any items out of view are set to invalid).

Sorry, I was specifically referring to the keyboard screen. If every key is being drawn separately, that means you're drawing 38 separate keys on each pass, with 38 separate calls to DrawText. If you drew the whole thing to a bitmap first, then just updated the focus rect on each frame, that would likely significantly improve performance. There's no reason you shouldn't be able to do animation on the Roku 1 for that screen.

"JordanT92" wrote:
My next questions is... To speed things up from a data standpoint, I want my app to download a ZIP / JSON file on startup, and use that as the central database for everything, so the only time any network activity would occur is when grabbing images. The only problem is, this file is likely to be around the 20MB mark... Do you think the boxes would be alright with this if I limit playback to 720p? Or would I run out of memory? I can't seem to find a way of getting my current memory usage...

Yeesh.. I don't know how that would work out for you. 20MB may be too large for tmp: storage. That should be independent of graphics and video memory, though.
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
belltown
Roku Guru

Re: Performance of roScreen

"JordanT92" wrote:
I can't seem to find a way of getting my current memory usage...


For some reason, Roku doesn't want you to know anything about memory usage. You can, however, use the r2d2_bitmaps command, issued to port 8080 to get some information about memory usage (at least for your bitmaps).

If you wish to access that information programmatically, it's possible although rather kludgy, e.g:

Sub Main ()
memstats = new_MemStats ()
stats = memstats.Stats ()
Print stats
bm = CreateObject ("roBitmap", {Width:1000, Height:1000, AlphaEnable: False})
stats = memstats.Stats ()
Print stats
bm1 = CreateObject ("roBitmap", {Width:1000, Height:1000, AlphaEnable: False})
stats = memstats.Stats ()
Print stats
memstats.Close ()
End Sub

Function new_MemStats () As Object
this = {}

this.re = CreateObject ("roRegex", "memory (\d+) used (\d+)", "")
this.port = CreateObject ("roMessagePort")
this.sa = CreateObject ("roSocketAddress")
If Not this.sa.SetAddress ("127.0.0.1:8080")
Print "SetAddress Failed"
Return Invalid
EndIf
this.ss = CreateObject ("roStreamSocket")
If Not this.ss.SetSendToAddress (this.sa)
Print "SetSendToAddress Failed"
Return Invalid
EndIf
this.ss.SetMessagePort (this.port)
crlf = Chr (13) + Chr (10)
this.r2d2_bitmaps = "r2d2_bitmaps" + crlf
this.quit = "quit" + crlf
this.prompt = crlf + ">"
If this.ss.Connect ()
this.ss.ReceiveStr (1024)
Else
Print "Connection Error: "; this.ss.Status ()
Return Invalid
EndIf

this.Stats = Function () As Object
m.ss.SendStr (m.r2d2_bitmaps)
rsp = ""
While True
rsp = rsp + m.ss.ReceiveStr (1024)
If Len (rsp) < 3 Or Right (rsp, 3) = m.prompt
Exit While
EndIf
End While
ma = m.re.Match (rsp)
If ma.Count () = 3
Return {avail: ma [1], used: ma [2]}
Else
Return {avail: 0, used: 0}
EndIf
End Function

this.Close = Function () As Void
m.ss.SendStr (m.quit)
m.ss.Close ()
End Function

Return this
End Function
0 Kudos
JordanT92
Visitor

Re: Performance of roScreen

"TheEndless" wrote:
"JordanT92" wrote:
That's good to know! I'm surprised at how well the Now TV Box runs it to be honest, my screens will never get too crowded as I'm going for a more simplistic approach. Currently some items are drawn off screen and scroll into view later, I'll ensure they're only drawn when in the bounding box of the screen and I think the performance on most screens will be pretty decent then, even on the lower end boxes. For the Roku 1, i think disabling animation altogether may be the only way to go... I'm running the latest version (no choice of course) and it still happens, although this is a grid with 11,000+ item (any items out of view are set to invalid).

Sorry, I was specifically referring to the keyboard screen. If every key is being drawn separately, that means you're drawing 38 separate keys on each pass, with 38 separate calls to DrawText. If you drew the whole thing to a bitmap first, then just updated the focus rect on each frame, that would likely significantly improve performance. There's no reason you shouldn't be able to do animation on the Roku 1 for that screen.

That worked well! Seems to run much smoother now I'm only drawing the keyboard as a single image. Still not looking quite how I envisioned but it's getting there!



"TheEndless" wrote:
"JordanT92" wrote:
My next questions is... To speed things up from a data standpoint, I want my app to download a ZIP / JSON file on startup, and use that as the central database for everything, so the only time any network activity would occur is when grabbing images. The only problem is, this file is likely to be around the 20MB mark... Do you think the boxes would be alright with this if I limit playback to 720p? Or would I run out of memory? I can't seem to find a way of getting my current memory usage...

Yeesh.. I don't know how that would work out for you. 20MB may be too large for tmp: storage. That should be independent of graphics and video memory, though.


Good point... I didn't think about TMP storage limits. Does anyone know the limit? I remember reading it somewhere but can't seem to find it anymore.

"belltown" wrote:
"JordanT92" wrote:
I can't seem to find a way of getting my current memory usage...


For some reason, Roku doesn't want you to know anything about memory usage. You can, however, use the r2d2_bitmaps command, issued to port 8080 to get some information about memory usage (at least for your bitmaps).

If you wish to access that information programmatically, it's possible although rather kludgy, e.g:

truncated...

That's some useful information right there! I'll give that a go.

Thanks both.
0 Kudos
TheEndless
Channel Surfer

Re: Performance of roScreen

"JordanT92" wrote:
"belltown" wrote:
"JordanT92" wrote:
I can't seem to find a way of getting my current memory usage...

For some reason, Roku doesn't want you to know anything about memory usage. You can, however, use the r2d2_bitmaps command, issued to port 8080 to get some information about memory usage (at least for your bitmaps).

If you wish to access that information programmatically, it's possible although rather kludgy, e.g:

truncated...

That's some useful information right there! I'll give that a go.

Thanks both.

Note that port 8080 and the r2d2_bitmaps command are only available if dev mode is enabled on the box, so you can only use this for development purposes. As such, I'm not sure how helpful it would be to code it into the channel itself vs. just opening a telnet session on your dev machine and issuing the command manually.
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
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.