Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Developer
Posts: 342
Registered: ‎09-28-2009
My Device: Not Specified
Accepted Solution

Drawing Speed

The current version of my game on the app market has a problem with low framerates. I've investigated, and have determined that the speed issues are caused by drawing stacked objects. Removing the background image resolved the issue on all levels except for those containing a sprite object that contains three shape objects which draw low opacity circles on top of each other. Having that sprite object only draw one circle at a time fixed the speed on those levels as well.

 

So the long and short if it is that performance seems to suffer greatly from drawing objects in a hierarchy. Is there any way to have a background image without losing so much performance? Thanks.

 

Developer
Posts: 146
Registered: ‎03-27-2011
My Device: Blackberry Playbook
My Carrier: WiFi

Re: Drawing Speed

The only way I have found to get decent framerates is using GPU rendering. Are you currently using CPU or GPU rendering? There are a number of drawbacks, but you will most likely see some good results by switching and optimizing your code a bit. Keep in mind, especially when using cacheAsBitcmap, that optimizations for the CPU won't necessary help when rendering using the GPU.

 

I have a scene with a moving background and 150-160 partially transparent sprites which are also moving. As well, the stage is listening for touch events. with GPU rendering, I can hold a steady 45-50 FPS, when I would get about 20 FPS on the CPU. Especially with the moving background, the whole screen must be redrawn every frame, and the CPU doesn't have the horsepower to keep up.

----------------------------------------
If this post solved your problem, please click the 'Accept as Solution' button.
If you found this post useful, please provide a Kudo. Thanks.

Approved Apps: Celestial Slingshot
Highlighted
Regular Contributor
Posts: 53
Registered: ‎04-28-2011
My Device: Playbook
My Carrier: Not Specified

Re: Drawing Speed

[ Edited ]

You could use blitting the images instead of a hierarchy, which is apparently a lot faster because only one object is added to the stage. You can find some great tutorials on this at http://gotoandlearn.com/:

http://gotoandlearn.com/play.php?id=140

http://gotoandlearn.com/play.php?id=14

http://gotoandlearn.com/play.php?id=14

 

 


Playbook App: Car Crash

Developer
Posts: 342
Registered: ‎09-28-2009
My Device: Not Specified

Re: Drawing Speed

Just to clarify, is this the correct way to enable GPU rendering?

blackberry-tablet.xml

<?xml version="1.0" encoding="UTF-8"?>

<qnx>
   <initialWindow>
      <systemChrome>none</systemChrome>
      <transparent>false</transparent>
      <renderMode>gpu</renderMode>
   </initialWindow>

   <author>daAutha</author>
   <authorId>daID</authorId>
   <publisher>daPublisha</publisher>
   <category>core.games</category>
   <splashscreen>daSplash.png</splashscreen>
</qnx>

 As for blitting, I've been hoping to avoid it, since it seems like alot of work for a negligible benefit (a background image) in this game, but I'll check it out. I just can't believe the PlayBook can't handle a handful of separate objects. I'll post back later.

Developer
Posts: 146
Registered: ‎03-27-2011
My Device: Blackberry Playbook
My Carrier: WiFi

Re: Drawing Speed

Joe, you should put it under your AppName-app.xml file, like so:

 

 

<initialWindow>
        <content>Whatever.swf</content>
        <autoOrients>false</autoOrients>
        <aspectRatio>landscape</aspectRatio>
        <renderMode>gpu</renderMode>

 

Make sure you have the right captialization as well.

 

----------------------------------------
If this post solved your problem, please click the 'Accept as Solution' button.
If you found this post useful, please provide a Kudo. Thanks.

Approved Apps: Celestial Slingshot
Developer
Posts: 113
Registered: ‎03-23-2011
My Device: Playbook, Z10
My Carrier: Platinumtel

Re: Drawing Speed

GoldenJoe,

 

From your other post I remember that you have an effect with a ring that scales up.  Unfortunately scaling is not supported with the GPU right now.  Basically objects that move only (no rotation, scaling, or shape-changing) are well-accelerated.  I'm sure it's still worth trying, but don't be too surprised if you don't notice a difference.

 

I do think that the GPU would help with your background image, though.    I haven't checked what the max image size is for the PlayBook GPU, but if it's still slow you could try splitting it up into 4 sections or so and adding those all to the display hierarchy as usual.

 

Perhaps the best way to understand what is accelerated on the GPU at the present time is to look through what you can do with a BitmapData object and what the limitations are, and that seems to correspond pretty well with what the GPU can do.  This may change in the future, though, since the typical GPU can do a lot more than what is available in flash.

----------------
WIP game: Melodaeum
My graphically bland but very useful Morse Code trainer: Speed CW
My graphically attractive but boring game: The Rainstorm
Developer
Posts: 342
Registered: ‎09-28-2009
My Device: Not Specified

Re: Drawing Speed

Aw, ****in'... putting it under [AppName]-app.xml sure made a difference! Well...I can put my background and layered "waves" back in without losing significant frames now. That's awesome. Strange, though...it seems to have a hiccup every so many seconds. Could garbage collection do that if I'm creating and destroying lots of objects?

 

The only thing of note is that one gradient filled line isn't displaying properly anymore. Certainly not a dealbreaker, just an interesting bug to note. All other gradient fills look good so far. I'll check it out tomorrow and let you know what I find. Thanks again, I had a feeling I should mention the name of the file I was putting the gpu tag in.

Developer
Posts: 113
Registered: ‎03-23-2011
My Device: Playbook, Z10
My Carrier: Platinumtel

Re: Drawing Speed

Yeah, garbage collection is by far the most likely culprit for occasional stuttering in a game.  I'd suggest creating a pool of objects ahead of time and reusing them.  There are lots of examples out there for how to do this, and here's one such example: http://lab.polygonal.de/2008/06/18/using-object-pools/

----------------
WIP game: Melodaeum
My graphically bland but very useful Morse Code trainer: Speed CW
My graphically attractive but boring game: The Rainstorm
BlackBerry Development Advisor
Posts: 172
Registered: ‎10-25-2010
My Device: Not Specified

Re: Drawing Speed

@GoldenJoe, Glad to here you got your framerate up. It sounds like you are using the drawing API's correct? lineTo, drawRect etc...

 

Well even with cacheAsBitmap and cacheAsBitmapMatrix you may see some slow downs. The drawing API can be slow, even in GPU mode, and Adobe advises against it for moblie. I would try to use PNG images if you can to see if that makes a difference at all.

BlackBerry Development Advisor
Posts: 172
Registered: ‎10-25-2010
My Device: Not Specified

Re: Drawing Speed

@cycletronic GPU mode does support scaling, rotating and alpha changes, but you will need to use cacheAsBitmapMatrix as well as cacheAsBitmap.