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

roku not loading images

Hi, i'm having problems loading images, both on canvas component and using both getfile and asyncgetfile.

The canvas component doesnt show the images (sometimes) and the async/getfile finishes loading, but when i try to get the local file it doesn't exist

There is a very erratic behavior, and after some tests i think it has got to do with image size (px/kb) and simoultaneous loading.

I started a java tomcat to use as proxy and monitor the image urls to be loaded by the canvas component. At first i started returning big images (2000x200 px 3Mb) created on the fly, and these loaded fine, until i started changing the images fast, and i started getting a connection reset by peer (roku) in the server, that could be one of the problems.

any ideas?

thanks!
0 Kudos
16 REPLIES 16
RokuJoel
Binge Watcher

Re: roku not loading images

I assume you are saving the files to tmp:/filename

so are you downloading multiple images to separate file names, or are you overwriting the image every time? You might want to grab a series, and then if you need to cleanup the tmp:/ area remove the oldest file.

The imageCanvas function is pretty slow to update, updates around 100 - 150 milliseconds. So Update, wait a bit, then update again.

For faster image rendering use roScreen instead of image canvas (of course this depends on what you are trying to accomplish).

- Joel
0 Kudos
bmn
Visitor

Re: roku not loading images

Thanks joel, i've been doing some more research on these images using firebug and loading them with js and html, and i got an http 302 status from the image and then it redirects to another url retrieveing the image.

How does roku handle http 302?

thanks!!
0 Kudos
bmn
Visitor

Re: roku not loading images

Joel, I tried using roScreen, but found no reference to it in the documentation, also i think it does not support the same methods roImageCanvas has...

ideas?

thanks!
0 Kudos
renojim
Community Streaming Expert

Re: roku not loading images

roScreen is in the Brightscript reference.

-JT
Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
0 Kudos
RokuJoel
Binge Watcher

Re: roku not loading images

"bmn" wrote:
Thanks joel, i've been doing some more research on these images using firebug and loading them with js and html, and i got an http 302 status from the image and then it redirects to another url retrieveing the image.

How does roku handle http 302?

thanks!!


There's a resolveRedirect function in the MRSS template, see if that will work for you.

- Joel
0 Kudos
bmn
Visitor

Re: roku not loading images

Joel thanks for your reply! but i stil couldnt load...

ahttp=CreateObject("roUrlTransfer")
ahttp.EnableEncodings(true)

ahttp.AddHeader("user-agent", "Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543 Safari/419.3")
'ahttp.SetUrl(url)

port = CreateObject("roMessagePort")
ahttp.setPort(port)
result = invalid

done = false

while not done
ahttp.SetURL(url)
result = ahttp.AsyncGetToFile(filename)
if ahttp.AsyncHead()
while true
msg = wait(10000, ahttp.GetPort())

if msg <> invalid
h = msg.GetResponseHeaders()
PrintAA(h)
if ValidStr(h.location) <> ""
result = ValidStr(h.location)
else
done = true
end if
else
done = true
end if
exit while
end while
else
done = true
end if


end while
print "IMAGE LOADED TO FILE"
return result

the print image loaded to file appears, but when i check for the file it isnt there...

is the code i wrote correct? any more ideas?

thanks!!
0 Kudos
bmn
Visitor

Re: roku not loading images

Joel, shouldnt the Canvas SetLayer handle this images well? I mean shouldt the component handle the 302 message?

I'm really out of ideas here...
0 Kudos
bmn
Visitor

Re: roku not loading images

Joel got more crazy things now..

I started getting a 403 error now, not the 302 firefox received... so I changed the code to get the headers, i got to the target and then i should recall the thing again..

the problem is i am getting status 200 now, it just returns crazy values! could it be cache?

port = CreateObject("roMessagePort")
ahttp.setPort(port)
result = invalid
result = ahttp.AsyncGetToFile(filename)
while true
msg = wait(100, ahttp.GetPort())
if type(msg)="roUrlEvent"
print "status code"
print msg.GetResponseCode()
if msg.GetResponseCode() = 403 then
headers=msg.GetResponseHeadersArray()
for each h in headers
if h.Location <> invalid
url=h.Location
goto start
end if
next
exit while
end if
if msg.GetResponseCode() = 200 then
exit while
end if
end if
end while
0 Kudos
bmn
Visitor

Re: roku not loading images

I managed to get the Target header, which was returned in the 403 http error, this header contains the path to the image, i tried loading that image, and even though the http status is 200,the image is not shown...

Why could this happen?
0 Kudos