My channel is using a RowList with itemComponentName=“CItem” as given below, (based on CItem.xml from some Roku sample code.)
I am seeing on my channel dashboard, that rarely, but consistently, my channel crashes on line 70 of this xml file (about once for every 100 hours played). Unfortunately, the Roku dashboard does not provide any error message, only the line number. I have not been able to reproduce the issue on my own development setup.
The line that crashes is always m.Poster.height = height , and it is odd because the immediately preceding line m.Poster.width = width never crashes, and just preceding the two is a check that both variables height and width are strictly positive.
This issue has been nagging me for more than a year, and I have made the code increasingly defensive, to the point that you see now. Does anyone have an idea what could be the issue?
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2016 Roku Corp. All Rights Reserved. -->
<component name="CItem" extends="Group">
<children>
<Poster id="poster" loadDisplayMode="scaleToZoom"/>
<Rectangle id="overlay"
color="#FFFFFF"
opacity="0.6"
visible="false"/>
<Poster id="overlayicon" loadDisplayMode="scaleToZoom"
uri="pkg:/images/dk-flag201x150.png"
width="201"
height="150"
visible="false"/>
<Label id="label" font="font:SmallSystemFont" text=""
color="#383838"
maxLines="3"
wrap="true" horizAlign="left" />
<Rectangle id="progress"
color="#FF001E"
opacity="1"/>
<Rectangle id="progressbg"
color="#C9C9C9"
opacity="1"/>
<!--
<Label id="description" font="font:SmallBoldSystemFont" text="PLACEHOLDER" />
<Label id="sublabel" font="font:SmallBoldSystemFont" text="PLACEHOLDER" /> -->
</children>
<interface>
<field id="width" type="float" onChange="updateLayout"/>
<field id="height" type="float" onChange="updateLayout"/>
<field id="itemContent" type="node" onChange="itemContentChanged" />
<field id="labelColor" type="string" alias="label.color"/>
</interface>
<script type="text/brightscript">
<![CDATA[
sub Init()
m.Poster = m.top.findNode("poster")
m.Overlay = m.top.findNode("overlay")
m.OverlayIcon = m.top.findNode("overlayicon")
m.Label = m.top.findNode("label")
m.Progress = m.top.findNode("progress")
m.ProgressBg = m.top.findNode("progressbg")
end sub
sub itemContentChanged()
m.Label.text = m.top.itemcontent.Title
m.Overlay.visible = m.top.itemcontent.showRestrictedToDenmark
m.OverlayIcon.visible = m.top.itemcontent.showRestrictedToDenmark
if m.top.itemContent.Length > 0 and m.top.itemContent.lastPositionSec > 0 then
m.Progress.height = 9
m.ProgressBg.height = 9
else
m.Progress.height = 0
m.ProgressBg.height = 0
end if
updateLayout()
m.Poster.uri = m.top.itemContent.sdposterurl
end sub
sub updateLayout()
height = m.top.height
width = m.top.width
if height > 0 And width > 0 then
m.Poster.width = width
m.Poster.height = height <==== This is where the channel crashes
m.Overlay.width = width
m.Overlay.height = height
m.OverlayIcon.translation = [(width - 201) / 2, (height - 150) / 2]
m.Label.width = width - 18
m.Label.translation = [9, height + 15]
m.Progress.translation = [0, height - m.Progress.height]
if m.top.itemContent <> invalid and m.top.itemContent.Length > 0 and m.top.itemContent.lastPositionSec > 0 then
m.Progress.width = m.top.itemContent.lastPositionSec / m.top.itemContent.Length * m.top.width
end if
m.ProgressBg.translation = [m.Progress.width, height - m.Progress.height]
m.ProgressBg.width = width - m.Progress.width
end if
end sub
]]>
</script>
</component>
