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.
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Freeze when Ads exit

Hello there,

I m having an issue with my roku channel:

I have a rowlist with a custom component, let's call it RowlistComponent.xml and brs, that usually take less than 40ms to render.

When you select an item, it brings you to a detail screen and from there you can play a video. When playing a video, you get a preroll ad, that I play with show_ads().

The issue is that when the ad is finished, and the RAF player gets dismissed, cells from the rowlist (that is not even visible at this point) get redrawn and this time the channel hangs for 10-12 seconds because cells each take 1.6-2 seconds to be drawn.
To be clear, if my rowlist does not have a custom component (.itemComponentName), there is no lag.

Is there a known issue, or a workaround that would allow me to fix this lag?
0 Kudos

Re: Freeze when Ads exit

I've learned that custom components can take a long time to create if not handled carefully.  I'd recommend looking at what you are doing in the init() method of the custom component, and also the dependency tree of that custom component since it has to recursively create all its child components as well.
0 Kudos

Re: Freeze when Ads exit

That's the thing, normally rendering a cell, including init, layout, oncontentChange... takes roughly 50ms. 
But it takes 1.6 seconds when exiting an ad. I m not even  sure why it's recreating the cell after exiting the ad player?
0 Kudos

Re: Freeze when Ads exit

As a note, I have commented out everything in my custom component. It now  has no children, the init does nothing, the updateLayout() does nothing

MyComponent.brs is this : 

function itemContentChanged()
    print "Cell content changed "
end function

function init()
    print "Init rowlist Cell"
end function

and the xml is this

<?xml version="1.0" encoding="utf-8" ?> 
<component name="RowListTitleAndSubtitle" extends="Group">
  <field id="width" type="float" /> 
  <field id="height" type="float" /> 
  <field id="index" type="int" />
  <field id="rowIndex" type="int" />
  <field id="itemContent" type="node" onChange="itemContentChanged"/> 
  <field id="focusPercent" type="float" onChange="focusPercentChanged"/> 
  <field id="rowFocusPercent" type="float" />
  <field id="rowHasFocus" type="bool" />
  <field id="rowListHasFocus" type="bool" onChange="focusPercentChanged" />

<script type="text/brightscript" uri="pkg:/components/RowListTitleAndSubtitle.brs"/>

and still, when recreating those empty cells, it takes 1.6, 2 seconds for each of them When the RAF Player is exiting. Any idea what might cause this?
0 Kudos

Re: Freeze when Ads exit

I can only speculate and give you things to try out.  

1) Be sure that you are differentiating between time executing brightscript and time waiting for images to download.  It looks like you have already done this by making your custom component and empty group.
2) remove the onChange from the fields.  The number of observer callbacks invoked can cause overhead, and especially so if you have a particularly large number of BRS objects or SG components in memory.
3) RAF needs memory for video cache and will probably affect downloaded images which may be purged during ad playback.  
4) You should put a print statement in all of your functions so that you can see in real time what is happening.  a timestamp in these print statements would be helpful too.
5) Be aware of the total system resource and what other threads may be doing.  After RAF ad break ends, if you have a Task thread running or main brightscript thread doing work then it will take away from SG UI thread CPU resources.
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.