Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
greubel
Level 7

SG objects slow with Brightscript

Having trouble generating SG objects from Brightscript. It's taking upwards of 15 seconds to generate and display a screen. I tried to can a screen using XML but that only reduced the time to 7 seconds because of all the fields that need to be modified before final display.

   g = CreateObject("roSGNode", "Group")
   g.visible = false
   g.translation = [ X, Y ]

   r = CreateObject("roSGNode", "Rectangle")
   r.translation = [ 0, 0 ]
   r.width = XR(325)
   r.height = YR(60)
   r.color = "0x000000FF"
   g.appendChild(r)

   p = CreateObject("roSGNode", "Poster")
   p.translation = [ 2, 2 ]
   p.width = XR(325)-4
   p.height = YR(60)-4
   p.uri = theme.Button_Off_Image
   r.appendChild(p)

   p = CreateObject("roSGNode", "Poster")
   p.visible = true
   p.uri = invalid
   p.width = YR(60)-9
   p.height = YR(60)-9
   p.translation = [ XR(4), YR(3) ]
   r.appendChild(p)

   l = CreateObject("roSGNode", "Label")
   l.translation = [ XR(55)+2, YR(0)+2 ]
   l.font = "font:LargeBoldSystemFont"
   l.font.size = 40
   l.visible = true
   l.text = ""
   l.color = "0x000000FF"
   l.height = YR(65)
   l.horizAlign = "left"
   l.vertAlign = "center"
   r.appendChild(l)

   l = CreateObject("roSGNode", "Label")
   l.translation = [ XR(55), YR(0) ]
   l.font = "font:LargeBoldSystemFont"
   l.font.size = 40
   l.visible = true
   l.text = ""
   l.color = "0xFFFFFFFF"
   l.height = YR(65)
   l.horizAlign = "left"
   l.vertAlign = "center"
   r.appendChild(l)

   l = CreateObject("roSGNode", "Label")
   l.visible = true
   l.text = "."
   l.color = "0x00FF00FF"
   l.translation = [ XR(315), 20 ]
   l.font = "font:LargeBoldSystemFont"
   l.font.size = 40
   l.horizAlign = "center"
   l.vertAlign = "center"
   r.appendChild(l)

   l = CreateObject("roSGNode", "Label")
   l.visible = true
   l.text = ""
   l.color = "0x000000FF"
   l.translation = [ XR(40), YR(47) ]
   l.font = "font:LargeBoldSystemFont"
   l.font.size = YR(10)
   l.width = XR(282)
   l.horizAlign = "right"
   l.vertAlign = "bottom"
   r.appendChild(l)


Here is a dump of the total structure
*   type = Group ID = List visible = false x 0 y 0
*     type = Group ID =  visible = true x 8 y 30
*       type = Group ID =  visible = false x 44 y 60
*         type = Rectangle ID =  visible = true x 0 y 0 w 577 h 90
*           type = Poster ID =  visible = true x 2 y 2 w 573 h 86 url = tmp:/Theme/Default/OffSlice.jpg
*           type = Poster ID =  visible = true x 7 y 4 w 57 h 82 url = http://192.168.1.2:12000/Roku/DVD/A%20Quiet%20Place.jpg
*           type = Label ID =  visible = true x 99 y 2 w 0 h 97 Text = A Quiet Place
*           type = Label ID =  visible = true x 97 y 0 w 0 h 97 Text = A Quiet Place
*           type = Label ID =  visible = true x 560 y 20 w 0 h 0 Text = .
*           type = Label ID =  visible = true x 71 y 70 w 501 h 0 Text = MP4 722x304 HD 1:30:10
*       type = Group ID =  visible = false x 640 y 60
*         type = Rectangle ID =  visible = true x 0 y 0 w 577 h 90
*           type = Poster ID =  visible = true x 2 y 2 w 573 h 86 url = tmp:/Theme/Default/OffSlice.jpg
*           type = Poster ID =  visible = true x 7 y 4 w 82 h 82 url = tmp:/Theme/Default/video.png
*           type = Label ID =  visible = true x 99 y 2 w 0 h 97 Text = I Feel Pretty
*           type = Label ID =  visible = true x 97 y 0 w 0 h 97 Text = I Feel Pretty
*           type = Label ID =  visible = true x 560 y 20 w 0 h 0 Text = .
*           type = Label ID =  visible = true x 71 y 70 w 501 h 0 Text = MP4 722x302 HD 1:50:53
*       type = Group ID =  visible = false x 44 y 165
*         type = Rectangle ID =  visible = true x 0 y 0 w 577 h 90
*           type = Poster ID =  visible = true x 2 y 2 w 573 h 86 url = tmp:/Theme/Default/OnSlice.jpg
*           type = Poster ID =  visible = true x 7 y 4 w 57 h 82 url = http://192.168.1.2:12000/Roku/DVD/Rampage.jpg
*           type = Label ID =  visible = true x 99 y 2 w 0 h 97 Text = Rampage
*           type = Label ID =  visible = true x 97 y 0 w 0 h 97 Text = Rampage
*           type = Label ID =  visible = true x 560 y 20 w 0 h 0 Text = .
*           type = Label ID =  visible = true x 71 y 70 w 501 h 0 Text = MP4 722x304 HD 1:47:11
*       type = Group ID =  visible = false x 640 y 165
*         type = Rectangle ID =  visible = true x 0 y 0 w 577 h 90
*           type = Poster ID =  visible = true x 2 y 2 w 573 h 86 url = tmp:/Theme/Default/OffSlice.jpg
*           type = Poster ID =  visible = true x 7 y 4 w 81 h 81 url =
*           type = Label ID =  visible = true x 99 y 2 w 0 h 97 Text =
*           type = Label ID =  visible = true x 97 y 0 w 0 h 97 Text =
*           type = Label ID =  visible = true x 560 y 20 w 0 h 0 Text = .
*           type = Label ID =  visible = true x 71 y 70 w 501 h 0 Text =
*       type = Group ID =  visible = false x 44 y 270
*         type = Rectangle ID =  visible = true x 0 y 0 w 577 h 90
*           type = Poster ID =  visible = true x 2 y 2 w 573 h 86 url = tmp:/Theme/Default/OffSlice.jpg
*           type = Poster ID =  visible = true x 7 y 4 w 81 h 81 url =
*           type = Label ID =  visible = true x 99 y 2 w 0 h 97 Text =
*           type = Label ID =  visible = true x 97 y 0 w 0 h 97 Text =
*           type = Label ID =  visible = true x 560 y 20 w 0 h 0 Text = .
*           type = Label ID =  visible = true x 71 y 70 w 501 h 0 Text =
*       type = Group ID =  visible = false x 640 y 270
*         type = Rectangle ID =  visible = true x 0 y 0 w 577 h 90
*           type = Poster ID =  visible = true x 2 y 2 w 573 h 86 url = tmp:/Theme/Default/OffSlice.jpg
*           type = Poster ID =  visible = true x 7 y 4 w 81 h 81 url =
*           type = Label ID =  visible = true x 99 y 2 w 0 h 97 Text =
*           type = Label ID =  visible = true x 97 y 0 w 0 h 97 Text =
*           type = Label ID =  visible = true x 560 y 20 w 0 h 0 Text = .
*           type = Label ID =  visible = true x 71 y 70 w 501 h 0 Text =
*       type = Group ID =  visible = false x 44 y 375
*         type = Rectangle ID =  visible = true x 0 y 0 w 577 h 90
*           type = Poster ID =  visible = true x 2 y 2 w 573 h 86 url = tmp:/Theme/Default/OffSlice.jpg
*           type = Poster ID =  visible = true x 7 y 4 w 81 h 81 url =
*           type = Label ID =  visible = true x 99 y 2 w 0 h 97 Text =
*           type = Label ID =  visible = true x 97 y 0 w 0 h 97 Text =
*           type = Label ID =  visible = true x 560 y 20 w 0 h 0 Text = .
*           type = Label ID =  visible = true x 71 y 70 w 501 h 0 Text =
*       type = Group ID =  visible = false x 640 y 375
*         type = Rectangle ID =  visible = true x 0 y 0 w 577 h 90
*           type = Poster ID =  visible = true x 2 y 2 w 573 h 86 url = tmp:/Theme/Default/OffSlice.jpg
*           type = Poster ID =  visible = true x 7 y 4 w 81 h 81 url =
*           type = Label ID =  visible = true x 99 y 2 w 0 h 97 Text =
*           type = Label ID =  visible = true x 97 y 0 w 0 h 97 Text =
*           type = Label ID =  visible = true x 560 y 20 w 0 h 0 Text = .
*           type = Label ID =  visible = true x 71 y 70 w 501 h 0 Text =
*       type = Group ID =  visible = false x 44 y 480
*         type = Rectangle ID =  visible = true x 0 y 0 w 577 h 90
*           type = Poster ID =  visible = true x 2 y 2 w 573 h 86 url = tmp:/Theme/Default/OffSlice.jpg
*           type = Poster ID =  visible = true x 7 y 4 w 81 h 81 url =
*           type = Label ID =  visible = true x 99 y 2 w 0 h 97 Text =
*           type = Label ID =  visible = true x 97 y 0 w 0 h 97 Text =
*           type = Label ID =  visible = true x 560 y 20 w 0 h 0 Text = .
*           type = Label ID =  visible = true x 71 y 70 w 501 h 0 Text =
*       type = Group ID =  visible = false x 640 y 480
*         type = Rectangle ID =  visible = true x 0 y 0 w 577 h 90
*           type = Poster ID =  visible = true x 2 y 2 w 573 h 86 url = tmp:/Theme/Default/OffSlice.jpg
*           type = Poster ID =  visible = true x 7 y 4 w 81 h 81 url =
*           type = Label ID =  visible = true x 99 y 2 w 0 h 97 Text =
*           type = Label ID =  visible = true x 97 y 0 w 0 h 97 Text =
*           type = Label ID =  visible = true x 560 y 20 w 0 h 0 Text = .
*           type = Label ID =  visible = true x 71 y 70 w 501 h 0 Text =
*     type = Poster ID = up visible = false x 44 y 37 w 15 h 30 url = tmp:/Theme/Default/up.png
*     type = Poster ID = dn visible = false x 44 y 622 w 15 h 30 url = tmp:/Theme/Default/down.png
*     type = Group ID = hdr visible = true x 0 y 0
*       type = Label ID =  visible = true x 2 y 12 w 1280 h 90 Text = DVD
*       type = Label ID =  visible = true x 0 y 10 w 1280 h 90 Text = DVD
*     type = Group ID = bot visible = true x 0 y 0
*       type = Label ID =  visible = true x 2 y 624 w 1280 h 60 Text = Rampage
*       type = Label ID =  visible = true x 0 y 622 w 1280 h 60 Text = Rampage
* Dump Scene time  591
0 Kudos
1 Reply
Roku Employee
Roku Employee

Re: SG objects slow with Brightscript

i will take a guess that code is running in the main() thread or a task thread - from there setting/getting fields experiences rendezvous penalty with the render thread. Try doing that from the render thread, e.g. in the init() or other method of the scene (or other visual node, i.e. Group subclass) and field access will be toll-free
0 Kudos