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: 
GandK-Geoff
Visitor

BUG: roBitmap creation silently fails for non-integer types

This fails silently (just returns Invalid) if size is not an Integer (even if it has no fractional part):

CreateObject("roBitmap", { width: size, height: size })


I discovered this by trying to create a bitmap 1/4 the size of a previous power-of-2-sized bitmap by simply dividing each dimension by 2. Unfortunately that means the result was a floating point type, rather than the integer type I started with -- and the type change gave roBitmap's constructor indigestion.

All of which would have been no problem at all, and an easy fix. Except that CreateObject() failed silently (just returning Invalid, the same as when there is no more video memory available), and it took an extended debugging session to find the bug, because I had no idea what had gone wrong.

Can CreateObject("roBitmap", ...) please throw an exception, or at least print a warning to console, when its arguments are the wrong type?
0 Kudos
2 REPLIES 2

Re: BUG: roBitmap creation silently fails for non-integer ty

Not a solution to the problem you've posted, but something that may help. Whenever I'm creating an roBitmap I do a check for invalid as follows:


bmp = CreateObject("roBitmap", "pkg:/file.jpg")
if bmp = invalid then
print "Unable to create bitmap."
stop
end if


It's somewhat like catching an exception, and it may save you some frustration in troubleshooting.
0 Kudos
GandK-Geoff
Visitor

Re: BUG: roBitmap creation silently fails for non-integer ty

"RyanMarquiste" wrote:
Not a solution to the problem you've posted, but something that may help. Whenever I'm creating an roBitmap I do a check for invalid ... It's somewhat like catching an exception, and it may save you some frustration in troubleshooting.


Sure ... and I'm checking for create failures as well. My problem is that when there is a failure, there's no way to tell why it happened -- even something as coarse as knowing if it was invalid inputs (like my wrong argument types) or a system failure (like running out of video memory). My frustration came from expecting one error class and getting the other ... and not even because of a static type failure, but a dynamic type failure caused by an unexpectedly morphing variable, so the problem didn't occur every time.
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.