I am writing a game for Roku using the roScreen and for some reason it seems that the Roku 3 I am testing on is locked to 20 fps. The thing that is really confusing is that the same game runs at more then 60fps on a Roku 2. What could be going on here that is making my frame rate so low on the Roku 3 when it should be a higher preforming device then the Roku 2?
You probably would have to share some source. If you don’t want to do that in the public forum, please email developer@roku.com with a sample app (in .zip format, not a .pkg) that shows the issue, so we can investigate.
- Joel
Depends on which Roku 3 and Roku 2 you are talking about as well - they might be the same!
This first thing I’m suspicious about is your use of a timed wait. Generally this isn’t a safe thing to do for animation, and the behavior could be different on different Roku models. You should probably use GetMessage() instead. See the discussion under “Game scripts” in https://sdkdocs.roku.com/display/sdkdoc/Event+Loops
–Mark
Yes, as Mark points out best not to use wait if you need a high framerate. On the Roku 2 XS and related chipsets there is actually a bug that makes wait take an inconsistent amount of time to complete. Not sure why that would give you higher performance, usually it is the opposite effect.
I would suggest using message=port.getmessage() and if you want to execute on a timeframe, then use roTimeSpan to trigger action at the millisecond count you want:
if mytimer.totalmilliseconds() >=m.timerManager.handleTimers() then
msg=port.getmessage()
doStuff()
timer.mark()
end if
So I just switched from using wait() to using roMessagePort.getMessage() but it seems that getMessage() never returns roSocket events.
I though that doing getMessage() was the same thing as wait(1, port) but faster, is this not the case?
“boomAlex” wrote:
So I just switched from using wait() to using roMessagePort.getMessage() but it seems that getMessage() never returns roSocket events.I though that doing getMessage() was the same thing as wait(1, port) but faster, is this not the case?
We noticed that too for events for roStreamSocket, but not for roDatagramSocket. We ended up using wait(1, port) for the roSocketPorts and GetMessage() for the others. This required using multiple ports, but processing them in a global loop.
At first we used wait(1, port) due to the missing events, but we noticed the Roku would intermittently wait 5000ms on every Roku model we tested, and only seemed to affect the message events for roDatagramSocket. Maybe this is what RokuMarkn was referring to.
“malort” wrote:
but we noticed the Roku would intermittently wait 5000ms on every Roku model we tested
Hmm not seeing this. What devices are you testing?
sub main()
screen=createobject("roScreen")
port=createobject("roMessagePort")
screen.setmessageport(port)
timer=createobject("roTimeSpan")
timer.mark()
while true
timer.mark()
msg=wait(1,port)
?timer.totalmilliseconds()
end while
end sub
Also, for things like roStreamSockets, probably best not to share a port (not saying you are doing this) with any other components like the screen - give it its own port.
- Joel
After some testing I figured out that my problem was that I was calling GetDefaultFont() in my while loop and that was killing my frame rate, now that I am storing the default font I am getting over 100 fps.
I still find it odd that it was running so much faster on the Roku 2 though.
