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

Native Development

Reply
New Developer
olejpoland
Posts: 10
Registered: ‎07-05-2012
My Device: BlackBerry 10 Dev Alpha
My Carrier: x

FPS limit, V-Sync and event handling

Hi,

 

I have a question how to properly handle events and FPS limit on BB10 Dev Alpha. My main application loop looks pretty much like in tutorials:

 

while (!exit_application) {
        while (true) {
            rc = bps_get_event(&event, 0);

            if (event) {
                // (...) handle events
            } else {
                break;
            }
        }
        onRun2D(timeDelta); // OpenGL draw method
    }

 

According to documentation, bps_get_event when handled 0 as timeout period exits immidiately whether there is an event to process or not. Therefore after handling all events, the loop should break and application should proceed to main draw method. In other words, the application shouldn't have any FPS limit and draw everything as quickly as it is possibble.

 

However, dispite onRun2D() lasting usually about from 0.005 up to 0.02 seconds the main application loops always lasts 0.033 seconds, so it has to be bps_get_event "keeping" me from drawing too often (forcing a limit of 30 frames per second). It is a behaviour not mentioned in official documentation, so I wonder if it is possible to at least change the limit up to 60 FPS or even get full control and code it manually.

 

Also, what is the refresh rate of LCD on Dev Alpha?

 

Thanks in advance,

 

Michał Olejnik

Programmer @ Vivid Games

Please use plain text.
Developer
MikePembo951
Posts: 107
Registered: ‎02-15-2012
My Device: Blackberry Playbook 32GB
My Carrier: Virgin Mobile

Re: FPS limit, V-Sync and event handling

I noticed this too. I'm currently capped at 30FPS and cannot seem to get around that collecting events is slowing my app. I'm sure that by looking at some of EAs and Gameloft's game they are running at smooth 60FPS and not 30.

However I downloaded a performance app from the BB app world for my playbook and even though it is to test performance it seems capped at 30fps and only ever reads lower not higher even if only there are 4 vertices.

 

Please use plain text.
Developer
MikePembo951
Posts: 107
Registered: ‎02-15-2012
My Device: Blackberry Playbook 32GB
My Carrier: Virgin Mobile

Re: FPS limit, V-Sync and event handling

*I missed the obvious!

How about receiving the event from another thread?

Im currently programming my recent app for playbook using multiple threads and its less difficult than it sounds.

Google P_thread.

 

Please use plain text.
New Developer
olejpoland
Posts: 10
Registered: ‎07-05-2012
My Device: BlackBerry 10 Dev Alpha
My Carrier: x

Re: FPS limit, V-Sync and event handling

I may just do so, but still it would be nice to know the reason of this weird behaviour.

 

Let's hope somebody in RIM will take notice.

Please use plain text.
New Developer
olejpoland
Posts: 10
Registered: ‎07-05-2012
My Device: BlackBerry 10 Dev Alpha
My Carrier: x

Re: FPS limit, V-Sync and event handling

I just noticed that limit on Simulator is 60FPS. Strange :Ninja:

Please use plain text.
New Developer
olejpoland
Posts: 10
Registered: ‎07-05-2012
My Device: BlackBerry 10 Dev Alpha
My Carrier: x

Re: FPS limit, V-Sync and event handling

Ok, I've found an official solution. There is a tutorial http://devblog.blackberry.com/2012/06/blackberry-10-porting-case-study/ which shows how to create custom events and bind callback function with timer to SIGALRM signal. Unfortunately, it won't work with OpenGL applications. I'll let you know if I find if there is any workaround.

Please use plain text.
Developer
MikePembo951
Posts: 107
Registered: ‎02-15-2012
My Device: Blackberry Playbook 32GB
My Carrier: Virgin Mobile

Re: FPS limit, V-Sync and event handling

The 30fps limit from collecting bps events is probably implemented by RIM so that simple apps dont update too often and that simple apps dont have to handle timing.

Using another thread should work and is probably recommended anyway.

Please use plain text.
BlackBerry Development Advisor
smcveigh
Posts: 668
Registered: ‎11-29-2011
My Device: developer
My Carrier: other

Re: FPS limit, V-Sync and event handling

Have you tried running your bps loop without any other rendering, etc. in there to confirm it is bps limiting you to 30fps?

 

Please use plain text.
Developer
MikePembo951
Posts: 107
Registered: ‎02-15-2012
My Device: Blackberry Playbook 32GB
My Carrier: Virgin Mobile

Re: FPS limit, V-Sync and event handling

There is evidence of this in an app world app called performance test. Whilst it can tell you how many polys slow down the device below 30fps it cant tell you fps rates any higher than 30. So that app is locked at 30fps too.

Surely should just run bps code on another thread?

Please use plain text.
BlackBerry Development Advisor
smcveigh
Posts: 668
Registered: ‎11-29-2011
My Device: developer
My Carrier: other

Re: FPS limit, V-Sync and event handling

Well, that didn't really answer my question, so I went and coded up a test app which consisted of bps_get_event() in a while(1) loop.

This loop runs at 500 iterations per second on my Dev Alpha and my s/w build, so your previous assertion that "The 30fps limit from collecting bps events is probably implemented by RIM" is false.  There is no such limitation.

 

As I suspect, and as I was trying to allude to, the problem is with the poster using OpenGL drawing in the same thread which is going to be limited to the graphics refresh rate.  (which may be additionally limited by eglSwapInterval() )

 

There is no 30fps bps limitation.

 

Cheers,

Sean

 

Please use plain text.